http://www.mathworks.com/matlabcentral/newsreader/view_thread/280351
MATLAB Central Newsreader  perfcurve function?? simple
Feed for thread: perfcurve function?? simple
enus
©19942015 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://www.mathworks.com/images/membrane_icon.gif

Sat, 24 Apr 2010 16:53:05 +0000
perfcurve function?? simple
http://www.mathworks.com/matlabcentral/newsreader/view_thread/280351#738991
Mohammad A. Mezher
Hi,<br>
<br>
I am not sure about the function perfcurve in matlab.. the function takes number of input parameters:<br>
[X,Y] = perfcurve(labels,scores,posclass);<br>
<br>
what is the labels? <br>
what is the scores?<br>
<br>
I read all its documentation but can't find the data that i have to use in labels and in scores??<br>
<br>
<br>
appreciate any clarification..<br>
<br>
Thanks

Sat, 24 Apr 2010 22:54:05 +0000
Re: perfcurve function?? simple
http://www.mathworks.com/matlabcentral/newsreader/view_thread/280351#739038
Sadik
Hi Mohammad,<br>
<br>
The following example from the documentation is very illustrative. I am going to explain it a bit for you to better understand it:<br>
<br>
1. load fisheriris <br>
%matlab's own dataset. Basically, there are three types of fish: setosa, versicolor and virginica [these names are in the variable species] and 50 samples per type. The first fifty is setosa, second fifty is versicolor and the third is virginica.<br>
2. x = meas(51:end,1:2); <br>
% If you load the data, you will see that meas is a 150x4 matrix. There are 150 samples with 4 features per sample. x = meas(51:end,1:2) chooses the data pertaining to versicolor and virginica, and it is getting only 2 of the 4 features.<br>
3. y = (1:100)'>50; <br>
% versicolor=0, virginica=1<br>
% 50 zeros and 50 ones. This means, versicolor will be represented by zeroes and virginica by ones in the glm.<br>
4. b = glmfit(x,y,'binomial'); <br>
% Obtain the model parameters. <br>
5. p = glmval(b,x,'logit'); <br>
% Using these parameters, compute the output of the classifier. This is what goes into "scores" in perfcurve.<br>
6. [X,Y,T,AUC] = perfcurve(species(51:end,:),p,'virginica');<br>
% You can very easily see now. "labels" is nothing but a list of true labels you had in your data set. Since, after reduction, the dataset had 50 versicolors and 50 virginicas, "labels" is now a cell array where the first 50 elements are equal to the string 'versicolor' and the last 50 is equal to 'virginica'. <br>
% The last input to perfcurve "posclass" is the label of the positive class. If you look at line 3. above, we are assigning 1 to the second fifty, which is virginica. Therefore, the label of the positive class is 'virginica'.<br>
plot(X,Y)<br>
xlabel('False positive rate'); ylabel('True positive rate')<br>
title('ROC for classification by logistic regression')<br>
<br>
Best.

Sun, 25 Apr 2010 03:09:05 +0000
Re: perfcurve function?? simple
http://www.mathworks.com/matlabcentral/newsreader/view_thread/280351#739062
Mohammad A. Mezher
"Sadik " <sadik.hava@gmail.com> wrote in message <hqvsqd$i5d$1@fred.mathworks.com>...<br>
> Hi Mohammad,<br>
> <br>
> The following example from the documentation is very illustrative. I am going to explain it a bit for you to better understand it:<br>
> <br>
> 1. load fisheriris <br>
> %matlab's own dataset. Basically, there are three types of fish: setosa, versicolor and virginica [these names are in the variable species] and 50 samples per type. The first fifty is setosa, second fifty is versicolor and the third is virginica.<br>
> 2. x = meas(51:end,1:2); <br>
> % If you load the data, you will see that meas is a 150x4 matrix. There are 150 samples with 4 features per sample. x = meas(51:end,1:2) chooses the data pertaining to versicolor and virginica, and it is getting only 2 of the 4 features.<br>
> 3. y = (1:100)'>50; <br>
> % versicolor=0, virginica=1<br>
> % 50 zeros and 50 ones. This means, versicolor will be represented by zeroes and virginica by ones in the glm.<br>
> 4. b = glmfit(x,y,'binomial'); <br>
> % Obtain the model parameters. <br>
> 5. p = glmval(b,x,'logit'); <br>
> % Using these parameters, compute the output of the classifier. This is what goes into "scores" in perfcurve.<br>
> 6. [X,Y,T,AUC] = perfcurve(species(51:end,:),p,'virginica');<br>
> % You can very easily see now. "labels" is nothing but a list of true labels you had in your data set. Since, after reduction, the dataset had 50 versicolors and 50 virginicas, "labels" is now a cell array where the first 50 elements are equal to the string 'versicolor' and the last 50 is equal to 'virginica'. <br>
> % The last input to perfcurve "posclass" is the label of the positive class. If you look at line 3. above, we are assigning 1 to the second fifty, which is virginica. Therefore, the label of the positive class is 'virginica'.<br>
> plot(X,Y)<br>
> xlabel('False positive rate'); ylabel('True positive rate')<br>
> title('ROC for classification by logistic regression')<br>
> <br>
> Best.<br>
<br>
Thank you Sadik for your reply,<br>
<br>
i think i am missing something here you did not use any type of training and testing data for example:<br>
<br>
load ionodata % ionosphere dataset has A for data and groups for their labels <br>
indices = crossvalind('Kfold',groups,3);<br>
test = (indices == i); train = ~test;<br>
svmStruct = svmtrain(A(train),groups(train)); <br>
classes = svmclassify(svmStruct,A(test));<br>
<br>
I am stuck here what kind of data i have to use in the perfcurve function<br>
pos =0; % for positive labels<br>
[X,Y,T,AUC] = perfcurve(labels,scores,pos);<br>
<br>
are the labels and scores here for labels and the confidence of training data or for the test data or for all dataset??<br>
<br>
Thank you in advance..

Sun, 25 Apr 2010 11:06:05 +0000
Re: perfcurve function?? simple
http://www.mathworks.com/matlabcentral/newsreader/view_thread/280351#739118
Sadik
You should be using the labels of the testing data and the scores obtained by the testing data.<br>
<br>
Best.

Sun, 25 Apr 2010 17:04:05 +0000
Re: perfcurve function?? simple
http://www.mathworks.com/matlabcentral/newsreader/view_thread/280351#739200
Mohammad A. Mezher
"Sadik " <sadik.hava@gmail.com> wrote in message <hr17mt$ad4$1@fred.mathworks.com>...<br>
> You should be using the labels of the testing data and the scores obtained by the testing data.<br>
> <br>
> Best.<br>
<br>
<br>
Thank you for your reply. Do you thinking of any function to compute the score value (the confidence) of testing data?? i have the following equation<br>
d(x) = sum K(xi,x)*(alphai.*yi)  0.5*sum K(xi,sv)*(alphai.*yi)<br>
<br>
xi training data<br>
yi labels of training data<br>
x testing data<br>
K() kernel function<br>
sv support vector