how do i display zeros in confusion chart?
12 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Udit06
2024 年 11 月 29 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Red についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!