Description Usage Arguments Details Value References Examples
View source: R/class_balance_accuracy_score_r.R
Assess classifier performance with Mosley's (2013) Class Balance Accuracy score.
1 | class_balance_accuracy_score_r(y_true, y_pred)
|
y_true |
Vector. The true classes. |
y_pred |
Vector. The predicted classes. |
The Class Balance Accuracy Score is a type of balanced accuracy
score to assess classifier performance on data with imbalanced classes in
multi-class supervised learning.
From Mosley (2013, p. 41–42):
"From its construction, CBA utilizes three core elements from each class
within the contingency table: the total number of correctly classified
cases, the total number of cases predicted into that class, and the total
number observed in the data. Intuitively, for each class the off-diagonal
row and column elements are reduced into a single sum. These singular sums
form the basis for the denominator of the per class accuracy contributions.
At the bottom of each per class ratio, the maximum of the row or column
sum is chosen resulting in either the Recall or Precision to be the
estimate of class accuracy. As a consequence, selecting the larger of the
two as the denominator provides the most conservative estimate of accuracy
that can be achieved. For each class, the per class Recall or Precision
are aggregated and treated as the numerator for the final ratio
calculation. By using the total number of classes in the dataset as the
divisor in the calculation we guarantee equal weight contributions for
all classes. In the end, Class Balance Accuracy acts as a measure that
independently accounts for the ability of the model to precisely recall
observations from each group within the target variable."
Numeric. The Class Balance Accuracy score.
Mosley L. (2013). A balanced approach to the multi-class imbalance problem. Graduate Theses and Dissertations. 13537. https://lib.dr.iastate.edu/etd/13537.
1 2 3 4 | x <- pxtextmineR::text_data %>%
dplyr::mutate(label_pred = sample(label, size = nrow(.))) # Mock predictions column
pxtextmineR::class_balance_accuracy_score_r(x$label, x$label_pred)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.