Hello,
I have the problem that when I try use plotconfusion, this function doesn't work.
I have dataset with 15 classes and I try to predict the target value using knn-classification. I've divided datasets to training and test datasets (75:25 accordinaly). My dataset has 300 instances and 90 attributes.
The problem is that when I try to call this plotconfusion function I just see that this doesn't work (it somehow just go to a infinite cycle or something like this, the process doesn't terminate). Could you tell me what's the problem or do I use it wrong?
Here the part of my code: knn = ClassificationKNN.fit(XtrainNN,YtrainNN,'NumNeighbors',5); Y_knn = knn.predict(XtestNN); loss(knn, XtestNN, YtestNN) plotconfusion(Y_knn,YtestNN)

댓글 수: 3

Andrew Singh
Andrew Singh 2017년 9월 20일
I'm also having the same problem.
Baran Yildiz
Baran Yildiz 2017년 9월 26일
I am also having the same problem. Plot confusion doesn't seem to work even for the sample problem/dataset given in the reference link below:
https://au.mathworks.com/help/nnet/ref/plotconfusion.html#inputarg_targets
Tapan
Tapan 2023년 8월 11일
My error is please tell me how to solve
Error using plotconfusion>standard_args (line 255) Value is not a matrix or cell array.
Error in plotconfusion (line 111) update_args = standard_args(args{:});
Error in dltt (line 18) plotconfusion(testdata.Labels, Predicted);

댓글을 달려면 로그인하십시오.

답변 (3개)

Nathan DeJong
Nathan DeJong 2017년 9월 27일

6 개 추천

Try transposing the inputs so that they are row vectors rather than column vectors. It worked for me. Seems to be a strange bug in plotconfusion().

댓글 수: 1

Pedro Borges
Pedro Borges 2018년 10월 17일
transposing the inputs worked for me, too! thanks!

댓글을 달려면 로그인하십시오.

Hamid Salimi
Hamid Salimi 2021년 6월 9일

2 개 추천

I write it for anyone that may have the same problem, I solved it by converting my actual and predicted results to categorical data! your actual and predicted should be n * 1, and then use it:
plotconfusion(categorical(actual),categorical(predicted));
Ilya
Ilya 2013년 12월 17일

0 개 추천

I never used plotconfusion, but you can get what you want using functions confusionmat and imagesc. For example,
knn = ClassificationKNN.fit(XtrainNN,YtrainNN,'NumNeighbors',5);
Y_knn = knn.predict(XtestNN);
cm = confusionmat(YtestNN,Y_knn);
imagesc(cm);
colorbar;

카테고리

질문:

2013년 12월 17일

댓글:

2023년 8월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by