Skip to main content

tune_weights

Function tune_weights 

pub fn tune_weights(
    intensities: &HashMap<String, [f64; 8], impl BuildHasher>,
    train: &[(String, bool)],
    validation: &[(String, bool)],
    defaults: &[(String, f64)],
) -> (Vec<(String, f64)>, TuningDecision)
Expand description

Constrained deterministic coordinate search over the eight SMELL_WEIGHTS (Unit D). intensities are per-file 8-smell intensity vectors in SMELL_WEIGHTS order (see capture_intensities); train/validation are (path, label) splits already partitioned by fix date (60/40, older/newer — a leakage guard against a random split, prepared by the caller); defaults are the weights to fall back to and the search’s starting point (see default_weights).

Honesty floor first: fewer than [MIN_LINKED_DEFECTS] total positively-labeled rows, or fewer than [MIN_IMPLICATED_FILES] distinct positively-labeled paths, across trainvalidation, keeps the defaults without running any search — the mined evidence is too thin to trust a tuned weight set. Past the floor, [coordinate_descent] searches train for the training-AUC-maximizing weights; the result is adopted only if its validation AUC clears [DISCRIMINATION_FLOOR] (at least random-level ranking on unseen recent defects) AND beats the defaults’ own validation AUC by at least [ACCEPTANCE_MARGIN] — otherwise the defaults are kept, with the reason recorded and both AUCs shown.

Returns the chosen weights (tuned when adopted, else defaults unchanged) plus the TuningDecision recording which branch fired.