%i,j,p %i %The rec_id of a recording in the test set. Only include predictions for recordings in the test set. %j %The species/class #. For each rec_id, there should be 19 lines for species 0 through 18. %p %Your classifier's prediction about the probability that species j is present in rec_id i. This must be in the range [0,1]. load('birds20130709.mat'); %ixtrain = find(J == 0); %ixtest = find(J == 1); %z=a(ixtest,:); [bags, labs, bagid] = getbags(z); C = 19; predictions = nan(length(bagid), 19); predictions2 = nan(length(bagid), 19); %u = simple_mil*classc; u = milvector([],'m')*scalem([],'variance')*libsvc*classc; %For each class, train a classifier for i=1:C xtr = changelablist(x,i+1); %Bird 1 is lablist 2, etc thisll = getlablistnames(xtr); xtr = setname(xtr,strtrim(thisll(curlablist(xtr),:))); xtr=makemillabeled(xtr); xte = changelablist(z,i+1); %Bird 1 is lablist 2, etc thisll = getlablistnames(xte); xte = setname(xte,strtrim(thisll(curlablist(xte),:))); xte=makemillabeled(xte); %x = a(ixtrain, :); %z = a(ixtest,:); w = xtr*u; out = xte*w; predictions(:,i) = out(:,2); %Positive class is column 2 end %Write everything to a CSV file fid = fopen('pred20130709.csv', 'w'); fprintf(fid, '%s,%s\r\n', 'Id', 'probability'); for i=1:length(bagid) for j=1:C if (i==length(bagid) && j==C) fprintf(fid, '%d,%f', bagid(i)*100+(j-1), predictions(i,j)); else fprintf(fid, '%d,%f\r\n', bagid(i)*100+(j-1), predictions(i,j)); end end end fclose(fid);