-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_MLP_HGPDR.m
78 lines (74 loc) · 2.4 KB
/
run_MLP_HGPDR.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
clear;clc
prompt = 'Type the seed number:\n';
seed = input(prompt);
s = RandStream('mt19937ar','Seed',seed);
RandStream.setGlobalStream(s);
gs = RandStream.getGlobalStream();
filename = 'dblp_324.mat';
load(['dataset/',filename]);
addpath(genpath('src_HGPDR/'));
options.burnin = 2000;
options.mcmcsamps = 1000;
options.display = 0;
%% create training test data
% T = size(B, 3);
% Acore = cell(1,T);
% for t = 1:T
% Acore{t} = B(:, :, t);
% end
numslices = numel(Acore);
TrainRatio = 0.8;
options.TrainRatio = TrainRatio;
idx_train = cell(numslices, 1);
idx_test = cell(numslices, 1);
BTrain_Mask = cell(numslices, 1);
% for t = 1:numslices
% [idx_train{t}, idx_test{t}, BTrain_Mask{t}] = Create_Mask_network(Acore{t}, TrainRatio);
% end
% options.idx_train = idx_train;
% options.idx_test = idx_test;
% TrainRatio = 1; options2.TrainRatio = TrainRatio;
% idx_train = cell(numslices, 1);
% idx_test = cell(numslices, 1);
% BTrain_Mask = cell(numslices, 1);
% for t = 1:numslices
% [idx_train{t}, idx_test{t}, BTrain_Mask{t}] = Create_Mask_network(Acore{t}, TrainRatio);
% end
options2.idx_train = idx_train;
options2.idx_test = idx_test;
options2.burnin = 2000;
options2.mcmcsamps = 1000;
options2.display =0;
%%
numrep = 5;
result = cell(numrep,1);
seed = [4604 8365 6969 1234 5432 7575 8848 9999 1010];
for rep = 1:numrep
if 1
s = RandStream('mt19937ar','Seed', seed(rep)); % Good demo seed
RandStream.setGlobalStream(s);
gs = RandStream.getGlobalStream();
fprintf('Random seed: %d\n', gs.Seed);
for t = 1:numslices
[idx_train{t}, idx_test{t},~] = Create_Mask_network(full(Acore{t}), TrainRatio);
end
%% missing link prediction
options.eval = 1;
options.idx_train = idx_train;
options.idx_test = idx_test;
options.TrainRatio = TrainRatio;
result = HGPDR_batch_Gibbs(Acore(1:numslices), options);
save(['result/result_HGPDR_rng',num2str(rep),'.mat'], 'options','result');
end
%% future network prediction
if 0
options2.eval = 0;
for numslices = 3:numel(Acore)
N = size(Acore{1}, 1);
fprintf(['HGPDR_T:',num2str(numslices),', N:',num2str(N),'.\n']);
samp = HGPDR_batch_Gibbs(Acore(1:(numslices-1)), options2);
[pred] = increament_phi(Acore(numslices), samp);
save(['result/result_pred',num2str(numslices),'_HGPDR_rng',num2str(rep),'.mat'], 'options','pred');
end
end
end