要训练 k 最近邻模型，可以使用分类学习器。为了获得更大的灵活性，可以在命令行界面中使用
fitcknn 训练 k 最近邻模型。训练模型后，可将模型和预测变量数据传递给
|Cross-validate machine learning model|
|Classification edge for cross-validated classification model|
|Classification loss for cross-validated classification model|
|Cross-validate function for classification|
|Classification margins for cross-validated classification model|
|Classify observations in cross-validated classification model|
|Loss of k-nearest neighbor classifier|
|Resubstitution classification loss|
|Compare accuracies of two classification models using new data|
|Edge of k-nearest neighbor classifier|
|Margin of k-nearest neighbor classifier|
|Resubstitution classification edge|
|Resubstitution classification margin|
|Compare accuracies of two classification models by repeated cross-validation|
Create and compare nearest neighbor classifiers, and export trained models to make predictions for new data.
This example shows how to visualize the decision surface for different classification algorithms.
Understand the steps for supervised learning and the characteristics of nonparametric classification and regression functions.
Categorize data points based on their distance to points in a training data set, using a variety of distance metrics.
Speaker Identification Using Pitch and MFCC (Audio Toolbox)