Confusion matrix not showing the vlaues of all boxes

5 views (last 30 days)
i have digital modualtion indetification using ANN project, including three files mainfunction.m , generateModulatedSignals.m, generateModulation.m and cycle_rot.
The confusion matrix not showing values for all boxes.some of boxes are empty. could some one help me to solve this issue.
the following is the code for confusion matrix in mainfunction.m file (which include dataset as will).
-----------------
% Visualize Confusion Matrix
figure;
% Convert predicted labels to class names
classNames = {'2ASK', '4ASK', '2PSK', '4PSK'};
predictedClassNames = classNames(vec2ind(predictedLabels));
Unrecognized function or variable 'predictedLabels'.
% Convert true labels to class names
trueClassNames = classNames(testModulationLabels);
% Create a confusion matrix chart
confusionchart(trueClassNames, predictedClassNames, 'RowSummary','row-normalized', 'ColumnSummary', 'column-normalized');
title('Confusion Matrix');
% Visualize Predicted Labels vs. True Labels
figure;
subplot(2,1,1);
stem(testModulationLabels, 'DisplayName', 'True Labels', 'LineWidth', 1.5);
hold on;
stem(vec2ind(predictedLabels), 'DisplayName', 'Predicted Labels', 'LineWidth', 1.5);
hold off;
title('True Labels vs. Predicted Labels');
xlabel('Sample Index');
ylabel('Modulation Type');
legend('True Labels', 'Predicted Labels');
grid on;
--------------------------------------

Answers (1)

Aastha
Aastha on 3 Dec 2024 at 6:25
I tried reproducing the issue using dummy data for the true and predicted labels. I can confirm that some boxes are indeed empty. This is the expected behaviour for the "confusionchart" function, as it does not display any values in cells where the confusion matrix is equal to zero.
This image below shows that some boxes where the values are zero are not displayed.
Refer to the following MathWorks documentation link for more information on "confusionchart" function:
Hope this helps!

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!