Skip to contents

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

Dictionary

This Learner can be instantiated via lrn():

lrn("classif.naive_bayes_multinomial")

Meta Information

  • Task type: “classif”

  • Predict Types: “response”, “prob”

  • Feature Types: “integer”, “numeric”

  • Required Packages: mlr3, RWeka

Parameters

IdTypeDefaultLevelsRange
subsetuntyped--
na.actionuntyped--
output_debug_infologicalFALSETRUE, FALSE-
do_not_check_capabilitieslogicalFALSETRUE, FALSE-
num_decimal_placesinteger2\([1, \infty)\)
batch_sizeinteger100\([1, \infty)\)
optionsuntypedNULL-

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

Author

damirpolat

Super classes

mlr3::Learner -> mlr3::LearnerClassif -> LearnerClassifNaiveBayesMultinomial

Methods

Inherited methods


Method new()

Creates a new instance of this R6 class.


Method clone()

The objects of this class are cloneable with this method.

Usage

LearnerClassifNaiveBayesMultinomial$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

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.53
#> R	0.47
#> 
#> 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.02	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.04	
#> 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.01	
#> 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