Products & Services Solutions Academia Support User Community Company

Learn more about Statistics Toolbox   

NaiveBayes class -

Naive Bayes classifier

Description

A NaiveBayes object defines a Naive Bayes classifier. A Naive Bayes classifier assigns a new observation to the most probable class, assuming the features are conditionally independent given the class value.

Construction

NaiveBayesCreate NaiveBayes object

Methods

dispDisplay NaiveBayes classifier object
displayDisplay NaiveBayes classifier object
fitCreate Naive Bayes classifier object by fitting training data
posteriorCompute posterior probability of each class for test data
predictPredict class label for test data
subsasgnSubscripted reference for NaiveBayes object
subsrefSubscripted reference for NaiveBayes object

Properties

CIsNonEmptyFlag for non-empty classes
CLevelsClass levels
CNamesClass names
CPriorClass priors
DistDistribution names
NClassesNumber of classes
NDimsNumber of dimensions
ParamsParameter estimates

Copy Semantics

Value. To learn how this affects your use of the class, see Comparing Handle and Value Classes in the MATLAB Object-Oriented Programming documentation.

Examples

Predict the class label using the Naive Bayes classifier

load fisheriris

Use the default Gaussian distribution and a confusion matrix:

O1 = NaiveBayes.fit(meas,species);
C1 = O1.predict(meas);
cMat1 = confusionmat(species,C1) 

This returns:

cMat1 =

    50     0     0
     0    47     3
     0     3    47

Use the Gaussian distribution for features 1 and 3 and use the kernel density estimation for features 2 and 4:

O2 = NaiveBayes.fit(meas,species,'dist',...
{'normal','kernel','normal','kernel'}); 
C2 = O2.predict(meas);
cMat2 = confusionmat(species,C2)

This returns:

cMat2 =

    50     0     0
     0    47     3
     0     3    47

References

[1] Mitchell, T. (1997) Machine Learning, McGraw Hill.

[2] Vangelis M., Ion A., and Geogios P. Spam Filtering with Naive Bayes - Which Naive Bayes? (2006) Third Conference on Email and Anti-Spam.

[3] George H. John and Pat Langley. Estimating continuous distributions in bayesian classifiers (1995) the Eleventh Conference on Uncertainty in Artificial Intelligence.

See Also

Naive Bayes Classification

Grouped Data

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS