Products & Services Solutions Academia Support User Community Company

Learn more about Statistics Toolbox   

predict - Class: NaiveBayes

Predict class label for test data

Syntax

cpre = predict(nb,test)
cpre = predict(...,'HandleMissing',val)

Description

cpre = predict(nb,test) classifies each row of data in test into one of the classes according to the NaiveBayes classifier nb, and returns the predicted class level cpre. test is an N-by-nb.ndims matrix, where N is the number of observations in the test data. Rows of test correspond to points, columns of test correspond to features. cpre is an N-by-1 vector of the same type as nb.CLevels, and it indicates the class to which each row of test has been assigned.

cpre = predict(...,'HandleMissing',val) specifies how predict treats NaN (missing values). val can be one of the following:

'off' (default) Observations with NaN in any of the columns are not classified into any class. The corresponding rows in post and logp are NaN. The corresponding rows in cpre are NaN (if obj.clevels is numeric or logical), empty strings (if obj.clevels is char or cell array of strings) or (if obj.clevels is categorical).
'on'For observations having NaN in some (but not all) columns, post and predict computes cpre using the columns with non-NaN values. Corresponding logp values are NaN.

See Also

NaiveBayes, fit, posterior

  


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