how to get confusion matrix data from patternet function with cross validation?

2 views (last 30 days)
ammu v
ammu v on 28 Jun 2021
Edited: ammu v on 28 Jun 2021
is the following program correct? I am trying to do 10 cross validation ...
feat = sig_feat(:,1:9);
% features
labels = sig_feat(:,10)
%labels
fold = cvpartition(labels,'kfold',10);
r=1;
net = patternnet(6);
while r<=10
trainIdx=fold.training(r); testIdx=fold.test(r);
xtrain=feat(trainIdx,:); ytrain=labels(trainIdx);
xtest = feat(testIdx,:); ytest = labels(testIdx);
train_data=[ytrain xtrain];
test_data = [ytest xtest];
net = train(net,xtrain',ytrain');
%view(net)
y_pred = net(xtest');
perf = perform(net,ytest,y_pred');
%%
[c,cm,ind,per] = confusion(ytest',y_pred);
confmat{r}=cm;
r=r+1;
end

Answers (0)

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by