Description Usage Arguments Details References Examples
View source: R/ConfusionMatrix.R
Confusion Matrix is a contingency table that gives a visualization of the performance of an algorithm
1 |
yhat |
A predicted value vector. |
y |
A real value vector. |
metrics |
Calculate all metrics. See details for more information. |
Also it known as an error matrix. Normally, you can identify 4 elements, they known as true positive (TP), true negative (TN), false positive (FP) and false negative (FN). To understand it, a simple example is presented:
Real Values | ||
Estimated | Class 1 | Class 2 |
Class 1 | TP | FP |
Class 2 | FN | TN |
The problem arises that there is not always a clear relationship between which is the positive class or there may be different classes so it is also common to use the terms Type I error (FP), Type II error (FN) and unify the success or accuracy (TP+TN) in a single value.
Suppose a 3x3 table with notation
Real Values | |||
Estimated | Class 1 | Class 2 | Class 3 |
Class 1 | A | B | C |
Class 2 | D | E | F |
Class 3 | G | H | I |
where N = A+B+C+D+E+F+G+H+I The formulas used here are:
Success rate = (A+E+I)/N
Type I error = (B+F+C)/N
Type II error = (D+H+G)/N
Other indicators depends of one class and in the case choose Class 1
Sensitivity Class 1 = A/(A+D+G)
Specificity Class 1 = (E+I)/(B+E+H+C+F+I)
Precision Class 1 = A/(A+E+I),
also it is called Positive Predictive Value (PPV)
Prevalence Class 1 = (A+D+G)/N
Stehman, Stephen V. (1997). "Selecting and interpreting measures of thematic classification accuracy". Remote Sensing of Environment. 62 (1): 77–89. doi:10.1016/S0034-4257(97)00083-7.
1 2 3 4 5 6 7 8 9 10 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.