Work out input classifier variable threshold in ROC analysis using perfcurve

2 ビュー (過去 30 日間)
Thomas Turmezei
Thomas Turmezei 2023 年 4 月 18 日
回答済み: Shivansh 2023 年 8 月 29 日
I am trying to work out the threshold value(s) for an input classifier variable X (or combination of variables) in a leave-one-out prediction model for Y (binary) using fitcdiscr, crossval, kfoldPredict, and perfcurve. I understand that I can work out the optimum threshold in the output distribition by searching for the optimum ROC point, but I am struggling to understand how I can then translate that back to understand what the threshold value(s) is/are in my input X. Any help would be most appreciated.
Here's my code...
mdl_xval = fitcdiscr(X,Y); %input variable X (can be more than one col) and response Y
cvmodel = crossval(mdl_xval,'Leaveout','on');
[label,score,cost] = kfoldPredict(cvmodel);
[X,Y,T,AUC,OPTROCPT,suby,subnames] = perfcurve(ycell,score(:,2),'+','NBoot',500); %perfomance metrics
T_thresh = T((X==OPTROCPT(1))&(Y==OPTROCPT(2))); %threshold value in distribution

回答 (1 件)

Shivansh
Shivansh 2023 年 8 月 29 日
Hi Thomas,
You can translate the optimum ROC point to find the threshold using the following steps. This solution is with assumption that you have found the coordinates of optimum ROC point for your analysis.
1. Find the index of the optimum ROC point with respect to ‘X’ and ‘Y’ vectors. The following line of code will help with it.
Index = find(X==opt_roc_point(1) & Y==opt_roc_point(2));
2. Retrieve the corresponding value(s) from ‘X’. You can use the following line of codes depending upon the data type of X.
If X is a single column data, directly retrieve the value from the index.
threshold = X(Index)
If X is a multi-column data, you can use the following line of code.
threshold = X(Index,:)
The threshold variable will hold the input classifier variable threshold for the data.

カテゴリ

Help Center および File ExchangeDiscriminant Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by