Username Remember Me?
Password   forgot password?
   
   
How to solve : Crisp labels cannot be supplied by a dataset, reset labtype first
Posted: 03 January 2011 08:21 AM   [ Ignore ]  
Newbie
Rank
Total Posts:  11
Joined  2010-07-01

Previously:
Hi Bob,
Q : How to reset the feature column to be class and class to be the feature.
...........
Answer:
If features and labels are given as columns in an array DATA and the labels are in column L then a proper PRTools dataset may be constructed by

DAT = DATA;
DAT(:,L) = []
A = dataset(DAT,DATA(:,L));

Hope this helps.

Bob Duin

Next Q: I have tried to flip the feature and label column but it complained
“Crisp labels cannot be supplied by a dataset, reset labtype first”.
So I set the label, but still the same error occured. Anything I missed out?
Thanks again.

A = dataset(DiscretIrisTrainA,DiscretIrisTrainAA);
....
for i = 1 : nvars %for each feature/attribute
z = 0;
B = [A(:,i) A.labels];
C = B(:,1:2); % get each feature and its class
[D I] = sort(C(:,1),’ascend’); %sort
E = C(I,:);
DAT = E;
DAT(:,2)=[]; % empty the label, DAT has feature column
DAT = setlabtype(DAT,’crisp’); % suppose to reset the label type
A=dataset(E(:,2),DAT);

Profile
 
 
Posted: 03 January 2011 12:00 PM   [ Ignore ]   [ # 1 ]  
Moderator
RankRankRankRank
Total Posts:  253
Joined  2008-11-08

In this code you assume that PRTools stores labels as columns, but that is not true. Please redefine datasets as I have indicated in the previous reply.

Bob Duin

Profile
 
 
Posted: 04 January 2011 04:10 AM   [ Ignore ]   [ # 2 ]  
Newbie
Rank
Total Posts:  11
Joined  2010-07-01

Thanks Bob for the idea. Yes I misunderstood the class as a
column in the data. Anyway I managed to solve the problem.

for i = 1 : nvars %for each feature/attribute
B = [A(:,i) A.labels];
C = B(:,1:2); % get each feature and its class
[D I] = sort(C(:,1),’ascend’); %sort
E = C(I,:);
DAT = E;
DATA = E; %try and error
DAT(:,2)=[]; % empty the label, DAT has feature column
mfaDAT=DAT(:,1);
DATA(:,1)=[]; % empty the feature, DATA has label column
mfaDATA=DATA(:,1
mfaDAT=setlabtype(mfaDAT,’soft’,mfaDATA);
mfaDATA=setlabtype(mfaDATA,’soft’,mfaDAT);
A=dataset(mfaDATA,mfaDAT);% flip
..........

Profile