how do i display zeros in confusion chart?
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Udit06
el 29 de Nov. de 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 comentarios
Ver también
Categorías
Más información sobre Red en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!