feat(scaling): Stephenson rating system (PlayerRatings steph()) - #302
Merged
Conversation
Rust core stephenson_rating extending Glicko with per-game neighborhood variance (ngames*hval^2), per-game bonus bval/100 on both sides, participants-only lambda drift toward opponents, and (lag+1)*cval^2 per-period deviation-variance inflation clamped at rdmax^2. Normative source: CRAN PlayerRatings 1.1-0 R driver (ratings.R 591-737) + C kernel (ratings.c stephenson_c 157-202), both READ and line-cited; no journal paper exists (Kaggle-2010 provenance noted as NOT independently verifiable). PyO3 binding + NumPy wrapper with PlayerRatings defaults. Tests anchored to an EXECUTED faithful oracle port (S1 heterogeneous init, S2 two-period draw/lag, S3 full knobs, S4 rdmax clamp + prior-run continuation, S5 bval symmetry, lambda=0 contrast; 1e-12 pins), 500-rep MC invariants (#[ignore]), and five EXECUTED mutation kills: bval drop, lambda sign flip, per-game hval scaling drop, (lag+1)->lag, opponent-g->own-g. 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 |
- Enforce the 2..=10000 n_players cap in the Python wrapper BEFORE any length-n allocation (High: huge n_players previously attempted the allocation instead of raising ValueError). - Preserve integer fidelity for white/black player-id columns: integer dtypes cast directly to u64; float/object inputs are rejected at or above the dtype's exact-integer bound before the uint64 cast, matching the existing period-label contract (Medium). - Guard u64 counter overflow in the Rust core: init_games/init_lag values that could overflow across the run's increments now return Err instead of panicking (debug) or wrapping (release) (Medium). Regression tests: Rust st_error_contract overflow cases; Python fidelity + pre-allocation cap cases. 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.
Iteration 61: Stephenson rating system (
stephenson_rating)Implements the Stephenson rating system as in CRAN PlayerRatings 1.1-0
steph().Citation governance
R/ratings.Rlines 591-737 (steph()driver) andsrc/ratings.clines 157-202 (stephenson_ckernel) — every formula line-cited in the Rust core header.What it adds over Glicko
ngames * hval^2inside the deviation update.bval/100added to each played game's score on both sides.(lambda/100) * sum(r_opp - r_self) / ngames.(lag+1) * cval^2per-period deviation-variance inflation clamped atrdmax^2(note(lag+1), unlike Glicko-2'slag * sigma^2).init_games/init_lag; per-game white advantagegamma.Verification
ngames*hval^2 -> hval^2, MU4(lag+1) -> lag, MU5 opponent-g -> own-g.mlsirm-core --lib802 pass; pytesttest_paper_features.py310 pass;st_mc_500(500-rep MC,#[ignore]) pass.Surface
mlsirm_core::scaling::stephenson_rating(+StephensonResult).stephenson_rating(plain name, scaling-section precedent).fast_mlsirm.stephenson_ratingwith PlayerRatings defaultsinit=(2200, 300), cval=10, hval=10, bval=0, lambda_=2, rdmax=350.Stacked on #301 (Glicko-2).
Adversarial impl-review outcome
Round 1 (commit 3514293): FINDINGS ? 3 confirmed
n_playerscap only in the Rust core, AFTER length-n allocations ? hugen_playersattempted a huge allocation instead of raising ValueError.white/blackplayer-id columns were cast through the float view, losing integer fidelity at/above the dtype's exact-integer bound before the u64 range checks.games/lagcounter increments on caller-supplied u64 state could overflow (debug panic / release wrap) withinit_games/init_lagnearu64::MAX.Fixes (commit 3e4fc99): early Python cap before any allocation; raw-integer-dtype direct u64 casts + fidelity rejection for float/object player ids; up-front
u64::MAX - goverflow guard in the Rust core. Regression tests added on both sides (Rustst_error_contractoverflow cases; Python fidelity + pre-allocation cap cases).Round 2 (commit 3e4fc99): CLEAN ? all three fixes verified, including the negative integer player-id path; targeted Rust + Python error-contract suites re-run green.