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

1 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Line Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by