フィルターのクリア

How can KNN classify if there are more than 2 dimension

3 ビュー (過去 30 日間)
Selina Loh
Selina Loh 2017 年 12 月 17 日
コメント済み: Selina Loh 2017 年 12 月 17 日
Is it possible to use the similar example from Matlab to classify with 4 dimensions.
Or does this example only classify according to 2 dimensions? load fisheriris X = meas; Y = species; Mdl = fitcknn(X,Y,'NumNeighbors',4); %% % Predict the classification of an average flower. flwr = mean(X); % an average flower flwrClass = predict(Mdl,flwr)

採用された回答

Akira Agata
Akira Agata 2017 年 12 月 17 日
Yes, it is possible to use fintcknn to classify with 4 dimensional data. The following code (same as your example) can generate classification model using all 4 dimensions, and predict an average flower.
load fisheriris
X = meas;
Y = species;
Mdl = fitcknn(X,Y,'NumNeighbors',4);
flwr = mean(X);
flwrClass = predict(Mdl,flwr);
  3 件のコメント
Akira Agata
Akira Agata 2017 年 12 月 17 日
What do you mean by 'plot' for 4 dimensional data? If you want to find the nearest neighbor, the following can do that.
D = pdist2(flwr,X);
[~,idx] = min(D);
Then, idx was found to be 65. Thant means the nearest neighbor from flwr in dataset X is X(65,:) ('versicolor').
Selina Loh
Selina Loh 2017 年 12 月 17 日
Thank you :)

サインインしてコメントする。

その他の回答 (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