MATLAB: String Class for Confusion Matrix

MATLABmatrixmatrix arraymatrix manipulationStatistics and Machine Learning Toolbox

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) :

Best Answer

Okay, i got a solution. The solution is by using confMatPlot function from Matlab's File Exchange .
Related Question