confusion_matrix: Confusion Matrix

Description Usage Arguments Value Author(s) Examples

Description

Confusion matrix - a special kind of contingency table - is a specific table layout that allows the visualization of performance of a classification model (or classifier). It composes of four different combinations of predicted and actual values.

confusion_list computes and returns those combinations as a named list while mtr_confusion_matrix returns a named matrix.

Here's elements of confusion matrix:

Usage

1
2
3
confusion_list(actual, predicted, cutoff = 0.5)

mtr_confusion_matrix(actual, predicted, cutoff = 0.5)

Arguments

actual

[numeric] Ground truth binary numeric vector containing 1 for the positive class and 0 for the negative class.

predicted

[numeric] A vector of estimated probabilities.

cutoff

[numeric] A cutoff value for predicted vector which classify a sample into a given class. Default value is 0.5

Value

A named list or a named two dimensions matrix

Author(s)

An Chu

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
act <- c(1, 0, 0, 1, 1)
pred <- c(0.9, 0.3, 0.6, 0.5, 0.2)

## output as a R's list
## metrics:::confusion_list(act, pred) # default value of cutoff = 0.5
## metrics:::confusion_list(act, pred, cutoff = 0.7)

## output as a R's matrix
mtr_confusion_matrix(act, pred)
mtr_confusion_matrix(act, pred, cutoff = 0.7)

chuvanan/metrics documentation built on Nov. 4, 2019, 8:52 a.m.