How to export performance measures from the Classificaiton Learner App?

조회 수: 6 (최근 30일)
Elena Ranguelova
Elena Ranguelova 2017년 1월 25일
댓글: Drew 2023년 8월 8일
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
Rama Malladi
Rama Malladi 2021년 7월 1일
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 2023년 7월 25일
Hello,
Has there been any update on how to export the TPP, FNR, ROC values using code?
Thanks!

댓글을 달려면 로그인하십시오.

답변 (1개)

Drew
Drew 2023년 7월 26일
편집: Drew 2023년 7월 26일
(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
Rama Malladi
Rama Malladi 2023년 8월 2일
Thank you for poting the code to do this, very helpful.
Drew
Drew 2023년 8월 8일
Thanks for your comment. Given that you found this answer helpful, I recommend to "Accept" the answer.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by