How to export performance measures from the Classificaiton Learner App?

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

If you are looking for exporting classifier and its training data, you can do that using the 'Export Model' option. However, the ability to export plots and figures is not available in the Classification Learner App as of MATLAB R2016b.
Thanks for the answer, but I know how to export the classifier and I don't want to export the plots and figures, but the numbers they represent. It's really pity (almost unbelievable), that one can look at plots, but can't export the numbers calculated (anyway to generate these plots!) begind these plots! Very sloppy for a MATLAB product!
Have the same issue Matlab 2018b
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?
Hello,
Has there been any update on how to export the TPP, FNR, ROC values using code?
Thanks!

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Drew
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.
% 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

Thank you for poting the code to do this, very helpful.
Thanks for your comment. Given that you found this answer helpful, I recommend to "Accept" the answer.

Melden Sie sich an, um zu kommentieren.

Gefragt:

am 25 Jan. 2017

Kommentiert:

am 8 Aug. 2023

Community Treasure Hunt

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

Start Hunting!

Translated by