The Momocs::classification_metrics() function as well as the mltools::mcc() fucntion are used to generate metrics to evaluate the performance of classification.

eval.classification.results(actual, predicted, name = "")

Arguments

actual

A character vector that indicates the actual class for each observation.

predicted

A character vector that indicates the predicted class for each observation.

name

A string that specifies a name to assign to this iteration of the function. Default is blank.

Value

A list with 4 objects:

  1. Name. Helpful if this function is put into a loop and the output is meant to be written into a separate text file. Otherwise, just leave blank.

  2. Contingency table used for calculating classification metrics by Momocs.

  3. Metrics calculated by Momocs.

  4. MCC value calculated by mltools labeled.

Details

Helpful for reference: https://rdrr.io/cran/Momocs/man/classification_metrics.html

https://blog.revolutionanalytics.com/2016/03/com_class_eval_metrics_r.html

https://github.com/saidbleik/Evaluation

See also

Examples

id = c("1a", "1b", "1c", "1d", "1e", "1f", "1g", "2a", "2b", "2c", "2d", "2e", "2f", "3a", "3b", "3c", "3d", "3e", "3f", "3g", "3h", "3i") x = c(18, 21, 22, 24, 26, 26, 27, 30, 31, 35, 39, 35, 30, 40, 41, 42, 44, 46, 47, 48, 49, 54) y = c(10, 11, 22, 15, 12, 13, 14, 33, 39, 37, 44, 40, 45, 27, 29, 20, 28, 21, 30, 31, 23, 24) a = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) b = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) actual = as.factor(c("1", "1", "1", "1", "1", "1", "1", "2", "2", "2", "2", "2", "2", "3", "3", "3", "3", "3", "3", "3", "3", "3")) example.data <- data.frame(id, x, y, a, b, actual) set.seed(2) rf.result <- randomForest::randomForest(x=example.data[,c("x", "y", "a", "b")], y=example.data[,"actual"], proximity=TRUE) predicted <- rf.result$predicted actual <- example.data[,"actual"] results <- eval.classification.results(as.character(actual), as.character(predicted), "Example")
#> Warning: `data_frame()` was deprecated in tibble 1.1.0. #> Please use `tibble()` instead.