how do i display zeros in confusion chart?
12 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
In confusion chart the cells correspond to zero values are getting blank which is normal for matlab...but i need to show these zero values...is there any way?

0 Commenti
Risposte (1)
Udit06
il 29 Nov 2024
Hi Arnab,
To display zeros instead of blank spaces, you can create a confusion matrix and display it using a heatmap while ensuring that all values, including zeros, are visible. You can find the code for the same below:
numSamples = 100;
numClasses = 5;
% Generate random true labels and predicted labels
trueLabels = randi([1, numClasses], numSamples, 1);
predictedLabels = trueLabels; % assigning predictLabels as trueLabels so that the confusion matrix contain some zeros
% Compute the confusion matrix
confMat = confusionmat(trueLabels, predictedLabels);
% Create a heatmap for the confusion matrix
h = heatmap(confMat, 'ColorbarVisible', 'off');
h.Colormap = [1 1 1]; % White
h.CellLabelColor = 'black'; % Ensure labels are visible
h.CellLabelFormat = '%d'; % Display as integers
% Add titles and labels for clarity
h.Title = 'Confusion Matrix';
h.XLabel = 'Predicted Class';
h.YLabel = 'True Class';
h.XDisplayLabels = string(1:numClasses);
h.YDisplayLabels = string(1:numClasses);
You can refer to the following MathWorks documentation to understand more about the heatmap function:
I hope this helps.
0 Commenti
Vedere anche
Categorie
Scopri di più su Deep Learning Toolbox in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!