【问题标题】:Plotting ROC curve in cross validation using Matlab perfcurve使用 Matlab perfcurve 在交叉验证中绘制 ROC 曲线
【发布时间】:2019-08-15 01:40:09
【问题描述】:

我有以下代码,用于使用 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】:

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

    【讨论】:

      猜你喜欢
      • 2021-05-08
      • 2021-01-30
      • 2018-01-15
      • 2020-01-02
      • 2019-03-04
      • 2012-09-11
      • 2019-01-25
      • 2014-07-04
      • 2016-12-26
      相关资源
      最近更新 更多