Borrar filtros
Borrar filtros

How to export performance measures from the Classificaiton Learner App?

1 visualización (últimos 30 días)
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 comentarios
Rama Malladi
Rama Malladi el 1 de Jul. de 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
Impala el 25 de Jul. de 2023
Hello,
Has there been any update on how to export the TPP, FNR, ROC values using code?
Thanks!

Iniciar sesión para comentar.

Respuestas (1)

Drew
Drew el 26 de Jul. de 2023
Editada: Drew el 26 de Jul. de 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 comentarios
Rama Malladi
Rama Malladi el 2 de Ag. de 2023
Thank you for poting the code to do this, very helpful.
Drew
Drew el 8 de Ag. de 2023
Thanks for your comment. Given that you found this answer helpful, I recommend to "Accept" the answer.

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by