Documentation

Nearest Neighbors

Find nearest neighbors for classification

To train a k-nearest neighbors model, use the Classification Learner App. Alternatively, train a k-nearest neighbors model using fitcknn. After training a k-nearest neighbors model, predict labels or estimate posterior probabilities by passing the model and predictor data to predict.

Apps

Classification Learner Train models to classify data using supervised machine learning

Functions

fitcknn Fit k-nearest neighbor classifier
predict k-nearest neighbor classification
templateKNN k-nearest neighbor classifier template
loss k-nearest neighbor classification
crossval k-nearest neighbor classification
pdist Pairwise distance between pairs of objects
pdist2 Pairwise distance between two sets of observations
ExhaustiveSearcher Prepare exhaustive nearest neighbors searcher
KDTreeSearcher Grow Kd-tree
createns Create object to use in k-nearest neighbors search

Classes

ClassificationKNN k-nearest neighbor classification
ClassificationPartitionedModel Cross-validated classification model

Was this topic helpful?