Help using perfcurve function!!

조회 수: 5 (최근 30일)
Yasmin Tamimi
Yasmin Tamimi 2012년 8월 14일
Hey everyone,
I have three groups of people normal ones, one with disease in its early stages and last one people with disease in its severe stages. And in each group I study 16 different features. In order to check the discriminatory performance of several features, I need to use area under the receiver operating characteristic curve. I don't know how can i translate my data to input arguments for the perfcurve function!! [X,Y,T,AUC,OPTROCPT,SUBY,SUBYNAMES] = perfcurve(labels,scores,posclass);
Any help will be appreciated.
  댓글 수: 1
Yasmin Tamimi
Yasmin Tamimi 2012년 8월 14일
편집: Yasmin Tamimi 2012년 8월 14일
here is my code but even after writing it and getting the results I still don't understand what does the numbers mean or interpret for X, Y, and AUC!! and on what bases did we choose to assign the ones and zeros for the labels and if I flip will I get different results!! plz advice
labels = {'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'can-';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'ecan+';'dcan+';'dcan+';'dcan+';'dcan+';'dcan+';'dcan+';'dcan+';'dcan+';'dcan+';'dcan+';'dcan+';'dcan+'};
data= [Data_normal; BB; CC ]; % the first group for normal people then people with early disease and finally with severe disease
x1= data((1:132),:); %combinations of can- and ecan+
x2= data([1:70 133:144],:); %combinations of can- and dcan+
x3= data((71:end),:); %combinations of ecan+ and dcan
y1 = (1:132)'>70; %% can- =0, ecan+ =1
y2 = (1:82)'>70; %% can- =0, dcan+ =1
y3 = (1:74)'>62; %% ecan+ =0, dcan+ =1
b1 = glmfit(x1,y1,'binomial');
b2 = glmfit(x2,y2,'binomial');
b3 = glmfit(x3,y3,'binomial');
p1 = glmval(b1,x1,'logit');
p2 = glmval(b2,x2,'logit');
p3 = glmval(b3,x3,'logit');
[X1,Y1,T1,AUC1] = perfcurve(labels((1:132),:),p1,'ecan+');
[X2,Y2,T2,AUC2] = perfcurve(labels([1:70 133:144],:),p2,'dcan+');
[X3,Y3,T3,AUC3] = perfcurve(labels((71:end),:),p3,'dcan+');
figure(1)
plot(X1,Y1)
xlabel('False positive rate'); ylabel('True positive rate')
title('ROC for classification by logistic regression')
figure(2)
plot(X2,Y2)
xlabel('False positive rate'); ylabel('True positive rate')
title('ROC for classification by logistic regression')
figure(3)
plot(X3,Y3)
xlabel('False positive rate'); ylabel('True positive rate')
title('ROC for classification by logistic regression')

댓글을 달려면 로그인하십시오.

채택된 답변

Ilya
Ilya 2012년 8월 14일
Other than a few typos (for example, y1 = (1:132)'>70; clearly is not what you meant), I don't see anything wrong with your code.
glmfit/glmval is your classifier.
The choice of the positive and negative classes is arbitrary. You can always swap them. By convention, the predicted scores must be large for the positive class and small for the negative class. For example, for the first ROC you choose ecan+ as your positive class. Then, I suppose, you set y1 to 1 for ecan+ and 0 for can-. The response returned by your logistic regression model will then be high for ecan+ and low for can-.
You can find many sources (textbooks, web pages etc) that interpret FPR, TPR and AUC.
  댓글 수: 5
Yasmin Tamimi
Yasmin Tamimi 2012년 8월 15일
i used normal distribution and it gave me the same results as in binomial!! no difference!!
Ilya
Ilya 2012년 8월 15일
Your response values are categorical, which means your problem can be treated as a classification problem. The binomial distribution for glmfit is then the obvious choice.
Statistics Tlbx provides many other tools for classification. You might want to start here:
There is no way to predict what model would work best for you. "Best" is usually chosen by balancing the model accuracy and its interpretability.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Ilya
Ilya 2012년 8월 14일
This is a rather vague question. You might get more replies if you explain what approaches you are thinking about and what you have tried so far.
The three groups of people define the labels. You must choose one of these groups as your positive class. Scores typically represent model predictions. You could train a classifier, for instance, to separate the 3 classes and use its predictions.
A ROC curve is used for two classes (groups). I don't know what you mean when you say you need AUC for 3 groups.
  댓글 수: 1
Yasmin Tamimi
Yasmin Tamimi 2012년 8월 14일
i have chosen combinations of two from the three groups,, so i did three different cases!! But what do u mean that I have to train my classifier!! I updated my question and added my code..

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Model Building and Assessment에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by