calc_confusion_matrix: Calculate the confusion matrix

Description Usage Arguments Value Examples

View source: R/calc_confusion_matrix.R

Description

Calculates the confusion matrix of observed and predicted classes, after converting them into factors first (not currently done by conf_mat{yardstick}).

Usage

1
calc_confusion_matrix(x, target_col_name, target_pred_col_name, ...)

Arguments

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.

...

Further arguments passed from other methods.

Value

An object with class conf_mat() (see conf_mat{yardstick}).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
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_confusion_matrix(
    target_col_name = "carb",
    target_pred_col_name = "carb_pred"
  )

CDU-data-science-team/experienceAnalysis documentation built on Dec. 17, 2021, 12:53 p.m.