使用Matlab perfcurve在交叉验证中绘制ROC曲线

问题描述 投票:0回答:1

我有以下代码用于使用SVM进行二进制分类,以及10个交叉验证,

更新:找到解决方案,请参阅下面的说明

k=10;
cp = classperf(lables); 
cvFolds = crossvalind('Kfold', lables, k);   
 for i = 1:k                                 
  testIdx = (cvFolds == i);                %# get indices of test instances
  trainIdx = ~testIdx;                     %# get indices training instances


   svmModel = fitcsvm(data_features(trainIdx,:), lables(trainIdx), 
   'Standardize',true,'KernelFunction','RBF','KernelScale','auto');

  [label,score] = predict(svmModel, data_features(testIdx,:));
  cp = classperf(cp, pred, testIdx);
  cumulative_score= [cumulative_score; score];
  label1 = [label1; label];

end
acc= cp.CorrectRate;
conf= cp.CountingMatrix;

我想在Matlab中使用perfcurve函数绘制ROC曲线,但是,输入“得分”会改变每个折叠,并且不能在k折叠循环之外使用。

[X,Y] = perfcurve(labels,scores,posclass)

关于如何在这种情况下策划ROC的任何建议?注意:上面的[已解决]在循环中添加cumulative_score= [cumulative_score; score];,并将其用作perfcurve的输入

matlab plot classification cross-validation roc
1个回答
0
投票

通过在循环中添加cumulative_score= [cumulative_score; score];,并将其用作perfcurve的输入

© www.soinside.com 2019 - 2024. All rights reserved.