Add predict_rating game-outcome prediction (PlayerRatings predict.rating) - #306
Merged
Conversation
…ting) Rust core predict_rating_two/predict_rating_multi in mlsirm-core scaling (Elo logistic, deviation-shrunk Glicko-family with qip3 = 3(ln10/400/pi)^2, EloM rowmean branch with optional min-tie placing), PyO3 bindings, Python wrappers, exact-oracle anchor tests P1-P9, 7-mutant EXECUTED kill map, MC-500 invariants, TestPredict pytest coverage, CHANGELOG entry. Normative source: CRAN PlayerRatings 1.1-0 R/ratings.R lines 1056-1133 (READ). REDUCED-SCOPE: index-based players, per-game/scalar gamma. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Impl-review round-1 findings: (1) games/tng went through a float round-trip in the Python wrappers, losing exact integer counts at or above 2^53 and silently shifting the strict games < tng cutoff — new _predict_games_u64/_predict_tng_u64 keep integer inputs lossless and reject float inputs at/above the source dtype's exact-integer bound; (2) predict_rating_multi computed nr*np unchecked, so a wrapping product could pass the length check and panic on indexing — now checked_mul with a checked error. Regression tests at both the Rust error contract and pytest levels. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
3 tasks
Contributor
Author
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
Implements
predict_rating/predict_rating_multi— game-outcome prediction from fitted rating states, a Rust reimplementation of CRAN PlayerRatings 1.1-0predict.rating(R/ratings.Rlines 1056–1133, READ and normative; no journal paper exists for this dispatch — CRAN package provenance only). Stacked on #305 (fide). This completes coverage of the PlayerRatings package (elo, glicko, glicko2, steph, elom, fide, metrics, predict).Model contract
Three branches, matching the R dispatch:
pred = 1 / (1 + 10^((brat − wrat − gamma)/400)), per-game or scalar gamma.vec = 1/sqrt(1 + qip3·(wdev² + bdev²))withqip3 = 3(ln10/400/π)²— the joint two-player shrink from the R source (both players' squared deviations inside ONE sqrt).pred = (rating − rowmean_{na.rm})/40per row of anr×npplayer matrix; optionalplacingreturns min-tie ranks of −pred with NaN kept.R semantics preserved: strict
games < tngunrated cutoff (stored value → NA),tratreplaces ALL missing extracted values (unmatched −1, low-games, stored-NA alike),pred >= thresh → 1/0with NaN propagation.REDUCED-SCOPE vs R: index-based players (−1 = unmatched; caller does name matching), no data-frame plumbing.
Verification evidence
predict_oracle.py, fixtures P1–P9): pins include P2 = 0.7898441797581306, P3 = 0.776912664201114, P9 = 0.7844611342833985, qip3 = 1.007239860196398e-05.< tng→<=< tng→<=>→>=>=→>cargo test -p mlsirm-core --lib→ 833 passed, 0 failed;pytest tests/test_paper_features.py→ 328 passed (incl. new TestPredict ×6).pr_mc_500_invariantsMC-500#[ignore]test passes.Adversarial impl-review outcome
games/tnginteger fidelity above 2^53 via a float round-trip, shifting the strictgames < tngcutoff; (2)predict_rating_multicomputednr * npunchecked, so a wrapping product could pass the length check and panic across the PyO3 boundary. Both fixed in 4cbba18: lossless_predict_games_u64/_predict_tng_u64validators (int inputs exact to u64; float inputs bounded by the source dtype's exact-integer limit) andchecked_mulwith a checked error, plus Rust + pytest regressions for both.pr_suite 8 pass, TestPredict 7 pass, oracle pins unchanged.