Skip to content

FIX: exclude NaN ratings with finite Krippendorff missing sentinel - #4654

Merged
Roman Lutz (romanlutz) merged 2 commits into
microsoft:mainfrom
feiiiiii5:feiiiiii5/1126-D299
Nov 27, 2026
Merged

Roman Lutz (romanlutz) merged 2 commits into
microsoft:mainfrom
feiiiiii5:feiiiiii5/1126-D299

Conversation

@feiiiiii5

Copy link
Copy Markdown
Contributor

Description

krippendorff_alpha() documents np.nan and a caller-supplied finite sentinel as equivalent ways to mark missing ratings. The mask at krippendorff.py:54 used only one encoding, so with missing=0.0 an actual np.nan cell was treated as a valid rating and created a phantom nan category. A perfect-agreement dataset reported alpha -0.5 instead of 1.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

  • Five new offline tests: base-red 5/5 failed (alpha mismatch, perfect agreement -0.5); with fix 5/5 passed.
  • test_krippendorff.py 52 passed; downstream test_scorer_evaluator.py 158 passed; broad tests/unit/score/ 7832 passed with 13 pre-existing unrelated environment failures.
  • ruff check and ruff format --check clean.

No real-model, network, or sleep-based tests used.

Copilot AI balanced review requested due to automatic review settings November 26, 2026 07:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

@romanlutz
Roman Lutz (romanlutz) added this pull request to the merge queue Nov 27, 2026
Merged via the queue into microsoft:main with commit 983e3fd Nov 27, 2026
72 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Krippendorff alpha counts NaN ratings with finite missing sentinel

3 participants