Matlab:perfcurve 分数必须是浮点值向量

Matlab: perfcurve scores must be a vector of floating values

以下代码引发错误:您必须将分数作为浮点值向量传递。

  [Yhat scores] = predict(svmModel, meas );
[X,Y,T,AUC] = perfcurve(Yhat ,scores,'1');

有人可以帮忙吗。

我无法提供深入的帮助,因为我不知道你到底想达到什么目的。顺便说一句,我发现你犯了一个根本性的错误,即使用单引号和数字“1”,因为它被识别为章程而不是数字。因此,它无法匹配数字数组 Yhat.

您不能对两列使用 scores,因为 perfcurve(_) 只接受单列的参数。

应用前面注释后的代码

% On full data
[Yhat, scores] = predict(svmModel, meas );
[X,Y,T,AUC] = perfcurve(Yhat ,abs(scores(:,2)),1);
plot(X,Y,'LineWidth',3)
xlabel('False positive rate')
ylabel('True positive rate')
title('ROC for Classification ')

以上代码可能无法解决您的问题,但可以指导您找出错误。