How to find the ROC curve?
2 views (last 30 days)
Show older comments
*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 Comment
Image Analyst
on 22 Mar 2014
Edited: Image Analyst
on 22 Mar 2014
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.
Answers (0)
See Also
Categories
Find more on Detection in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!