Confusion Matrix with known True and Predicted Values
2 views (last 30 days)
Show older comments
Elizabeth Cardona
on 15 Feb 2021
Answered: Mahesh Taparia
on 22 Feb 2021
I did some machine learning with some datasets. I now have accuracies and numerical numbers of prdicted classes and true classes as shown below:
The different colors (blue, orange, grey, and yellow) show different datasets. The model is pretty accurate, but has some misclassifications. For example take a look at the first row. for the Model(blue), the dataset had 3,505 responsive cells (3392+113), 3392 were correctly identified as responsive but 113 were misclassfied as resistant, making 96.776% accuracy. I want to show either all of the Model(blue) in a confusion matrix with percentages and colors (green for correct, red for incorrect) in a confusion matrix. Or maybe even all the datasets in one matrix. But I'd like to start with one forst to see how it works.
I have tried plotconfusion(), confusionmat(), but I don't think I'm inputting the data correctly.
PLEASE HELP ME.
0 Comments
Accepted Answer
Mahesh Taparia
on 22 Feb 2021
Hi
You are already having the class-wise information about the number of correct and misclassified objects, you can use confusionchart function to visualize the confusion matrix. You can refer to this documentation for more information. In your case, a sample example is given below:
A=[3392 113 0 0;125 3397 0 0;0 0 3109 366;0 0 356 3142];
cm = confusionchart(A)
cm.RowSummary = 'row-normalized';
cm.ColumnSummary = 'column-normalized';
Hope it will help!
0 Comments
More Answers (0)
See Also
Categories
Find more on Colormaps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!