-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrunExperimentActiveTask.m
71 lines (68 loc) · 2.37 KB
/
runExperimentActiveTask.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
%%
% Do an active task selection experiment on the landmine data
%
% Copyright (C) Paul Ruvolo and Eric Eaton 2013
%
% This file is part of ELLA.
%
% ELLA is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% ELLA is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with ELLA. If not, see <http://www.gnu.org/licenses/>.
function y = runExperimentActiveTask()
useLogistic = true;
load('Datasets/landminedata','feature','label');
T = length(feature);
learningCurves = zeros(T);
for t = 1 : T
feature{t}(:,end+1) = 1;
end
d = size(feature{1},2);
X = cell(T,1);
Xtest = cell(T,1);
Y = cell(T,1);
Ytest = cell(T,1);
for t = 1 : T
r = randperm(size(feature{t},1));
traininds = r(1:floor(length(r)/2));
testinds = r(floor(length(r)/2)+1:end);
X{t} = feature{t}(traininds,:);
Xtest{t} = feature{t}(testinds,:);
Y{t} = label{t}(traininds);
Ytest{t} = label{t}(testinds);
end
model = initModelELLA(struct('k',2,...
'd',d,...
'mu',exp(-12),...
'lambda',exp(-10),...
'ridgeTerm',exp(-5),...
'initializeWithFirstKTasks',true,...
'useLogistic',useLogistic,...
'lastFeatureIsABiasTerm',true));
learned = logical(zeros(length(Y),1));
unlearned = find(~learned);
for t = 1 : T
% change the last input to 1 for random, 2 for InfoMax, 3 for Diversity, 4 for Diversity++
idx = selectTaskELLA(model,{X{unlearned}},{Y{unlearned}},2);
model = addTaskELLA(model,X{unlearned(idx)},Y{unlearned(idx)},unlearned(idx));
learned(unlearned(idx)) = true;
unlearned = find(~learned);
% encode the unlearned tasks
for tprime = 1 : length(unlearned)
model = addTaskELLA(model,X{unlearned(tprime)},Y{unlearned(tprime)},unlearned(tprime),true);
end
for tprime = 1 : T
preds = predictELLA(model,Xtest{tprime},tprime);
learningCurves(t,tprime) = roc(preds,Ytest{tprime});
end
end
y = mean(learningCurves,2);
end