You forgot to post the error. You just snipped out a very small portion of it. Please post the ENTIRE error. ALL the red text , with line numbers, code statements, everything. Also, below in the Products section please list what toolboxes you used, for example what toolbox perfcurve and confusionmat are in. I don't think I have those so I won't be able to help you.
How to find the ROC curve?
2 次查看(过去 30 天)
显示 更早的评论
*Hello ,
I want to find the ROC curve in MATLAB. I have used a linear classification first using classify command and then I need to plot the ROC.*
I used this code:*
%%%%
clc close all
clear all
%% MY FEATURES
features = xlsread('ExtractedFeatures.xls');
numFeatures = 418;
%% Define ground truth
groundTruthGroup = cell(numFeatures,1); groundTruthGroup(1:351) = cellstr('normal'); groundTruthGroup(352:end) = cellstr('abnormal');
%% Select features
featureSelcted = [features(:,1),features(:,2)];
%% Run LDA
[ldaClass, ldaResubErr] = classify(featureSelcted(:,1), featureSelcted(:,2), groundTruthGroup, 'linear');
bad = ~strcmp(ldaClass,groundTruthGroup);
ldaResubErr2 = sum(bad)/numFeatures;
[ldaResubCM,grpOrder] = confusionmat(groundTruthGroup,ldaClass);
%% ROC curve
[X,Y,T,AUC] = perfcurve(featureSelcted(:,1),ldaResubErr,'normal');
plot(X,Y)
xlabel('False positive rate'); ylabel('True positive rate')
title('ROC for classification by lheogistic regression')
%%%%%%
*However, I'm having an error:
Error using perfcurve>membership (line 633) Positive class is not found in the input data.
Error in perfcurve (line 387) [W,subYnames] = membership(labels(sorted),weights(sorted),...
Error in Untitled33 (line 23) [X,Y,T,AUC] = perfcurve(featureSelcted(:,1),featureSelcted(:,2),'normal');
Can any one help me in plotting the ROC curve?
I already attached the Excel sheet.
Many thanks in advance !*
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Detection 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!