Main Content

最近邻

k 最近邻分类

要训练 k 最近邻模型,可以使用分类学习器。为了获得更大的灵活性,可以在命令行界面中使用 fitcknn 训练 k 最近邻模型。训练模型后,可将模型和预测变量数据传递给 predict,以预测标签或估计后验概率。

App

分类学习器使用有监督的机器学习训练模型以对数据进行分类

模块

ClassificationKNN PredictClassify observations using nearest neighbor classification model (自 R2022b 起)

函数

全部展开

fitcknnFit k-nearest neighbor classifier
ExhaustiveSearcherCreate exhaustive nearest neighbor searcher
KDTreeSearcherCreate Kd-tree nearest neighbor searcher
hnswSearcherHierarchical Navigable Small Worlds (HNSW) approximate nearest neighbor search (自 R2024a 起)
creatensCreate nearest neighbor searcher object
limeLocal interpretable model-agnostic explanations (LIME) (自 R2020b 起)
partialDependenceCompute partial dependence (自 R2020b 起)
permutationImportancePredictor importance by permutation (自 R2024a 起)
plotPartialDependenceCreate partial dependence plot (PDP) and individual conditional expectation (ICE) plots
shapleyShapley values (自 R2021a 起)
crossvalCross-validate machine learning model
kfoldEdgeClassification edge for cross-validated classification model
kfoldLossClassification loss for cross-validated classification model
kfoldfunCross-validate function for classification
kfoldMarginClassification margins for cross-validated classification model
kfoldPredictClassify observations in cross-validated classification model
lossLoss of k-nearest neighbor classifier
resubLossResubstitution classification loss
compareHoldoutCompare accuracies of two classification models using new data
edgeEdge of k-nearest neighbor classifier
marginMargin of k-nearest neighbor classifier
resubEdgeResubstitution classification edge
resubMarginResubstitution classification margin
testckfoldCompare accuracies of two classification models by repeated cross-validation
predictPredict labels using k-nearest neighbor classification model
resubPredictClassify training data using trained classifier
gatherGather properties of Statistics and Machine Learning Toolbox object from GPU (自 R2020b 起)
pdist成对观测值之间的两两距离
pdist2两组观测值之间的两两距离

对象

全部展开

ClassificationKNNk-nearest neighbor classification
ClassificationPartitionedModelCross-validated classification model

主题

相关信息