data: (Optional) argument to call an existing data frame containing the data.
obs: Vector with observed values (character | factor).
pred: Vector with predicted values (character | factor).
tidy: Logical operator (TRUE/FALSE) to decide the type of return. TRUE returns a data.frame, FALSE returns a list (default).
na.rm: Logic argument to remove rows with missing values (NA). Default is na.rm = TRUE.
Returns
an object of class numeric within a list (if tidy = FALSE) or within a data frame (if tidy = TRUE).
Details
The error rate represents the opposite of accuracy, referring to a measure of the degree to which the predictions miss-classify the reality. The classification error_rate is calculated as the ratio between the number of incorrectly classified objects with respect to the total number of objects. It is bounded between 0 and 1. The closer to 1 the worse. Values towards zero indicate low error_rate of predictions. It can be also expressed as percentage if multiplied by 100. It is estimated at a global level (not at the class level). The error rate is directly related to the accuracy, since error_rate = 1 – accuracy' . For the formula and more details, see online-documentation
Examples
set.seed(123)# Two-classbinomial_case <- data.frame(labels = sample(c("True","False"),100,replace =TRUE), predictions = sample(c("True","False"),100, replace =TRUE))# Multi-classmultinomial_case <- data.frame(labels = sample(c("Red","Blue","Green"),100,replace =TRUE), predictions = sample(c("Red","Blue","Green"),100, replace =TRUE))# Get error_rate estimate for two-class caseerror_rate(data = binomial_case, obs = labels, pred = predictions, tidy =TRUE)# Get error_rate estimate for multi-class caseerror_rate(data = multinomial_case, obs = labels, pred = predictions, tidy =TRUE)
References
(2017) Accuracy. In: Sammut C., Webb G.I. (eds) Encyclopedia of Machine Learning and Data Mining