FUNCTION REFERENCE
ClassificationKNN.predict
Predict class labels and scores from a ClassificationKNN model.
Predict class labels and scores from a ClassificationKNN model.
Syntax
[label, score] = predict(mdl, Xnew)Finds the k nearest training neighbors for each row of Xnew and returns predicted labels and posterior scores.
Example
mdl = fitcknn([0; 1; 5; 6], [1; 1; 2; 2]); predict(mdl, 0.5) % 1Differences from MATLAB: Numeric predictors only; call as predict(mdl, Xnew).
These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.