-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdate_predictions.m
executable file
·107 lines (89 loc) · 5.92 KB
/
update_predictions.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
% PAL (Pareto Active Learning) Algorithm
%
% Copyright (c) 2014 ETH Zurich
%
% This program 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 2 of the License, or
% (at your option) any later version.
%
% This program 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 this program; if not, write to the Free Software
% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
function [pop_predicted,gp_conf] = update_predictions(pop_sampled,pop_predicted,gp_conf,conf,state)
% Get independent values for the training dataset
features_train = pop_sampled.get_features(1:pop_sampled.num_entries);
% Get independent values for the testing dataset
features_test = pop_predicted.get_features(1:pop_predicted.num_entries);
% Get first objective of the sampled population aka training dataset
response_train_obj1 = pop_sampled.get_real_obj(1:pop_sampled.num_entries,1);
response_train_obj2 = pop_sampled.get_real_obj(1:pop_sampled.num_entries,2);
%GP regression
if ((state.iter_train==1) || mod(state.iter_train,conf.gap_hyp_update)==0)
%disp('find hyperparams........')
% Not sure what this means?
gp_conf.hyp_obj1 = gp_find_hp(features_train, response_train_obj1,gp_conf);
gp_conf.hyp_obj2 = gp_find_hp(features_train, response_train_obj2,gp_conf);
% Get prediction results from objective 1 and objective 2
[prediction_test_obj1, var_test_obj1] = gp_original(gp_conf.hyp_obj1, @infExact, gp_conf.meanfunc, gp_conf.covfunc, gp_conf.likfunc, features_train, response_train_obj1,features_test);
[prediction_test_obj2, var_test_obj2] = gp_original(gp_conf.hyp_obj2, @infExact, gp_conf.meanfunc, gp_conf.covfunc, gp_conf.likfunc, features_train, response_train_obj2,features_test);
tic
else
try
[prediction_test_obj1, var_test_obj1] = gp_original(gp_conf.hyp_obj1, @infExact, gp_conf.meanfunc, gp_conf.covfunc, gp_conf.likfunc, features_train, response_train_obj1,features_test);
catch
state.total_time = state.total_time + toc;
disp('gp obj1 failed hyperparams...')
gp_conf.hyp_obj1 = gp_find_hp(features_train, response_train_obj1,gp_conf);
[prediction_test_obj1, var_test_obj1] = gp_original(gp_conf.hyp_obj1, @infExact, gp_conf.meanfunc, gp_conf.covfunc, gp_conf.likfunc, features_train, response_train_obj1,features_test);
tic
end
try
[prediction_test_obj2, var_test_obj2] = gp_original(gp_conf.hyp_obj2, @infExact, gp_conf.meanfunc, gp_conf.covfunc, gp_conf.likfunc, features_train, response_train_obj2,features_test);
catch
state.total_time = state.total_time + toc;
disp('gp obj2 failed hyperparams...')
gp_conf.hyp_obj2 = gp_find_hp(features_train, response_train_obj2,gp_conf);
[prediction_test_obj2, var_test_obj2] = gp_original(gp_conf.hyp_obj2, @infExact, gp_conf.meanfunc, gp_conf.covfunc, gp_conf.likfunc, features_train, response_train_obj2,features_test);
tic
end
end
s_obj1 = var_test_obj1.^(1/2);
s_obj2 = var_test_obj2.^(1/2);
pop_predicted = pop_predicted.set_sigma(1:pop_predicted.num_entries,s_obj1,1);
pop_predicted = pop_predicted.set_sigma(1:pop_predicted.num_entries,s_obj2,2);
pop_predicted = pop_predicted.set_mu(1:pop_predicted.num_entries,prediction_test_obj1,1);
pop_predicted = pop_predicted.set_mu(1:pop_predicted.num_entries,prediction_test_obj2,2);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%% intersect confidence regions %%%%%%%%%%%%%%%%%%%
next_rt_mu_obj1 = zeros(length(s_obj1),1);
next_rt_mu_obj2 = zeros(length(s_obj1),1);
next_rt_sigma_obj1 = zeros(length(s_obj1),1);
next_rt_sigma_obj2 = zeros(length(s_obj1),1);
prev_rt_mu_obj1 = pop_predicted.get_rt_mu(:,1);
prev_rt_mu_obj2 = pop_predicted.get_rt_mu(:,2);
prev_rt_sigma_obj1 = pop_predicted.get_rt_sigma(:,1);
prev_rt_sigma_obj2 = pop_predicted.get_rt_sigma(:,2);
if (state.iter_train>1)
for iter_k = 1:pop_predicted.num_entries
%using new mean and old std dev
area_a = [prev_rt_mu_obj1(iter_k),prev_rt_sigma_obj1(iter_k),prev_rt_mu_obj2(iter_k),prev_rt_sigma_obj2(iter_k)];
area_b = [prediction_test_obj1(iter_k),s_obj1(iter_k)*state.beta,prediction_test_obj2(iter_k),s_obj2(iter_k)*state.beta];
[next_rt_mu_obj1(iter_k),next_rt_sigma_obj1(iter_k),next_rt_mu_obj2(iter_k),next_rt_sigma_obj2(iter_k)]=get_intersection(area_a,area_b);
end
pop_predicted = pop_predicted.set_rt_mu(:,next_rt_mu_obj1,1);
pop_predicted = pop_predicted.set_rt_sigma(:,next_rt_sigma_obj1,1);
pop_predicted = pop_predicted.set_rt_mu(:,next_rt_mu_obj2,2);
pop_predicted = pop_predicted.set_rt_sigma(:,next_rt_sigma_obj2,2);
else
pop_predicted = pop_predicted.set_rt_mu(1:pop_predicted.num_entries,pop_predicted.get_mu(1:pop_predicted.num_entries,1),1);
pop_predicted = pop_predicted.set_rt_mu(1:pop_predicted.num_entries,pop_predicted.get_mu(1:pop_predicted.num_entries,2),2);
pop_predicted = pop_predicted.set_rt_sigma(1:pop_predicted.num_entries,pop_predicted.get_sigma(1:pop_predicted.num_entries,1)*state.beta,1);
pop_predicted = pop_predicted.set_rt_sigma(1:pop_predicted.num_entries,pop_predicted.get_sigma(1:pop_predicted.num_entries,2)*state.beta,2);
end
end