matthews | R Documentation |
compute the Matthews correlation coefficient with actual and predict values.
matthews(predicted, y, positive)
predicted |
numeric. the predicted value of binary classification |
y |
factor or character. the actual value of binary classification |
positive |
level of positive class of binary classification |
The Matthews Correlation Coefficient has a value between -1 and 1, and the closer to 1, the better the performance of the binary classification.
numeric. The Matthews Correlation Coefficient.
# simulate actual data
set.seed(123L)
actual <- sample(c("Y", "N"), size = 100, prob = c(0.3, 0.7), replace = TRUE)
actual
# simulate predict data
set.seed(123L)
pred <- sample(c("Y", "N"), size = 100, prob = c(0.2, 0.8), replace = TRUE)
pred
# simulate confusion matrix
table(pred, actual)
matthews(pred, actual, "Y")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.