
Calibrate matches end-to-end (features -> filter -> apply)
Source:R/generics_calibration.R
calibrate_matches.RdHigh-level Q5 verb. Builds features via match_features(), fits a
Filter_Model via fit_filter(), and applies it via
apply_filter() to return a Calibrated_Matches object enriched
with tp_prob / predicted_tp. Dispatches on the strategy class.
Arguments
- matches
Match output table (data.table / tibble / data.frame / DuckDB lazy
tbl).- strategy
The
search_strategy()orembedding_strategy()used to producematches.- ...
Method-specific arguments. Required:
labels(manually labelled rows produced byimport_labels()),base, andid. Optional:target,target_id(forwarded tomatch_features()),model,class_weighted,na_fill,threshold, plus allmatch_features()tuning knobs (top_n,include_string_sim,include_block_stats,method).
Examples
strat <- search_strategy(
workshop ~ normalize_text() + word_tokens(min_nchar = 3),
proprietor ~ normalize_text() + word_tokens(min_nchar = 2),
block_by = c("postcode_area", "trade"),
threshold = 0.30
)
matches <- search_candidates(
workshop_listings, workshop_register,
base_id = "listing_id", target_id = "reg_no", strategy = strat
)
# One call: build features, fit the filter, apply it. Uses the shipped
# labelled pairs, which line up with this exact search.
calibrate_matches(matches, strat, labels = match_labels_example,
base = workshop_listings, id = "listing_id",
target = workshop_register, target_id = "reg_no")
#>
#> ── Calibrated_Matches ──────────────────────────────────────────────────────────
#> <joinery::Calibrated_Matches>
#> threshold : 0.7237 (method: youden_j)
#> n_rows : 1930
#> predicted_tp == 1: 1232
#> predicted_tp == 0: 698
#> tp_prob quantiles: 0.000 / 0.016 / 0.972 / 0.998 / 1.000