FUNCTION REFERENCE

ClassificationKNN

k-nearest neighbor classification model returned by fitcknn.

k-nearest neighbor classification model returned by fitcknn.

Syntax

mdl = fitcknn(X, Y)

Stores training predictors, class labels, neighbor count, distance metric and standardization state. Evaluate with predict, resubLoss, loss and crossval.

Example

mdl = fitcknn([0 0; 1 1; 2 2], [1; 1; 2]); class(mdl)   % 'ClassificationKNN'

Differences from MATLAB: Numeric predictors only; exhaustive search without KD-tree indexing.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.