kappa_coeff: Cohen's Kappa coefficient

View source: R/metrics.R

kappa_coeffR Documentation

Cohen's Kappa coefficient

Description

Given the observed and predicted values of categorical data (of any number of classes) computes the Cohen's Kappa coefficient.

Usage

kappa_coeff(observed, predicted, remove_na = TRUE)

Arguments

observed

(factor) The observed values. It has to have the same length as predicted.

predicted

(factor) The observed values. It has to have the same length as observed.

remove_na

(logical(1)) Should NA values be removed?. TRUE by default.

Details

Given a confusion matrix P, Cohen's Kappa coefficient is be computed by:

kappa(x) = (P_o - P_e) / (1 - P_e)

P_o is the sum of all diagonal values and P_e is the sum of all the products of row i times col i.

Value

A single numeric value with the Cohen's Kappa coefficient.

See Also

Other categorical_metrics: accuracy(), brier_score(), categorical_summary(), confusion_matrix(), f1_score(), math_mode(), matthews_coeff(), pccc(), pcic(), pr_auc(), precision(), recall(), roc_auc(), sensitivity(), specificity()

Examples

## Not run: 
kappa_coeff(factor(c("a", "b")), factor(c("a", "b")))
kappa_coeff(factor(c("a", "b")), factor(c("b", "a")))
kappa_coeff(factor(c("a", "b", "a")), factor(c("b", "a", "c")))

## End(Not run)


brandon-mosqueda/SKM documentation built on Feb. 8, 2025, 5:24 p.m.