Description Usage Arguments Details Value Examples
View source: R/calc_accuracy_per_class.R
Calculates the accuracy of a predictive model for each class.
1 2 3 4 5 6 | calc_accuracy_per_class(
x,
target_col_name,
target_pred_col_name,
column_names = NULL
)
|
x |
A data frame with two columns: the column with the actual classes; and the column with the predicted classes. Any other columns will be ignored. |
target_col_name |
A string with the column name of the target variable. |
target_pred_col_name |
A string with the column name of the predictions for the target variable. |
column_names |
A vector of strings or |
This function was originally designed for use with package
{pxtextminingdashboard}
,
in which case column_names
is set to c("class", "accuracy")
. It can,
however, be used outside the context of{pxtextminingdashboard}
, by
controlling the column_names
argument:
When column_names
is NULL
, then the returned data frame names
are c(target_col_name, "accuracy")
.
When column_names
is a vector of strings, the returned data
frame names are as in the vector.
A data frame/tibble with as many rows as the number of unique labels.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | library(experienceAnalysis)
mtcars %>%
dplyr::mutate(carb_pred = sample(carb, size = nrow(.))) %>% # Mock predictions column
calc_accuracy_per_class(
target_col_name = "carb",
target_pred_col_name = "carb_pred"
)
# Custom column names
mtcars %>%
dplyr::mutate(carb_pred = sample(carb, size = nrow(.))) %>% # Mock predictions column
calc_accuracy_per_class(
target_col_name = "carb",
target_pred_col_name = "carb_pred",
column_names = c("class", "accuracy_per_class")
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.