source: birds/doprediction.m @ 68

Last change on this file since 68 was 68, checked in by vcheplygina, 11 years ago
File size: 1.3 KB
Line 
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
10load('birds20130709.mat');
11
12ixtrain = find(J == 0);
13ixtest = find(J == 1);
14
15z=a(ixtest,:);
16[bags, labs, bagid] = getbags(z);
17
18
19
20C = 19;
21predictions = nan(length(bagid), 19);
22
23
24u = milvector([],'e')*scalem([],'variance')*loglc2*classc;
25
26%For each class, train a classifier
27for 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);
41end
42
43
44
45
46
47
48%Write everything to a CSV file
49
50
51fid = fopen('pred20130709.csv', 'w');
52fprintf(fid, '%s,%s,%s\n', 'rec_id', 'species', 'probability');
53
54for 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
63end
64fclose(fid);
Note: See TracBrowser for help on using the repository browser.