-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSBM_case_PositiveInformative.m~
127 lines (97 loc) · 4.16 KB
/
SBM_case_PositiveInformative.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
function SBM_case_PositiveInformative
% Runs experiment corresponding to section 3.1 of our paper
% structure of multilayer graph:
% - 2 clusters
% - Two layers:
% - - Layer one is strongly informative (assortative)
% - - Layer two goes from an assortative to an assortative configuration
restoredefaultpath
addpath(genpath('utils'))
addpath(genpath('subroutines'))
addpath(genpath('SpectralClusteringOfSignedGraphsViaMatrixPowerMeans'))
dirName_Output_Data = 'SBM_case_PositiveInformative';
if ~exist(dirName_Output_Data,'dir')
mkdir(dirName_Output_Data)
end
% Multilayer Graph data
sizeOfEachCluster = 100;
numClusters = 2;
numLayers = 2;
% Ground Truth vector
GroundTruth = [];
for i = 1:numClusters
GroundTruth = [GroundTruth; i*ones(sizeOfEachCluster,1)];
end
% Setting ground truth per layer
GroundTruthPerLayerCell = cell(numLayers,1);
for i = 1:numLayers
GroundTruthPerLayerCell{i} = GroundTruth;
end
% Data for power means
pArray = [10,5,1,0,-1,-5,-10];
idxNeg = find(pArray<=0);
% Setting diagonal shift depending of value of power 'p'
diagShiftArray = zeros(size(pArray))+1.e-6;
diagShiftArray(idxNeg) = log10(1+abs(pArray(idxNeg)))+1.e-6;
% computation method
method_str = 'eigs';
% method_str = 'polynomial_krylov';
% Mixing parameter
diffArray = -0.05:0.005:0.05;
pin_Layer1_Array = (0.1+diffArray)/2; %p_in of layer 1
pout_Layer1_Array = (0.1-diffArray)/2; %p_out of layer 2
pin_Layer2_Array = 0.01*ones(size(diffArray)); %p_in of layer 2
pout_Layer2_Array = 0.09*ones(size(diffArray)); %p_out of layer 2
pin_Layer1_Array = 0.09*ones(size(diffArray)); %p_in of layer 1
pout_Layer1_Array = 0.01*ones(size(diffArray)); %p_out of layer 1
pin_Layer2_Array = (0.1+diffArray)/2; %p_in of layer 2
pout_Layer2_Array = (0.1-diffArray)/2; %p_out of layer 2
pin_input = [pin_Layer1_Array(:) pin_Layer2_Array(:) ]; %p_in per layer
pout_input = [pout_Layer1_Array(:) pout_Layer2_Array(:)]; %p_out per layer
1;
% number of runs
numRuns = 50;
% Run experiment
subdir = strcat(dirName_Output_Data, filesep, 'method_str_', method_str);%, '_diagShift_', num2str(diagShiftValue));
if ~exist(subdir,'dir')
mkdir(subdir)
end
power_mean_error_mean_cell = cell(length(diffArray),1);
for i = 1:length(diffArray)
pinVec = pin_input(i,:);
poutVec = pout_input(i,:);
C_cell_power_mean = run_experiment_SBM(...
pinVec, poutVec, numRuns, numClusters, GroundTruthPerLayerCell, numLayers, pArray, diagShiftArray, method_str);
power_mean_error_mean_cell{i} = get_means(C_cell_power_mean, GroundTruth);
end
filename = strcat(subdir, filesep, 'output.mat');
save(filename, 'power_mean_error_mean_cell', '-v7.3')
% load(filename)
1;
% Plot
fig_handle = get_plot_SBM_1(power_mean_error_mean_cell, diffArray);
filename_prefix = strcat(subdir, filesep, 'plot');
save_plots(fig_handle, filename_prefix)
1;
function fig_handle = get_plot_SBM_1(power_mean_error_mean_cell, diffArray)
dataMatrix = cell2mat(power_mean_error_mean_cell)';
% plot Parameters
[legendCell, colorCell, markerCell, LineStyleCell, LineWidthCell] = get_plot_parameters;
MarkerSize = [];
fontSize = 20;
fontSize_legend = 20;
xArray = diffArray;
legendLocation = 'northeast';
xAxisTitle_str = {'Positive Informative','\quad\,\, $G^+:p_{\mathrm{in}}^+ - p_{\mathrm{out}}^+$'};
yAxisTitle_str = 'Mean Clustering Error';
title_str = '\fontsize{15}{0} $ G^{-}: \mathbf{ p_{\mathrm{in}}=0.01,\,\, p_{\mathrm{out}}=0.09}$';
legendBoolean = true;
xTickArray = [1,6,11,16,21];
yTickArray = 0:0.1:0.5;
1;
% plot!
fig_handle = plot_performance(dataMatrix, xArray, legendCell, colorCell, LineStyleCell, markerCell, MarkerSize, LineWidthCell,legendLocation,xAxisTitle_str,yAxisTitle_str, title_str, fontSize,fontSize_legend,legendBoolean,xTickArray,yTickArray);
% Create arrow
annotation(fig_handle,'arrow',[0.24400871459695 0.78649237472767],...
[0.0855928954621513 0.0855928954621513],'LineWidth',3,'HeadWidth',30,...
'HeadLength',20);