-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main_fun.m~
39 lines (28 loc) · 888 Bytes
/
Main_fun.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
function result=Main_fun(dataname)
totalrato=0;
totalacc=[];
totalmae=[];
addpath ./libqp/matlab/
mydir='./dataset/';
bestpars=[];
for i = 1:20,
i
%call CrossV to find the best hyperpara and return the trained coefficient ,then Call testmodel to test the result
trainname=[mydir,dataname,'/','train_',dataname,'.',num2str(i)];
traindata=load(trainname);
testname=[mydir,dataname,'/','test_',dataname,'.',num2str(i)];
testdata=load(testname);
[bestret,bestpar]=CrossV(traindata);
bestpars=[bestpars,bestpar];
[accrato,mae]=testModel(traindata,bestret,testdata);
accrato
totalacc=[totalacc,accrato];
totalmae=[totalmae,mae];
end
result.acc=sum(totalacc)/20;
result.accstd=std(totalacc);
result.mae=sum(totalmae)/20;
result.maestd=std(totalmae);
resultdir = './Result/'
rename=[resultdir,dataname,'jieguo'];
save(rename,'result','bestpars')