mltools (version 0.3.4)

mcc: Matthews correlation coefficient

Description

Calculate Matthews correlation coefficient

Usage

mcc(preds = NULL, actuals = NULL, TP = NULL, FP = NULL, TN = NULL,
  FN = NULL)

Arguments

preds

A vector of prediction values in 1, 0, or TRUE, FALSE

actuals

A vector of actuals values in 1, 0, or TRUE, FALSE

TP

Count of true positives (correctly predicted 1/TRUE)

FP

Count of false positives (predicted 1/TRUE, but actually 0/FALSE)

TN

Count of true negatives (correctly predicted 0/FALSE)

FN

Count of false negatives (predicted 0/FALSE, but actually 1/TRUE)

Details

Calculate Matthews correlation coefficient. Either

  • preds and actuals can be given, leaving TP, FP, TN, and FN NULL or

  • TP, FP, TN, and FN can be given, leaving preds and actuals NULL

References

https://en.wikipedia.org/wiki/Matthews_correlation_coefficient

Examples

Run this code
# NOT RUN {
preds <- c(1,1,1,0,1,1,0,0)
actuals <- c(1,1,1,1,0,0,0,0)
mcc(preds, actuals)
mcc(actuals, actuals)
mcc(TP=3, FP=2, TN=2, FN=1)

# }

Run the code above in your browser using DataLab