How to input scores to the predict function
2 次查看(过去 30 天)
显示 更早的评论
Code for calculating performance of classifier model is below. An error is received in the perfcurve function:
Error using perfcurve>preparedata (line 1244) You must pass scores as a vector of floating-point values.
Error in perfcurve (line 381) [scores,labels,weights,ncv] = preparedata(scores,labels,weights);
The output of checking the class of vector scores: whos scores Name Size Bytes Class Attributes
scores 4916x2 78656 double
length(scores)==length(labels)
Any ideas of what is causing the error?
% load classifier model
load baggedTrees3
% read predictor data in
readData3 = xlsread('featureMatrix3');
[n,m] = size(readData3);
predictorData3 = readData3(:,1:m-1); %
% calculate labels and scores
[labels,scores] = predict(baggedTrees3,predictorData3);
% calculate ROC and AUROC
posclass = true;
[X,Y,T,AUC] = perfcurve(labels,scores,posclass);
0 个评论
采纳的回答
Ilya
2015-6-3
The error message says "You must pass scores as a vector..." You are passing it as a matrix with two columns. How would perfcurve know which column represents scores for the positive class?
4 个评论
Ilya
2015-6-4
The doc page http://www.mathworks.com/help/stats/perfcurve.html has a few references at the bottom. The top two would have good introductory material.
In your case, you have two classes. Since class probabilities add up to one, you only need one of them.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 ROC - AUC 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!