Train a Tidy Naive Bayes classifier model

# S3 method for default
tidy_naive_bayes(x, y)

# S3 method for formula
tidy_naive_bayes(formula, data)

# S3 method for tbl_df
tidy_naive_bayes(.data, class_var)

Arguments

x

A data frame.

y

A vector.

formula

An object of class 'formula' of the form 'class ~ predictors'.

data

A data frame.

Value

A Tidy Naive Bayes classifier model.

See also

predict.tidy_naive_bayes()

Examples

library(tibble) data(iris) model <- tidy_naive_bayes(Species ~ ., iris) new_flowers <- tribble( ~Sepal.Length, ~Sepal.Width, ~Petal.Length, ~Petal.Width, 5.3, 3.4, 1.6, 0.3, 7.7, 3.9, 6.3, 2.1 ) predict(model, new_flowers)
#> [1] setosa virginica #> Levels: setosa versicolor virginica
predict(model, new_flowers, type = "prob")
#> setosa versicolor virginica #> [1,] 1.000000e+00 3.539348e-15 1.827735e-22 #> [2,] 1.660286e-245 2.588513e-10 1.000000e+00