mcc: Matthews Correlation Coefficient

View source: R/binary_mcc.R

mccR Documentation

Matthews Correlation Coefficient

Description

Measure to compare true observed labels with predicted labels in binary classification tasks.

Usage

mcc(truth, response, positive, ...)

Arguments

truth

(factor())
True (observed) labels. Must have the exactly same two levels and the same length as response.

response

(factor())
Predicted response labels. Must have the exactly same two levels and the same length as truth.

positive

(character(1))
Name of the positive class.

...

(any)
Additional arguments. Currently ignored.

Details

The Matthews Correlation Coefficient is defined as

(TP * TN - FP * FN) / sqrt((TP + FP) * (TP + FN) * (TN + FP) * (TN + FN)).

This above formula is undefined if any of the four sums in the denominator is 0. The denominator is then set to 1.

Value

Performance value as numeric(1).

Meta Information

  • Type: "binary"

  • Range: [-1, 1]

  • Minimize: FALSE

  • Required prediction: response

References

Matthews BW (1975). “Comparison of the predicted and observed secondary structure of T4 phage lysozyme.” Biochimica et Biophysica Acta (BBA) - Protein Structure, 405(2), 442–451. doi: 10.1016/0005-2795(75)90109-9.

See Also

Other Binary Classification Measures: auc(), bbrier(), dor(), fbeta(), fdr(), fnr(), fn(), fomr(), fpr(), fp(), npv(), ppv(), prauc(), tnr(), tn(), tpr(), tp()

Examples

set.seed(1)
lvls = c("a", "b")
truth = factor(sample(lvls, 10, replace = TRUE), levels = lvls)
response = factor(sample(lvls, 10, replace = TRUE), levels = lvls)
mcc(truth, response, positive = "a")

mlr3measures documentation built on Aug. 5, 2022, 5:22 p.m.