Skip to main content

zer_core/
scoring.rs

1use crate::{comparison::ComparisonVector, record::RecordId};
2
3/// Coarse classification of a scored pair based on match probability.
4#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
5pub enum MatchBand {
6    AutoMatch,
7    Borderline,
8    AutoReject,
9}
10
11/// Learned Fellegi-Sunter m/u parameters and classification thresholds for one schema.
12#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
13pub struct ModelParams {
14    pub m: Vec<Vec<f32>>,
15    pub u: Vec<Vec<f32>>,
16    pub log_prior_odds:  f32,
17    pub upper_threshold: f32,
18    pub lower_threshold: f32,
19}
20
21/// A candidate pair annotated with its match weight, probability, and band.
22#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
23pub struct ScoredPair {
24    pub record_a:          RecordId,
25    pub record_b:          RecordId,
26    pub match_weight:      f32,
27    pub match_probability: f32,
28    pub vector:            ComparisonVector,
29    pub band:              MatchBand,
30}