필터 지우기
필터 지우기

String Class for Confusion Matrix

조회 수: 2 (최근 30일)
Angga Lisdiyanto
Angga Lisdiyanto 2016년 5월 12일
답변: Angga Lisdiyanto 2016년 6월 6일
Hi, my code is like below :
predictors = [apple apple watermelon watermelon orange orange];
validationPredictions = [apple apple apple apple orange apple];
confuseMatrix = confusionmat(predictors, validationPredictions);
Where :
  • predictors = Class names (string data type) of data training.
  • validationPredictions = Class names (string data type) as a result of classification.
What i know is, confusionmat need for integer value type for both of True Class and Predict Class.
I got error for running my code above, it seems the data must a integer but my classes is string. How to solve this?
If possible, i need a Confusion Matrix like this (taken from Classification Learner App Toolbox) :
  댓글 수: 2
Tom Lane
Tom Lane 2016년 5월 19일
If I run this right before your code:
apple = {'apple'}; watermelon = {'watermelon'}; orange = {'orange'};
then I get a matrix result with no error. How did you define these variables? What release of MATLAB are you using?
Angga Lisdiyanto
Angga Lisdiyanto 2016년 5월 21일
편집: Angga Lisdiyanto 2016년 5월 21일
My variable is a matrix, not a cell. Now is ok with cell type, thanks.
I am using Matlab R2015b.
But how to give a string label?
It is very confusing if we read CM without X or Y tick class/variables.

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

채택된 답변

Angga Lisdiyanto
Angga Lisdiyanto 2016년 6월 6일
Okay, i got a solution. The solution is by using confMatPlot function from Matlab's File Exchange .

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by