Changeset 72 for birds/doprediction.m


Ignore:
Timestamp:
07/09/13 15:27:17 (11 years ago)
Author:
vcheplygina
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • birds/doprediction.m

    r68 r72  
    1010load('birds20130709.mat');
    1111
    12 ixtrain = find(J == 0);
    13 ixtest = find(J == 1);
     12%ixtrain = find(J == 0);
     13%ixtest = find(J == 1);
     14%z=a(ixtest,:);
    1415
    15 z=a(ixtest,:);
     16
    1617[bags, labs, bagid] = getbags(z);
    1718
     
    2223
    2324
    24 u = milvector([],'e')*scalem([],'variance')*loglc2*classc;
     25predictions2 = nan(length(bagid), 19);
     26
     27%u = simple_mil*classc;
     28
     29u = milvector([],'m')*scalem([],'variance')*libsvc*classc;
     30
    2531
    2632%For each class, train a classifier
    2733for 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);
    3138   
    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,:);
    3447   
    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
    4153end
    4254
     
    5062
    5163fid = fopen('pred20130709.csv', 'w');
    52 fprintf(fid, '%s,%s,%s\n', 'rec_id', 'species', 'probability');
     64fprintf(fid, '%s,%s\r\n', 'Id', 'probability');
    5365
    5466for i=1:length(bagid)
     
    5668    for j=1:C
    5769        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));
    5971        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));
    6173        end
    6274    end
Note: See TracChangeset for help on using the changeset viewer.