MATLAB Answers

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

3 views (last 30 days)
Kong
Kong on 5 Apr 2020
Edited: Kong on 6 Apr 2020
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 Comments

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!