How to find the ROC curve?

2 次查看(过去 30 天)
Nourhan
Nourhan 2014-3-22
编辑: Nourhan 2014-3-22
*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 !*
  1 个评论
Image Analyst
Image Analyst 2014-3-22
编辑:Image Analyst 2014-3-22
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.

请先登录,再进行评论。

回答(0 个)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by