naivebayes::naive_bayes()
fits a model that uses Bayes' theorem to compute
the probability of each class, given the predictor values.
For this engine, there is a single mode: classification
This model has 2 tuning parameter:
smoothness
: Kernel Smoothness (type: double, default: 1.0)
Laplace
: Laplace Correction (type: double, default: 0.0)
Note that the engine argument usekernel
is set to TRUE
by default
when using the naivebayes
engine.
The discrim extension package is required to fit this model.
library(discrim)naive_Bayes(smoothness = numeric(0), Laplace = numeric(0)) %>%
set_engine("naivebayes") %>%
translate()
## Naive Bayes Model Specification (classification)
##
## Main Arguments:
## smoothness = numeric(0)
## Laplace = numeric(0)
##
## Computational engine: naivebayes
##
## Model fit template:
## naivebayes::naive_bayes(x = missing_arg(), y = missing_arg(),
## adjust = numeric(0), laplace = numeric(0), usekernel = TRUE)
The columns for qualitative predictors should always be represented as factors (as opposed to dummy/indicator variables). When the predictors are factors, the underlying code treats them as multinomial data and appropriately computes their conditional distributions.
For count data, integers can be estimated using a Poisson distribution
if the argument usepoisson = TRUE
is passed as an engine argument.
Variance calculations are used in these computations so zero-variance predictors (i.e., with a single unique value) should be eliminated before fitting the model.
The underlying model implementation does not allow for case weights.
Kuhn, M, and K Johnson. 2013. Applied Predictive Modeling. Springer.