-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathreg_linear.m
More file actions
36 lines (33 loc) · 988 Bytes
/
reg_linear.m
File metadata and controls
36 lines (33 loc) · 988 Bytes
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
function [bestPara] = reg_linear(algo_id, data_id, num_metric, loss_func)
base = 10;
k = 20;
n = 9;
para.IsCv = 1;
para.method = 'als';
result_avg = cell(n, num_metric+1);
for metric = 1:num_metric+1
for i = 1 : n
result_avg{i, metric} = Inf;
end;
end
para1 = [base.^(-6+(1:n))];
for i = 1 : n
result_avg{ i, 1} = para1(i);
end
for i = n : -1 : 1
para.para1 = para1(i);
para.k = k;
[ avg_metrics, ~ ] = ...
exp_func( algo_id, data_id, para, loss_func);
for metric = 1:num_metric
result_avg{ i, metric+1} = avg_metrics(metric);
end
csvwrite( [ 'result/avg-algo' num2str( algo_id ) '-' data_id '.csv' ], result_avg );
end;
if loss_func == 1
[~,idx] = max([result_avg{:,end}]);
else
[~,idx] = min([result_avg{:,end}]);
end
bestPara.para1 = para1(idx);
end