Repository navigation
ENH: Add Krippendorff's alpha to stats.inter_rater - #10738
Merged
Merged
Conversation
krippendorff_alpha computes Krippendorff's alpha for any number of raters with missing ratings, at the nominal, ordinal, interval and ratio levels, following Krippendorff (2011). The tests check the values published in that document, the exact fractions from its coincidence matrix, R irr kripp.alpha, a pairwise computation from the definition, and the relation to Fleiss' kappa for complete nominal data.
Allan-dq
force-pushed
the
enh-krippendorff-alpha
branch
from
November 11, 2026 17:18
c3cd894 to
a6c99d6
Compare
Member
|
Thanks LGTM. |
4 of 5 tasks
bashtage
added a commit
that referenced
this pull request
Nov 16, 2026
Follow-up to the merged #10738. The docstring now says that raters are in columns, the transpose of R irr::kripp.alpha and DescTools::KrippAlpha, and that a transposed matrix is accepted and gives a different alpha without an error (with an example). It says that a single used category gives nan while irr returns 1, that for two raters Fleiss' kappa is Scott's pi so that alpha is 1 - (1 - pi) * (n - 1) / n instead of being equal to pi, and that memory and time grow with the number of distinct ratings. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
bashtage
added a commit
that referenced
this pull request
Nov 16, 2026
Follow-up to the merged #10738. Replace the while loop with continue in test_krippendorff_alpha_random_vs_pairs by a parametrization over kind, level and seed, and compare with the pairwise definition also for non-consecutive codes, negative codes (not for ratio) and float ratings. The undefined cases now run with warnings as errors: numpy's 0 / 0 RuntimeWarning is not an error in this repo, so deleting the len(values) < 2 return kept every test green. Do not match the wording of the message of array_like. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
bashtage
added a commit
that referenced
this pull request
Nov 16, 2026
DOC: Follow up #10738 on krippendorff_alpha, with tighter tests
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.
I needed Krippendorff's alpha when evaluating LLM scorers, and statsmodels doesn't have it, so I added it. The results match the original paper and R. R's irr has a bug when there are no missing values. Confidence intervals are not implemented yet; they can be added later.
NumPy's guide.
AI Disclosure
Contributions must comply with the statsmodels AI Policy.
Tick exactly one of the following. If AI tools were used, replace the
<...>placeholders in the second option with the tool name(s) and how the tool's output was
used.
Tool(s): Claude Code (Claude Opus 5.5).
Used for: drafting the implementation, the tests and the docstring, running the cross-checks against the paper, R and other implementations, and translating this description from Chinese.
I have personally read, understood, and can explain every line of this diff, and
have verified the statistical/numerical correctness of the change.
Details
Notes:
needed for doc changes.
then show that it is fixed with the new code.
verify your changes are well formatted by running
ruffis installed. While passing this test is not required, it is good practice and it helpimprove code quality in
statsmodels.AI Policy for what disclosure
and review is expected of you before submitting.