String Class for Confusion Matrix
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Angga Lisdiyanto
am 12 Mai 2016
Beantwortet: Angga Lisdiyanto
am 6 Jun. 2016
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) :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/164155/image.jpeg)
2 Kommentare
Tom Lane
am 19 Mai 2016
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?
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!