Confusion matrix not showing the vlaues of all boxes

조회 수: 3 (최근 30일)
mohammed
mohammed 2023년 12월 13일
답변: Aastha 2024년 12월 3일
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;
--------------------------------------

답변 (1개)

Aastha
Aastha 2024년 12월 3일
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!

카테고리

Help CenterFile Exchange에서 Model Building and Assessment에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by