Skip to content
EvalSuite
Documentation menu

Classification

Cohen's kappa

Implementedclassification.cohen_kappa

Definition

Agreement between predicted and true labels corrected for agreement expected by chance.

Formula

κ = (pₒ − pₑ) / (1 − pₑ)

Range: [−1, 1]

Inputs and outputs

  • y_true: array of class labels
  • y_pred: array of predicted labels

Returns: float

Assumptions

No assumptions beyond valid, aligned inputs of the documented types.

Limitations

  • Depends on the marginal distributions, so values are hard to compare across datasets with different prevalence.

Python API

PythonSince v0.1.0
import evalsuite as es

es.cohen_kappa(y_true, y_pred, weights="quadratic")

References

  1. Cohen, J. (1960). A coefficient of agreement for nominal scales. Educational and Psychological Measurement, 20(1), 37–46.

Implementation status