How to export performance measures from the Classificaiton Learner App?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
The Classification Learner App provides nice results in the form of Confusion matricies, ROC curves etc in the App's GUI.
But how can all these values (e.g. accuracy, number of observations, TPP, FNR, PPV and FDR for all classes) be exported easily out of the App?
Thanks in advance!
5 Kommentare
Rama Malladi
am 1 Jul. 2021
I have been waiting for this feature (to export FDR, PPV numbers by code), so that I can run Matlab code and get the PPV/FDR instead of looking at a graph and manually note down PPV/FDR.
Does MATLAB have a code to export PPV/FDR numbers?
Impala
am 25 Jul. 2023
Hello,
Has there been any update on how to export the TPP, FNR, ROC values using code?
Thanks!
Antworten (1)
Drew
am 26 Jul. 2023
Bearbeitet: Drew
am 26 Jul. 2023
(1) Starting in 2022b, you can export results from Classification Learner using the Results Table. This will provide accuracy, model type, etc, etc. For more info, see the answer at https://www.mathworks.com/matlabcentral/answers/409889-saving-classification-learner-results
(2) To export confusion matrices from Classification Learner, you can use the "Export Plot to Figure" option. Next, at the command line, with the current figure showing the confusion matrix exported from Classification Learner, use "cm=gca;" to get a variable "cm" representing the ConfusionMatrixChart object. From the ConfusionMatrixChart object, the metrics of interest (TPR, FNR, PPV, FDR) for the primary matrix can be accessed from the NormalizedValues property. Alternately, to reproduce Classification Learner confusion matrix plots at the command line, use confusionchart (introduced in 18b). Set the Normalization, RowSummary, and ColumnSummary properties to get the metrics of interest. An example is illustrated below.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1443017/image.png)
% Export the above plot to figure, then
% use gca to get a handle to the ConfusionMatrixChart
>> cm=gca;
% Then access the Normalized values
>> cm.NormalizedValues
ans =
0.9266 0.0734
0.0814 0.9186
% Those are row-normalized values, since TPR/FNR option was
% selected in classification learner
>> cm.Normalization
ans =
'row-normalized'
% If you want a different normalization, just update the relevant
% properties, and the figure will update.
% Using cm.Normalization='absolute'; will give the raw numbers in the primary matrix,
>> cm.Normalization='absolute';
>> cm.NormalizedValues
ans =
101 8
7 79
% The row and column summaries can be adjusted with their corresponding properties
% Their current settings in this case are
>> cm.RowSummary
ans =
'row-normalized'
>> cm.ColumnSummary
ans =
'off'
% See doc for confusionchart for all the options.
% https://www.mathworks.com/help/stats/confusionchart.html
(3) To reproduce ROC curves at the command line, use rocmetrics (introduced in 22a). Metrics of interest can be obtained from the methods and properties of the rocmetrics object. For earlier releases, perfcurve (introduced in 2009a) can be used.
2 Kommentare
Drew
am 8 Aug. 2023
Thanks for your comment. Given that you found this answer helpful, I recommend to "Accept" the answer.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!