How to export performance measures from the Classificaiton Learner App?
4 次查看(过去 30 天)
显示 更早的评论
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
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
2023-7-25
Hello,
Has there been any update on how to export the TPP, FNR, ROC values using code?
Thanks!
回答(1 个)
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 个评论
Drew
2023-8-8
Thanks for your comment. Given that you found this answer helpful, I recommend to "Accept" the answer.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Classification Learner App 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!