-
Notifications
You must be signed in to change notification settings - Fork 39
/
Test_Learning_TVHP_SyntheticData.m
113 lines (85 loc) · 2.11 KB
/
Test_Learning_TVHP_SyntheticData.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
108
109
110
111
112
113
% demo: testing synthetic data
clear
load SynData_TVHP.mat
%type = 1;
%ShowTMHP(Seq{1,type}, mu, T, w, Period, Shift, MaxInfect, type)
SeqTrain = Seqs{2}(1:1000);
SeqTest = Seqs{2}(1001:2000);
option1.outer = 2;
option1.inner = 5;
option1.innerW = 5;
option1.thresW = 1e-5;
option1.step = 1e-5;
option1.D = 2;
option1.landmark = 0:5:50;
option1.M = length(option1.landmark);
option1.sigmaA = 5;
option1.typeA = 'gauss';
option1.sigmaT = 1;
option1.typeT = 'exp';
option1.thres = 1e-5;
option1.bias = 0.1;
option1.delta = 2;
option1.reg = 'L1';
option1.rho = 1;
option1.factor = 1.1;
option1.alphaS = 1;
NN = 5;
model = cell(NN,1);
for nn = 1:NN
number = 200*nn;
model{nn} = Learning_MLE_TVHP( SeqTrain(1:number), option1 );
end
save('Result_TVHP_Synthetic.mat', ...
'model', 'option1');
%%
load Result_TVHP_Synthetic.mat
U = option1.D;
NN = 5;
A = zeros(U,U,T,Type);
Error = zeros(1, NN);
LogLike = zeros(1,NN);
for nn = 1:NN
LogLike(nn) = Loglike_TVHP( SeqTest, model{nn}, option1 );
Err = 0;
for type = Type
for t=1:T
A(:,:,t,type) = Infectivity_TVHP(T, t, Period, Shift, MaxInfect, type);
end
basis = Kernel_TVHP( 1:T, option1.landmark, option1.sigmaA, option1.typeA );
%figure
for u=1:option1.D
for v = 1:option1.D
subplot(option1.D,option1.D,option1.D*(u-1)+v)
tmp=A(u,v,:,type);
Atmp = model{nn}.A(v,:,u)*basis;
hold on
plot(1:T, tmp(:), 'k-');
plot(1:T, Atmp(:), 'r-');
title(sprintf('a_{%d%d}(t)',u,v));
legend('Real', 'Est')
hold off
Err = Err+norm(tmp(:)-Atmp(:));
end
end
Error(nn) = Err/(option1.D^2);
end
end
NUM = 200:200:1000;
figure
subplot(121)
hold on
plot(NUM, -LogLike, 'bs-');
axis tight
axis square
ylabel('LogLike');
xlabel('The number of training samples');
hold off
subplot(122)
hold on
plot(NUM, Error, 'bs-');
axis tight
axis square
ylabel('Relative Error');
xlabel('The number of training samples');
hold off