Trains a probabilistic naive bayes model
Trains a naive bayes model. It is built on top high performance naivebayes R package.
priornumeric vector with prior probabilities. vector with prior probabilities of the classes. If unspecified, the class proportions for the training set are used. If present, the probabilities should be specified in the order of the factor levels.
laplacevalue used for Laplace smoothing. Defaults to 0 (no Laplace smoothing)
usekernelif TRUE, density is used to estimate the densities of metric predictors
modelfor internal use
new()NBTrainer$new(prior, laplace, usekernel)priornumeric, prior numeric vector with prior probabilities. vector with prior probabilities of the classes. If unspecified, the class proportions for the training set are used. If present, the probabilities should be specified in the order of the factor levels.
laplacenuemric, value used for Laplace smoothing. Defaults to 0 (no Laplace smoothing)
usekernellogical, if TRUE, density is used to estimate the densities of metric predictors
predict()
## ------------------------------------------------
## Method `NBTrainer$new`
## ------------------------------------------------
data(iris)
nb <- NBTrainer$new()
## ------------------------------------------------
## Method `NBTrainer$fit`
## ------------------------------------------------
data(iris)
nb <- NBTrainer$new()
nb$fit(iris, 'Species')
## ------------------------------------------------
## Method `NBTrainer$predict`
## ------------------------------------------------
data(iris)
nb <- NBTrainer$new()
nb$fit(iris, 'Species')
y <- nb$predict(iris)
#> Warning: predict.naive_bayes(): more features in the newdata are provided as there are probability tables in the object. Calculation is performed based on features to be found in the tables.