mlr3learners (version 0.6.0)

mlr_learners_classif.naive_bayes: Naive Bayes Classification Learner

Description

Naive Bayes classification. Calls e1071::naiveBayes() from package e1071.

Arguments

Dictionary

This Learner can be instantiated via the dictionary mlr_learners or with the associated sugar function lrn():

mlr_learners$get("classif.naive_bayes")
lrn("classif.naive_bayes")

Meta Information

  • Task type: “classif”

  • Predict Types: “response”, “prob”

  • Feature Types: “logical”, “integer”, “numeric”, “factor”

  • Required Packages: mlr3, mlr3learners, e1071

Parameters

IdTypeDefaultRange
epsnumeric0\((-\infty, \infty)\)
laplacenumeric0\([0, \infty)\)
thresholdnumeric0.001\((-\infty, \infty)\)

Super classes

mlr3::Learner -> mlr3::LearnerClassif -> LearnerClassifNaiveBayes

Methods

Inherited methods


Method new()

Creates a new instance of this R6 class.

Usage

LearnerClassifNaiveBayes$new()


Method clone()

The objects of this class are cloneable with this method.

Usage

LearnerClassifNaiveBayes$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

See Also

Other Learner: mlr_learners_classif.cv_glmnet, mlr_learners_classif.glmnet, mlr_learners_classif.kknn, mlr_learners_classif.lda, mlr_learners_classif.log_reg, mlr_learners_classif.multinom, mlr_learners_classif.nnet, mlr_learners_classif.qda, mlr_learners_classif.ranger, mlr_learners_classif.svm, mlr_learners_classif.xgboost, mlr_learners_regr.cv_glmnet, mlr_learners_regr.glmnet, mlr_learners_regr.kknn, mlr_learners_regr.km, mlr_learners_regr.lm, mlr_learners_regr.nnet, mlr_learners_regr.ranger, mlr_learners_regr.svm, mlr_learners_regr.xgboost

Examples

Run this code
if (requireNamespace("e1071", quietly = TRUE)) {
# Define the Learner and set parameter values
learner = lrn("classif.naive_bayes")
print(learner)

# Define a Task
task = tsk("sonar")

# Create train and test set
ids = partition(task)

# Train the learner on the training ids
learner$train(task, row_ids = ids$train)

# print the model
print(learner$model)

# importance method
if("importance" %in% learner$properties) print(learner$importance)

# Make predictions for the test rows
predictions = learner$predict(task, row_ids = ids$test)

# Score the predictions
predictions$score()
}

Run the code above in your browser using DataLab