what is the 'NSMethod','exhaustive' k-nearest neighbor classifier

6 ビュー (過去 30 日間)
Kong
Kong 2020 年 4 月 11 日
コメント済み: Kong 2020 年 4 月 17 日
Hello.
I am using the k-nearest neighbor classifier as the below code.
Could you explain what 'NSMethod','exhaustive' are?
Is it related to distance metric learning? (It learns a metric that pulls the neighbor candidates near, while pushes near data from different classes out of the target neighbors margin.) I got a high accuracy than I expected.
clear all
close all
for i = 2:30:750
X = csvread('kth_optical_only.csv');
Y = csvread('kth_optical_only_class1.csv');
X = X(:,1:i);
Mdl = fitcknn(X,Y,'NumNeighbors',3,...
'NSMethod','exhaustive','Distance','cosine',...
'Standardize',1);
rng(1); % For reproducibility
CVKNNMdl = crossval(Mdl, 'KFold', 5);
classAccuracy(i) = 100 - kfoldLoss(CVKNNMdl, 'LossFun', 'ClassifError')*100;
end

採用された回答

Divya Gaddipati
Divya Gaddipati 2020 年 4 月 13 日
Hi,
NSMethod is the Nearest neighbor search method, specified as either 'kdtree' or 'exhaustive'.
  • 'kdtree' — Creates and uses a Kd-tree to find nearest neighbors.
  • 'exhaustive' — Uses the exhaustive search algorithm. When predicting the class of a new point xnew, the algorithm computes the distance values from all points in X to xnew to find nearest neighbors.
For information on exhaustive and kdtree based searching, you can refer to the following links:
Hope this helps!

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStatistics and Machine Learning Toolbox についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by