This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.


Class: NaiveBayes

Predict class label for test data


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


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 cpre are NaN (if obj.clevels is numeric or logical), empty character vectors (if obj.clevels is a character array or cell array of character vectors) or <undefined> (if obj.clevels is categorical).
'on'For observations having NaN in some (but not all) columns, predict computes cpre using the columns with non-NaN values. Corresponding cpre values are NaN.

Was this topic helpful?