-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhpsearching.m
94 lines (77 loc) · 2.88 KB
/
hpsearching.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
% Hyperparameters searching for gunar datasets
addpath(genpath(pwd()));
dpath ='D:\Codeplace\Dataset\GunarDataset\benchmarks.mat';
datasets = load(dpath,'benchmarks');
datasets = datasets.('benchmarks');
dpath = 'D:\Codeplace\Dataset\dataset_single\';
datasets ={'abalone.csv','ailerons.csv','automgp.csv','bank.csv','boston.csv',...
'california.csv','elevator.csv','servo.csv','cpu_small.data','machine.data','triazines.data','r_wpbc.data' };
n_testing=[2177,4129,200,3692,256,12640,5517,87,4192,109,86,94];
% if classification class=1, regression class=0
class = 0;
% hyperparams
nodes = 5:5:200;
% nodes = 1:15;
ncv = 10;
bestnode = ones(1,length(datasets));
alname = 'elm';
for j = 1:length(datasets)
clear cv;
prev_err = 100;
fails = zeros(1,length(nodes));
for i=1:length(nodes)
% [j i]
switch alname
case 'lsm'
net = lsmr(nodes(i),~class); %args: (iteration, isReg?)
case 'elm'
net = elm(nodes(i),1e-6); %args: (nHidden, cReg)
case 'dpelm'
net = dpelm(nodes(i)); %args: (nHidden)
case 'cpelm'
net = cpelm(nodes(i)); %args: (nHidden)
case 'pcaelm'
net = pcaelm(0.95, 1e-6); %args: (confLev,cReg)
case 'eielm'
net = eielm(nodes(i),10); %args: (nHidden)
case 'ielm'
net = eielm(nodes(i),1); %args: (nHidden)
case 'ail'
net = ail(nodes(i),0,1e-6); %args: (iteration, isClass?, cReg/Lambda)
otherwise
net = bpnet(nodes(i)); %args: (nHidden)
end
if class
cv = struct;
dt=load(dpath,datasets{j});
for ii = 1:ncv
cv(ii).test = dt.(datasets{j}).test(ii,:);
cv(ii).training = dt.(datasets{j}).train(ii,:);
end
x=mapminmax(dt.(datasets{j}).x',-1,1)';
y=dt.(datasets{j}).t;
else
dt=normalize(csvread([dpath,datasets{j}]));
dt(isnan(dt))=0;
x=dt(:,1:(size(dt,2)-1));x=mapminmax(x',-1,1)';
y=dt(:,size(dt,2));y=mapminmax(y',0,1)';
cv(1) = cvpartition(y,'HoldOut',n_testing(j),'Stratify',false);
for ii = 1:ncv-1
cv(ii+1) = repartition(cv(ii));
end
end
results = runcvdata(x,y,cv,net,class);
if mean(results.tsPerf)<prev_err
prev_err = mean(results.tsPerf);
bestnode(j) = nodes(i);
fails(i)=0;
else
fails(i) = fails(i-1)+1;
if fails(i)>5
break;
end
end
end
prev_err
end
save([alname,'r_regbrev'],'bestnode');