NBTrainer | R Documentation |
Trains a probabilistic naive bayes model
Trains a naive bayes model. It is built on top high performance naivebayes R package.
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
model
for internal use
new()
NBTrainer$new(prior, laplace, usekernel)
prior
numeric, 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
nuemric, value used for Laplace smoothing. Defaults to 0 (no Laplace smoothing)
usekernel
logical, if TRUE, density is used to estimate the densities of metric predictors
Create a new 'NBTrainer' object.
A 'NBTrainer' object.
data(iris) nb <- NBTrainer$new()
fit()
NBTrainer$fit(X, y)
X
data.frame containing train features
y
character, name of target variable
Fits the naive bayes model
NULL, trains and saves the model in memory
data(iris) nb <- NBTrainer$new() nb$fit(iris, 'Species')
predict()
NBTrainer$predict(X, type = "class")
X
data.frame containing test features
type
character, if the predictions should be labels or probability
Returns predictions from the model
NULL, trains and saves the model in memory
data(iris) nb <- NBTrainer$new() nb$fit(iris, 'Species') y <- nb$predict(iris)
clone()
The objects of this class are cloneable with this method.
NBTrainer$clone(deep = FALSE)
deep
Whether to make a deep clone.
## ------------------------------------------------
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.