
Last chance! 50% off unlimited learning
Sale ends in
Trains a naive bayes model. It is built on top high performance naivebayes R package.
NBTrainer
R6Class
object.
For usage details see Methods, Arguments and Examples sections.
nbt = NBTrainer$new(prior=NULL, laplace=0, usekernel=FALSE) nbt$fit(X_train, "target") prediction <- bst$predict(X_test)
$new()
Initialises an instance of naive bayes model
$fit()
fits model to an input train data and trains the model.
$predict()
returns predictions by fitting the trained model on test data.
for detailed explanation of parameters, check: https://cran.r-project.org/package=naivebayes
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.
value used for Laplace smoothing. Defaults to 0 (no Laplace smoothing)
if TRUE, density is used to estimate the densities of metric predictors
# NOT RUN {
data(iris)
nb <- NBTrainer$new()
nb$fit(iris, 'Species')
y <- nb$predict(iris)
# }
Run the code above in your browser using DataLab