-
Notifications
You must be signed in to change notification settings - Fork 1
/
MKCemdbht_run.m
103 lines (88 loc) · 3.17 KB
/
MKCemdbht_run.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
function [rmse]=MKCemdnht_run(name,Rep,c1,c2,c3)
para.c1=c1;
para.c2=c2;
para.c3=c3;
fname=[name,'_emdbht'];
system(['mkdir ../',fname]);
str=[num2str(c1),'_',num2str(c2),'_',num2str(c3)];
load(['../data/',name,'.mat'])
M=size(K,3);
if length(size(IDmisTest))==3
MISS=size(IDmisTest,3);
end
if length(size(IDmisTest))==4
MISS=size(IDmisTest,4);
end
for nInd=1:1:MISS
for r=1:1:Rep
for cv=1:1:2
if cv ==1
idts = squeeze([IDtr(r,:),IDts(r,:)]);
Kts=K(idts,idts,:);
MID=ones(length(IDtr(r,:)),M);
if length(size(IDmisTest))==3
MID=[MID; squeeze(IDmisTest(:,:,nInd))];
end
if length(size(IDmisTest))==4
MID=[MID; squeeze(IDmisTest(r,:,:,nInd))];
end
else
idts = squeeze([IDtr(r,:),IDval(r,:)]);
Kts=K(idts,idts,:);
MID=ones(length(IDtr(r,:)),M);
if length(size(IDmisCv))==3
MID=[MID; squeeze(IDmisCv(:,:,nInd))];
end
if length(size(IDmisCv))==4
MID=[MID; squeeze(IDmisCv(r,:,:,nInd))];
end
end
Kts0=Kts;
for m=1:1:M
unObs(m).id=find(MID(:,m)==0);
Kts0(unObs(m).id,:,m)=NaN;
Kts0(:,unObs(m).id,m)=NaN;
end
if exist(['../',fname,'/sF',name,'miss_',num2str(nInd),'r_',num2str(r),'_cv_',num2str(cv),'_',str,'Model.mat'])==2
disp(['../',fname,'/sF',name,'miss_',num2str(nInd),'r_',num2str(r),'_cv_',num2str(cv),'_',str,'Model.mat'])
load(['../',fname,'/sF',name,'miss_',num2str(nInd),'r_',num2str(r),'_cv_',num2str(cv),'_',str,'Model.mat'],'Mer');
else
O=9999999999999;
for init=1:1:5
stime = tic;
[tPredK,tA,tS,tobjective,tiOutput]=MKCemdbht(Kts0,MID,para,init);
runtime(init)=toc(stime);
if tobjective.T <O
PredK=tPredK;
Model.A=tA;
Model.S=tS;
Model.objective=tobjective;
Model.iOutput=tiOutput;
O=tobjective.T
end
end
Model.Sall=Model.S;
Model.S(find(Model.S<=0.05))=0;
Model.Aall=Model.A
Model.A(find(Model.A<=0.001))=0;
M=size(K,3)
for m=1:1:M
unObs(m).id=find(MID(:,m)==0);
if length(unObs(m).id)>0
info(m).Er=diag((PredK(unObs(m).id,:,m)-Kts(unObs(m).id,:,m))*(PredK(unObs(m).id,:,m)-Kts(unObs(m).id,:,m))')./diag(Kts(unObs(m).id,:,m)*Kts(unObs(m).id,:,m)');
else
info(m).Er=0;
end
Mer(m)=mean(info(m).Er);
Ser(m)=std(info(m).Er);
info(m).core=find(sum(abs(Model.A(:,:,m)))>0.3)
Ncore(m)=length(info(m).core);
end
save(['../',fname,'/sF',name,'miss_',num2str(nInd),'r_',num2str(r),'_cv_',num2str(cv),'_',str,'Model.mat'] ,'Model','PredK','Kts','MID','unObs','info','Ncore','Mer','Ser','runtime');
end
rmse(r,nInd,cv)=mean(Mer);
end
end
end
return;
end