R/naive_classification_summary.R
naive_classification_summary.Rd
Given a set of observed data including a categorical response variable y and a naiveBayes model of y, this function returns summaries of the model's posterior classification quality. These summaries include a confusion matrix as well as an estimate of the model's overall accuracy.
naive_classification_summary(model, data, y)
a naiveBayes model object with categorical y
data frame including the variables in the model
a character string indicating the y variable in data
a list
data(penguins_bayes, package = "bayesrules")
example_model <- e1071::naiveBayes(species ~ bill_length_mm, data = penguins_bayes)
naive_classification_summary(model = example_model, data = penguins_bayes, y = "species")
#> $confusion_matrix
#> species Adelie Chinstrap Gentoo
#> Adelie 95.39% (145) 0.00% (0) 4.61% (7)
#> Chinstrap 5.88% (4) 8.82% (6) 85.29% (58)
#> Gentoo 6.45% (8) 4.84% (6) 88.71% (110)
#>
#> $overall_accuracy
#> [1] 0.7587209
#>