[68] | 1 | %i,j,p
|
---|
| 2 | %i
|
---|
| 3 | %The rec_id of a recording in the test set. Only include predictions for recordings in the test set.
|
---|
| 4 | %j
|
---|
| 5 | %The species/class #. For each rec_id, there should be 19 lines for species 0 through 18.
|
---|
| 6 | %p
|
---|
| 7 | %Your classifier's prediction about the probability that species j is present in rec_id i. This must be in the range [0,1].
|
---|
| 8 |
|
---|
| 9 |
|
---|
| 10 | load('birds20130709.mat');
|
---|
| 11 |
|
---|
| 12 | ixtrain = find(J == 0);
|
---|
| 13 | ixtest = find(J == 1);
|
---|
| 14 |
|
---|
| 15 | z=a(ixtest,:);
|
---|
| 16 | [bags, labs, bagid] = getbags(z);
|
---|
| 17 |
|
---|
| 18 |
|
---|
| 19 |
|
---|
| 20 | C = 19;
|
---|
| 21 | predictions = nan(length(bagid), 19);
|
---|
| 22 |
|
---|
| 23 |
|
---|
| 24 | u = milvector([],'e')*scalem([],'variance')*loglc2*classc;
|
---|
| 25 |
|
---|
| 26 | %For each class, train a classifier
|
---|
| 27 | for i=1:C
|
---|
| 28 | a = changelablist(a,i+1); %Bird 1 is lablist 2, etc
|
---|
| 29 | x = a(ixtrain, :);
|
---|
| 30 | z = a(ixtest,:);
|
---|
| 31 |
|
---|
| 32 | w = x*u;
|
---|
| 33 | out = z*w;
|
---|
| 34 |
|
---|
| 35 | try
|
---|
| 36 | testc(out,'auc')
|
---|
| 37 | catch
|
---|
| 38 | end
|
---|
| 39 |
|
---|
| 40 | predictions(:,i) = out(:,1);
|
---|
| 41 | end
|
---|
| 42 |
|
---|
| 43 |
|
---|
| 44 |
|
---|
| 45 |
|
---|
| 46 |
|
---|
| 47 |
|
---|
| 48 | %Write everything to a CSV file
|
---|
| 49 |
|
---|
| 50 |
|
---|
| 51 | fid = fopen('pred20130709.csv', 'w');
|
---|
| 52 | fprintf(fid, '%s,%s,%s\n', 'rec_id', 'species', 'probability');
|
---|
| 53 |
|
---|
| 54 | for i=1:length(bagid)
|
---|
| 55 |
|
---|
| 56 | for j=1:C
|
---|
| 57 | if (i==length(bagid) && j==C)
|
---|
| 58 | fprintf(fid, '%d,%d,%f', bagid(i), j-1, predictions(i,j));
|
---|
| 59 | else
|
---|
| 60 | fprintf(fid, '%d,%d,%f\n', bagid(i), j-1, predictions(i,j));
|
---|
| 61 | end
|
---|
| 62 | end
|
---|
| 63 | end
|
---|
| 64 | fclose(fid);
|
---|