Documentation

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 cpre are NaN (if obj.clevels is numeric or logical), empty strings (if obj.clevels is char or cell array of strings) 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?