Learn R Programming

mlr3measures (version 0.3.0)

acc: Classification Accuracy

Description

Classification measure defined as $$ \frac{1}{n} \sum_{i=1}^n \left( t_i = r_i \right). $$

Usage

acc(truth, response, ...)

Arguments

truth

:: factor() True (observed) labels. Must have the same levels and length as response.

response

:: factor() Predicted response labels. Must have the same levels and length as truth.

...

:: any Additional arguments. Currently ignored.

Value

Performance value as numeric(1).

Meta Information

  • Type: "classif"

  • Range: \([0, 1]\)

  • Minimize: FALSE

  • Required prediction: response

See Also

Other Classification Measures: bacc(), ce(), logloss(), mauc_aunu(), mbrier()

Examples

Run this code
# NOT RUN {
set.seed(1)
lvls = c("a", "b", "c")
truth = factor(sample(lvls, 10, replace = TRUE), levels = lvls)
response = factor(sample(lvls, 10, replace = TRUE), levels = lvls)
acc(truth, response)
# }

Run the code above in your browser using DataLab