Classification Multinomial Naive Bayes Learner From Weka
mlr_learners_classif.naive_bayes_multinomial.Rd
Multinomial Naive Bayes classifier.
Calls RWeka::make_Weka_classifier()
from RWeka.
Custom mlr3 parameters
output_debug_info
:original id: output-debug-info
do_not_check_capabilities
:original id: do-not-check-capabilities
num_decimal_places
:original id: num-decimal-places
batch_size
:original id: batch-size
Parameters
Id | Type | Default | Levels | Range |
subset | untyped | - | - | |
na.action | untyped | - | - | |
output_debug_info | logical | FALSE | TRUE, FALSE | - |
do_not_check_capabilities | logical | FALSE | TRUE, FALSE | - |
num_decimal_places | integer | 2 | \([1, \infty)\) | |
batch_size | integer | 100 | \([1, \infty)\) | |
options | untyped | NULL | - |
References
Mccallum A, Nigam K (1998). “A Comparison of Event Models for Naive Bayes Text Classification.” In AAAI-98 Workshop on 'Learning for Text Categorization'.
See also
as.data.table(mlr_learners)
for a table of available Learners in the running session (depending on the loaded packages).Chapter in the mlr3book: https://mlr3book.mlr-org.com/basics.html#learners
mlr3learners for a selection of recommended learners.
mlr3cluster for unsupervised clustering learners.
mlr3pipelines to combine learners with pre- and postprocessing steps.
mlr3tuning for tuning of hyperparameters, mlr3tuningspaces for established default tuning spaces.
Super classes
mlr3::Learner
-> mlr3::LearnerClassif
-> LearnerClassifNaiveBayesMultinomial
Examples
# Define the Learner
learner = mlr3::lrn("classif.naive_bayes_multinomial")
print(learner)
#> <LearnerClassifNaiveBayesMultinomial:classif.naive_bayes_multinomial>: Multinomial Naive Bayes
#> * Model: -
#> * Parameters: list()
#> * Packages: mlr3, RWeka
#> * Predict Types: [response], prob
#> * Feature Types: integer, numeric
#> * Properties: multiclass, twoclass
# Define a Task
task = mlr3::tsk("sonar")
# Create train and test set
ids = mlr3::partition(task)
# Train the learner on the training ids
learner$train(task, row_ids = ids$train)
print(learner$model)
#> The independent probability of a class
#> --------------------------------------
#> M 0.52
#> R 0.48
#>
#> The probability of a word given the class
#> -----------------------------------------
#> M R
#> V1 0 0
#> V10 0.01 0.01
#> V11 0.02 0.01
#> V12 0.02 0.01
#> V13 0.02 0.01
#> V14 0.02 0.02
#> V15 0.02 0.02
#> V16 0.02 0.02
#> V17 0.02 0.03
#> V18 0.03 0.03
#> V19 0.03 0.03
#> V2 0 0
#> V20 0.03 0.03
#> V21 0.04 0.03
#> V22 0.04 0.03
#> V23 0.04 0.04
#> V24 0.04 0.04
#> V25 0.04 0.04
#> V26 0.04 0.04
#> V27 0.04 0.04
#> V28 0.04 0.04
#> V29 0.04 0.04
#> V3 0 0
#> V30 0.03 0.03
#> V31 0.03 0.03
#> V32 0.02 0.03
#> V33 0.02 0.03
#> V34 0.02 0.03
#> V35 0.02 0.03
#> V36 0.02 0.03
#> V37 0.02 0.03
#> V38 0.02 0.02
#> V39 0.02 0.02
#> V4 0 0
#> V40 0.02 0.02
#> V41 0.02 0.02
#> V42 0.02 0.02
#> V43 0.02 0.01
#> V44 0.01 0.01
#> V45 0.01 0.01
#> V46 0.01 0.01
#> V47 0.01 0.01
#> V48 0.01 0
#> V49 0 0
#> V5 0.01 0
#> V50 0 0
#> V51 0 0
#> V52 0 0
#> V53 0 0
#> V54 0 0
#> V55 0 0
#> V56 0 0
#> V57 0 0
#> V58 0 0
#> V59 0 0
#> V6 0.01 0.01
#> V60 0 0
#> V7 0.01 0.01
#> V8 0.01 0.01
#> V9 0.01 0.01
#>
# Make predictions for the test rows
predictions = learner$predict(task, row_ids = ids$test)
# Score the predictions
predictions$score()
#> classif.ce
#> 0.2898551