Repository navigation
feat(stats): rank-based effect size for ordinal scores - #177
k-dickinson merged 2 commits into
Conversation
|
Warning Review limit reached
Next review available in: 48 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe audit now detects supported ordinal scales and reports paired rank-biserial correlation, probability of superiority, confidence intervals, magnitude labels, and scale metadata. New effect-size utilities and tests cover ties, zero differences, invalid inputs, and continuous fallbacks. Documentation and methodology version updates describe the behavior. ChangesOrdinal effect-size support
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Audit
participant Classifier
participant EffectUtilities
participant Bootstrap
Audit->>Classifier: Extract and classify scores
Classifier-->>Audit: Ordinal status and scale levels
Audit->>EffectUtilities: Compute paired rank effects
EffectUtilities-->>Audit: Rank-biserial correlation and probability of superiority
Audit->>Bootstrap: Generate ordinal confidence interval
Bootstrap-->>Audit: Confidence interval and audit result
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/evaltrust/audit/statistical.py`:
- Around line 68-75: Normalize tolerance-matched ordinal scores in the analysis
flow after ordinal detection and before leader selection, deriving raw paired
differences from rounded scores so values equivalent under _INTEGER_SCORE_ATOL
remain tied. Update the cluster-resampling path to use the same normalized
differences when clusters are present, including the logic around the ordinal
metrics. Extend
test_ordinal_detection_accepts_integer_values_within_float_tolerance with the
specified tied-pair case and verify rank-biserial is 0.0 and probability of
superiority is 50%.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: d77a2461-d43a-4650-be2f-ae2e832fed47
📒 Files selected for processing (7)
CHANGELOG.mddocs/checks.mdsrc/evaltrust/audit/statistical.pysrc/evaltrust/stats/effect.pysrc/evaltrust/versions.pytests/test_effect.pytests/test_statistical.py
| score_values = _score_values(data, model_a, model_b) | ||
| binary = _is_binary(data, model_a, model_b, values=score_values) | ||
| ordinal_levels = _ordinal_levels( | ||
| data, model_a, model_b, values=score_values | ||
| ) | ||
| ordinal = not binary and _is_ordinal( | ||
| data, model_a, model_b, levels=ordinal_levels | ||
| ) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Normalize tolerance-matched ordinal scores before analysis.
At Line 59, raw is created before Lines 68-75 classify the scale. Lines 290-296 therefore send unrounded differences to the ordinal metrics.
With A=[1+5e-10, 2+5e-10, 3+5e-10] and B=[1, 2, 3], every pair is the same ordinal rating under _INTEGER_SCORE_ATOL. The current path reports rank-biserial +1.0 and probability of superiority 100% after leader orientation, instead of 0.0 and 50%.
After ordinal detection, derive raw from rounded paired scores before leader selection. When clusters exist, normalize the differences used for cluster resampling too. Extend test_ordinal_detection_accepts_integer_values_within_float_tolerance with this tied-pair case.
Also applies to: 173-186, 290-296
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/evaltrust/audit/statistical.py` around lines 68 - 75, Normalize
tolerance-matched ordinal scores in the analysis flow after ordinal detection
and before leader selection, deriving raw paired differences from rounded scores
so values equivalent under _INTEGER_SCORE_ATOL remain tied. Update the
cluster-resampling path to use the same normalized differences when clusters are
present, including the logic around the ordinal metrics. Extend
test_ordinal_detection_accepts_integer_values_within_float_tolerance with the
specified tied-pair case and verify rank-biserial is 0.0 and probability of
superiority is 50%.
What and why
Ordinal judge ratings now use paired rank effect sizes. Binary and clearly continuous scores keep their existing handling.
Closes #166.
Implementation
METHODOLOGY_VERSIONfrom1.0to1.1because the stored audit method changed.Flagged decision
The automatic ordinal rule requires integer-valued scores within a
1e-9absolute tolerance and 3 to 10 observed levels. Two levels stay on the binary or continuous path. More than 10 integer levels and all noninteger scales stay on the continuous path. This version does not add a declaration key because the current input and configuration contracts have no metric-type surface.This rule can be narrowed, widened, or replaced with an explicit declaration if the automatic boundary is not the intended policy.
Worked example
A 1 to 5 rating fixture has nine
+1paired differences, two-4differences, and one tie. Cohen's d is+0.043, which is negligible. Matched-pairs rank-biserial r is+0.364, which is medium, and probability of superiority is79.2%. Cohen's d treated the rating gaps as interval data and reduced the many paired wins to a negligible label.Issue mapping
Validation
pytest tests/test_effect.py tests/test_statistical.py tests/test_versions.py: 75 passed.pytest: 1129 passed, 1 skipped.wilcoxonvalidates rank-biserial r on seeded randomized data with ties and zeros.mannwhitneyuand brute-force enumeration validate probability of superiority.0eadbda82bd1b630e26487fc91b562d7e9841728dd1e07b6239fd4ed76cc2501.1561fe933525c99c9fd2f93bdfb561fe5cd334989697c3736fc0df5f89eb1695.Fixture grounding
The fixtures are grounded in
k-dickinson/evaltrustatd508963ce1940b30a2d510b7f496c97ffc0dbdf0. They extend the paired helpers and effect contracts intests/test_statistical.py,tests/test_effect.py,src/evaltrust/audit/statistical.py,src/evaltrust/stats/effect.py, andsrc/evaltrust/versions.py.Checklist
pytestis greenSummary by CodeRabbit
New Features
Documentation