R/naive_classification_summary_cv.R
naive_classification_summary_cv.Rd
Given a set of observed data including a categorical response variable y and a naiveBayes model of y, this function returns a cross validated confusion matrix by which to assess the model's posterior classification quality.
naive_classification_summary_cv(model, data, y, k = 10)
a naiveBayes model object with categorical y
data frame including the variables in the model
a character string indicating the y variable in data
the number of folds to use for cross validation
a list
data(penguins_bayes, package = "bayesrules")
example_model <- e1071::naiveBayes(species ~ bill_length_mm, data = penguins_bayes)
naive_classification_summary_cv(model = example_model, data = penguins_bayes, y = "species", k = 2)
#> $folds
#> fold Adelie Chinstrap Gentoo overall_accuracy
#> 1 1 0.961039 0.06451613 0.8750000 0.7674419
#> 2 2 0.960000 0.13513514 0.8666667 0.7500000
#>
#> $cv
#> species Adelie Chinstrap Gentoo
#> Adelie 96.05% (146) 0.00% (0) 3.95% (6)
#> Chinstrap 5.88% (4) 10.29% (7) 83.82% (57)
#> Gentoo 7.26% (9) 5.65% (7) 87.10% (108)
#>