Main Content

Naive Bayes

Naive Bayes model with Gaussian, multinomial, or kernel predictors

Naive Bayes models assume that observations have some multivariate distribution given class membership, but the predictor or features composing the observation are independent. This framework can accommodate a complete feature set such that an observation is a set of multinomial counts.

To train a naive Bayes model, use fitcnb in the command-line interface. After training, predict labels or estimate posterior probabilities by passing the model and predictor data to predict.

Apps

Classification LearnerTrain models to classify data using supervised machine learning

Blocks

ClassificationNaiveBayes PredictClassify observations using naive Bayes model (Since R2023b)

Functions

expand all

fitcnbTrain multiclass naive Bayes model
compactReduce size of machine learning model
limeLocal interpretable model-agnostic explanations (LIME) (Since R2020b)
partialDependenceCompute partial dependence (Since R2020b)
permutationImportancePredictor importance by permutation (Since R2024a)
plotPartialDependenceCreate partial dependence plot (PDP) and individual conditional expectation (ICE) plots
shapleyShapley values (Since R2021a)
crossvalCross-validate machine learning model
kfoldEdgeClassification edge for cross-validated classification model
kfoldLossClassification loss for cross-validated classification model
kfoldfunCross-validate function for classification
kfoldMarginClassification margins for cross-validated classification model
kfoldPredictClassify observations in cross-validated classification model
lossClassification loss for naive Bayes classifier
resubLossResubstitution classification loss
logpLog unconditional probability density for naive Bayes classifier
compareHoldoutCompare accuracies of two classification models using new data
edgeClassification edge for naive Bayes classifier
marginClassification margins for naive Bayes classifier
resubEdgeResubstitution classification edge
resubMarginResubstitution classification margin
testckfoldCompare accuracies of two classification models by repeated cross-validation
predictClassify observations using naive Bayes classifier
resubPredictClassify training data using trained classifier
incrementalLearnerConvert naive Bayes classification model to incremental learner (Since R2021a)

Objects

ClassificationPartitionedModelCross-validated classification model

Classes

ClassificationNaiveBayesNaive Bayes classification for multiclass classification
CompactClassificationNaiveBayesCompact naive Bayes classifier for multiclass classification

Topics