How can I find the different score and threshold of a treebagger for ROC plotting?
1 次查看(过去 30 天)
显示 更早的评论
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.
load ('Data.mat');
Allfeature = D(:,1:14);
Label = D(:,15);
% Half for training
Trainfeatures = Allfeature(1:544,:);
Trainlabels =Label(1:544,:);
% Half for testing
Testfeatures = Allfeature(545:end,:);
Testlabels = Label(545:end,:);
% tree bagger for classification
template = templateTree(...
'MaxNumSplits', 2000);
TreeBagger = fitcensemble(...
Trainfeatures, ...
Trainlabels, ...
'Method', 'Bag', ...
'NumLearningCycles',100, ...
'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');
% plotconfusion(ORFTestlabels,ORFlabels)
[c,cm,ind,per] = confusion(Testlabels',labels')
plot(X,Y,'--','LineWidth',1)
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Classification Ensembles 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!