evalMetrics: Compute Selected Evaluation Metrics

View source: R/evalMetrics.R

evalMetricsR Documentation

Compute Selected Evaluation Metrics

Description

Compute selected evaluation metrics for binary (i.e. two-class) confusion matrices.

Usage

evalMetrics(mat, type = c("accuracy", "precision", "recall"))

Arguments

mat

Binary confusion matrix (2-by-2; see Examples).

type

Target evaluation metric as character, defaults to "accuracy". Other available options are "precision" and "recall".

Value

A single numeric.

Author(s)

Florian Detsch

References

University of Michigan (2017) Applied Machine Learning in Python. Available online: https://www.coursera.org/learn/python-machine-learning/home/welcome.

Examples

in1 = matrix(c(96, 4, 8, 19), nc = 2L, byrow = TRUE)
rownames(in1) = c("Condition Positive", "Condition Negative")
colnames(in1) = c("Predicted Positive", "Predicted Negative")

evalMetrics(in1) # default: "accuracy"
evalMetrics(in1, "precision")
evalMetrics(in1, "recall")

in2 = matrix(c(26, 17, 7, 400), nc = 2, byrow = TRUE)
evalMetrics(in2, "precision")
evalMetrics(in2, "recall")


Orcs documentation built on Jan. 6, 2023, 5:14 p.m.