fix(rust/scorer): sync recalibrated default weights with Elixir

Pre-existing CI failure (`tests/scorer_golden.rs`) — the Rust scorer
was still on the pre-recalibration weight vector, while the Elixir
side picked up new gradient-descent-fit weights in f98ee153.

- Update `DEFAULT_WEIGHTS` in band_config.rs to match the new Elixir
  values (humidity 0.1262, time_of_day 0.0380, td_depression 0.1010,
  refractivity 0.0986, sky 0.0841, season 0.1134, wind 0.0841,
  rain 0.1431, pressure 0.0967, pwat 0.1147).
- Loosen the sum-to-one tolerance in `default_weights_sum_to_one`
  from 1e-9 to 1e-3 to match Elixir's `assert_in_delta total, 1.0,
  0.001` — gradient-descent fits land near 1.0 but not exact.
- Regenerate `tests/scores.bincode` from `mix rust.golden` so the
  golden fixture reflects the recalibrated scorer outputs.

`cargo clippy --all-targets -- -D warnings` clean.
139 Rust unit tests + golden fixture pass.
3072 Elixir tests pass.
This commit is contained in:
Graham McIntire 2026-04-29 09:32:54 -05:00
parent af560be01e
commit fdecd51014
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59
3 changed files with 18 additions and 15 deletions

Binary file not shown.

View file

@ -55,20 +55,22 @@ impl Weights {
}
}
/// Default weight vector fit by gradient descent on 5,000 QSOs
/// (2026-04-11). Used as fallback for bands that don't carry a `weights`
/// override.
/// Default weight vector fit by gradient descent on the current contact
/// corpus (val loss 0.140 vs 0.146 train, refit 2026-04-28). Mirrors the
/// `@weights` map in `lib/microwaveprop/propagation/band_config.ex` —
/// must stay in sync any time `mix recalibrate_scorer` is run on the
/// Elixir side, otherwise `tests/scorer_golden.rs` will diverge.
pub const DEFAULT_WEIGHTS: Weights = Weights::new(
0.1243, // humidity
0.0496, // time_of_day
0.0978, // td_depression
0.1049, // refractivity
0.08, // sky
0.1112, // season
0.08, // wind
0.1362, // rain
0.1032, // pressure
0.1128, // pwat
0.1262, // humidity
0.0380, // time_of_day
0.1010, // td_depression
0.0986, // refractivity
0.0841, // sky
0.1134, // season
0.0841, // wind
0.1431, // rain
0.0967, // pressure
0.1147, // pwat
);
/// Sunrise hour by month (1..=12) in local solar time. Index = month - 1.
@ -792,8 +794,9 @@ mod tests {
+ w.rain
+ w.pressure
+ w.pwat;
// Elixir comment says "all 10 values sum to 1.0" — allow tiny FP slop.
assert!((sum - 1.0).abs() < 1e-9, "weights sum = {sum}");
// Match the Elixir-side tolerance (`assert_in_delta total, 1.0, 0.001`)
// — gradient-descent fits land near 1.0 but not exact.
assert!((sum - 1.0).abs() < 1.0e-3, "weights sum = {sum}");
}
#[test]