Learn R Programming

superml (version 0.2.0)

NBTrainer: Naive Bayes Trainer

Description

Trains a naive bayes model. It is built on top high performance naivebayes R package.

Usage

NBTrainer

Format

R6Class object.

Usage

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)

Methods

$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.

Arguments

prior

for detailed explanation of parameters, check: https://cran.r-project.org/package=naivebayes

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.

laplace

value used for Laplace smoothing. Defaults to 0 (no Laplace smoothing)

usekernel

if TRUE, density is used to estimate the densities of metric predictors

Examples

Run this code
# NOT RUN {
data(iris)
nb <- NBTrainer$new()
nb$fit(iris, 'Species')
y <- nb$predict(iris)
# }

Run the code above in your browser using DataLab