Change class labels of a confusion matrix that has been exported from Classification Learner
22 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
I have exported a confusion matrix from the classification learner app (using the Export plot to figure function), which is where it was generated. How can I change the class labels from numeric to string as the option seems to be greyed out in the figure properties (ClassLabels).
Thank you!
0 Kommentare
Akzeptierte Antwort
Drew
am 12 Apr. 2024
In R2023a, one approach is to access the original confusion matrix info, and then create a new confusion chart with different labels. Using the fisheriris dataset, assume we created this confusion matrix in Classification Learner:
Next, export the confusion matrix out of Classification Learner using "Export Plot to Figure", and get access to the ConfusionMatrixChart object and the underlying data. Be sure to run "gca" right after the "Export Plot to Figure" operation, so that the ConfusionMatrixChart is the current figure.
>> ax = gca;
>> ax
ax =
ConfusionMatrixChart (Model 1 (Fine Tree)) with properties:
NormalizedValues: [3×3 double]
ClassLabels: {'setosa' 'versicolor' 'virginica'}
% Normalization is set to "absolute", so the values are the counts
>> ax.NormalizedValues
ans =
50 0 0
0 47 3
0 2 48
% Access the original confusion matrix counts and class labels
>> ConfusionMatrixCounts = ax.NormalizedValues;
>> OriginalClassLabels = ax.ClassLabels;
Define new class labels, and make a new confusionchart with the desired labels.
>> NewClassLabels = {'flower1' 'flower2' 'flower3'};
>> figure(2);
>> confusionchart(ConfusionMatrixCounts,NewClassLabels)
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!