How to use "for loop" to compute the accuracy and plot graph

2 ビュー (過去 30 日間)
Kong
Kong 2020 年 4 月 5 日
編集済み: Kong 2020 年 4 月 6 日
Hello.
I want to calculate the accuracy of each dimension' X(:,n), n = 1 ~ 1150
The shape of the data is 90x1150. I want to get the accuracy of each dimension
(etc. (90X2), (90x3), (90x10) (90x100),,,,,,,,,,,,,,,,,,,,,,,,,,(90x1150))
and plot the graph of accuracy.
How can I fix this code?
% the shape of data is 90x1150
data = cell2mat(c')';
lable = [1:10 1:10 1:10 1:10 1:10 1:10 1:10 1:10 1:10]';
% I want to compute the accuracy of each X(:,N) using for loop.
% n = size(data,2)
% i = 1:n
% How to fix this code?
CMdl = fitcknn(data,lable,'NSMethod','exhaustive','Distance','cosine');
CMdl.NumNeighbors = 1;
rng(1); % For reproducibility
CVMdl = crossval(CMdl,'KFold',5);
accuracy = 100 - kfoldLoss(CVMdl)*100
% I want to plot the accuracy.
% x-axis: dimension, y-axis : accuracy.

回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by