How can I find the different score and threshold of a treebagger for ROC plotting?
4 views (last 30 days)
Show older comments
I am trying to plot a ROC to know the preformance of tree bagger. I use the attached dataset and the following code to perform the classifiaction. As my problem is a binary classification, I have two columns of score values from treebagger. My class of interest is '1' and I want to calculate the thresholds. My ROC curve is something wrong. Please kindly help me to solve it. Thank you.
Allfeature = D(:,1:14);
Label = D(:,15);
% Half for training
Trainfeatures = Allfeature(1:544,:);
% Half for testing
Testfeatures = Allfeature(545:end,:);
Testlabels = Label(545:end,:);
% tree bagger for classification
template = templateTree(...
TreeBagger = fitcensemble(...
'Method', 'Bag', ...
'Learners', template,'ClassNames', [1; 0]);
[labels,score] = predict(TreeBagger,Testfeatures);
diffscore = score(:,1) - max(score(:,2));
[X,Y,T,~,OPTROCPT,suby,subnames] = perfcurve(Testlabels,diffscore,'1');
[c,cm,ind,per] = confusion(Testlabels',labels')
Find more on Classification Ensembles in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!