fix(auc+encoder): review follow-ups from #374, clippy fix, coverage tests, v0.6.0 - #375
Merged
Conversation
- Apply the core fix from PR #374: compare scores in sorted order via label_idx to correctly rank-average non-adjacent tied scores. - Add `auc_all_tied_scores` edge-case test (all predictions equal → AUC 0.5). - Add comments documenting the rank loop invariant and tie-group logic. - Add `debug_assert!(label_idx[j] < n)` to make bounds safety explicit. - Add comment on the rank-averaging formula.
…overage tests - Fix clippy::unnecessary_sort_by: use sort_by_key(|a| a.1) instead of sort_by(|a, b| a.1.cmp(&b.1)) in from_category_map. - Add tests covering: num_categories(), get_num(), get_cat(), get_categories() slice, get_ordinal() for unknown category, invert_one_hot() multi-hot error path, and make_one_hot() directly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #374 (now merged). Applies the remaining review suggestions and an unrelated clippy fix discovered in
series_encoder.rs, plus a minor version bump.src/metrics/auc.rsauc_all_tied_scores): exercises the innerwhile j < nloop running tonwithout early exit; asserts AUC = 0.5 (random performance), matching the Wilcoxon expectation.rank[i]for the first element of a tie group is written in the same outer-loop iteration, clarifying the subtle advance ofitoj.debug_assert!(label_idx[j] < n): makes the bounds-safety invariant (argsort produces a[0..n)permutation) explicit at runtime in debug builds.(i+1+j)/2is the average of 1-based ranks[i+1 .. j]inclusive.src/preprocessing/series_encoder.rssort_by(|a, b| a.1.cmp(&b.1))→sort_by_key(|a| a.1)(clippy::unnecessary_sort_by, was causing a compile error under-D warnings).num_categories_returns_correct_countget_num_known_and_unknownget_cat_round_tripsget_categories_slice_matches_positional_orderget_ordinal_unknown_returns_noneinvert_one_hot_multi_hot_errormake_one_hot_directfrom_category_map_preserves_orderCargo.toml0.5.0→0.6.0.Checklist
development(branched after Fix ROC AUC computation for tied prediction scores #374 merged).cargo fmt --all -- --check— clean.cargo clippy --all-features -- -Drust-2018-idioms -Dwarnings— clean.cargo test --lib— all tests pass.