This function computes the accuracy of a classification.
Usage
accuracy_score(true, pred, weights = NULL, multi = c("average", "raw"), ...)
Arguments
- true
a vector of observed values
- pred
a vector of predicted values
- weights
vector of observation weights
- multi
what to do when response has multiple classes
average
errors of multiple classes are averaged to get a single value
raw
returns a vector containing one score for each class
- ...
not currently used
Value
A numeric vector of length one if multi = "average"
or nc
if
multi = "raw"
, where nc
is the number of classes.
Details
The accuracy measures the fraction of all instances that are correctly categorized. It is defined as:
$$ACC = \frac{correct}{total} = \frac{TP + TN}{P + N} = \frac{TP + TN}{TP + FP + TN + FN} = 1 - ERR$$
The optimal value is 1 and the worst value is 0.
The complementary statistic is the classification error rate
.