Changeset 72 for birds/doprediction.m
- Timestamp:
- 07/09/13 15:27:17 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
birds/doprediction.m
r68 r72 10 10 load('birds20130709.mat'); 11 11 12 ixtrain = find(J == 0); 13 ixtest = find(J == 1); 12 %ixtrain = find(J == 0); 13 %ixtest = find(J == 1); 14 %z=a(ixtest,:); 14 15 15 z=a(ixtest,:); 16 16 17 [bags, labs, bagid] = getbags(z); 17 18 … … 22 23 23 24 24 u = milvector([],'e')*scalem([],'variance')*loglc2*classc; 25 predictions2 = nan(length(bagid), 19); 26 27 %u = simple_mil*classc; 28 29 u = milvector([],'m')*scalem([],'variance')*libsvc*classc; 30 25 31 26 32 %For each class, train a classifier 27 33 for i=1:C 28 a = changelablist(a,i+1); %Bird 1 is lablist 2, etc 29 x = a(ixtrain, :); 30 z = a(ixtest,:); 34 xtr = changelablist(x,i+1); %Bird 1 is lablist 2, etc 35 thisll = getlablistnames(xtr); 36 xtr = setname(xtr,strtrim(thisll(curlablist(xtr),:))); 37 xtr=makemillabeled(xtr); 31 38 32 w = x*u; 33 out = z*w; 39 xte = changelablist(z,i+1); %Bird 1 is lablist 2, etc 40 thisll = getlablistnames(xte); 41 xte = setname(xte,strtrim(thisll(curlablist(xte),:))); 42 xte=makemillabeled(xte); 43 44 45 %x = a(ixtrain, :); 46 %z = a(ixtest,:); 34 47 35 try 36 testc(out,'auc') 37 catch 38 end 39 40 predictions(:,i) = out(:,1); 48 w = xtr*u; 49 out = xte*w; 50 51 52 predictions(:,i) = out(:,2); %Positive class is column 2 41 53 end 42 54 … … 50 62 51 63 fid = fopen('pred20130709.csv', 'w'); 52 fprintf(fid, '%s,%s ,%s\n', 'rec_id', 'species', 'probability');64 fprintf(fid, '%s,%s\r\n', 'Id', 'probability'); 53 65 54 66 for i=1:length(bagid) … … 56 68 for j=1:C 57 69 if (i==length(bagid) && j==C) 58 fprintf(fid, '%d,% d,%f', bagid(i), j-1, predictions(i,j));70 fprintf(fid, '%d,%f', bagid(i)*100+(j-1), predictions(i,j)); 59 71 else 60 fprintf(fid, '%d,% d,%f\n', bagid(i), j-1, predictions(i,j));72 fprintf(fid, '%d,%f\r\n', bagid(i)*100+(j-1), predictions(i,j)); 61 73 end 62 74 end
Note: See TracChangeset
for help on using the changeset viewer.