Repository navigation
FIX: exclude NaN ratings with finite Krippendorff missing sentinel - #4654
Merged
Roman Lutz (romanlutz) merged 2 commits intoNov 27, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the change to consistently treat NaN ratings as missing.
No open issues 🎉
What changed in this PR
Fixes #4653 by ensuring Krippendorff’s alpha always treats NaN ratings as missing, including when a finite missing-value sentinel is configured.
Changes:
- Excludes both NaN values and the configured sentinel without changing downstream calculations.
- Adds five regression cases covering equivalent missing-value encodings and the reported perfect-agreement failure.
| File | Description |
|---|---|
tests/unit/score/test_krippendorff.py |
Adds regression coverage for NaN handling with a finite sentinel. |
pyrit/score/scorer_evaluation/krippendorff.py |
Updates the validity mask to always exclude NaN ratings. |
Review effort: Balanced
Roman Lutz (romanlutz)
approved these changes
Nov 27, 2026
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.
Description
krippendorff_alpha()documentsnp.nanand a caller-supplied finite sentinel as equivalent ways to mark missing ratings. The mask atkrippendorff.py:54used only one encoding, so withmissing=0.0an actualnp.nancell was treated as a valid rating and created a phantomnancategory. A perfect-agreement dataset reported alpha-0.5instead of1.0. Fixes #4653.Changes
Always exclude NaN; exclude the finite sentinel only when configured.
valid_ratings,categories, and all downstream logic are unchanged. Title follows the repo's FIX convention; only the Description section is used as required by the PR template.Verification
-0.5); with fix 5/5 passed.test_krippendorff.py52 passed; downstreamtest_scorer_evaluator.py158 passed; broadtests/unit/score/7832 passed with 13 pre-existing unrelated environment failures.ruff checkandruff format --checkclean.No real-model, network, or sleep-based tests used.