help with error in my code
古いコメントを表示
Hi can someone help me understand the mistake in my code, i followed the correct syntax from https://uk.mathworks.com/help/bioinfo/ref/classperf.html
i keep getting the error
operator "==" not supported for operands of type "cvpartition"
error in line 24
test = (indices == 1)
k = 4;
n = 699; %sample lenght
rng ('default')
indices = cvpartition(n,'kfold', k);
for i = 1:k
test= (indices == i); train = ~test;
class = classify(InputVariable(test,:),InputVariable(train,:),OutputVariable(train,:));
classperf(cp,class,test);
end
cp.ErrorRate
plotconfusion(testTarget, testY)
4 件のコメント
Walter Roberson
2021 年 1 月 1 日
If you are concerned about other people copying your code, or copying the answer that is given in response... then hire a private consultant.
Many of the people who volunteer here do so on the understanding that the answers are available to everyone. I did not research and spend the time writing up my response to help you personally, I did so in order that anyone else who also had a similar question would also be able to see the answer.
Rik
2021 年 1 月 1 日
Original question by Dilpreet kaur retrieved from Google Cache:
help with error in my code
Hi can someone help me understand the mistake in my code, i followed the correct syntax from https://uk.mathworks.com/help/bioinfo/ref/classperf.html
i keep getting the error
operator "==" not supported for operands of type "cvpartition"
error in line 24
test = (indices == 1)
k = 4;
n = 699; %sample lenght
rng ('default')
indices = cvpartition(n,'kfold', k);
for i = 1:k
test= (indices == i); train = ~test;
class = classify(InputVariable(test,:),InputVariable(train,:),OutputVariable(train,:));
classperf(cp,class,test);
end
cp.ErrorRate
plotconfusion(testTarget, testY)
Rena Berman
2021 年 5 月 6 日
(Answers Dev) Restored edit
採用された回答
その他の回答 (1 件)
Walter Roberson
2021 年 1 月 1 日
編集済み: Walter Roberson
2021 年 1 月 2 日
cvpartition does not return indices.
rng ('default')
nfold = 4;
cvfolds = cvpartition(699,'kfold', nfold);
cp = classperf(OutputVariable); % initializes the CP object
for i = 1:nfold
test = cvfolds.test(i);
train = cvfolds.training(i);
class = classify(InputVariable(test,:), InputVariable(train,:), OutputVariable(train,:));
classperf(cp, class, test);
end
cp.ErrorRate
カテゴリ
ヘルプ センター および File Exchange で Model Building and Assessment についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!