@@ -63,85 +63,35 @@ def plot_features(self):
63
63
Plot the features of the random graphs.
64
64
'''
65
65
for i , feature in enumerate (self .features ):
66
- plt .errorbar (self .search_space , [np .mean (self .random_graphs_features ['{}_{}' .format (feature , sparsity )]) for sparsity in self .search_space ],
67
- yerr = [np .std (self .random_graphs_features ['{}_{}' .format (feature , sparsity )]) for sparsity in self .search_space ], label = 'Random Graphs' )
68
- plt .plot (self .search_space , [self .fc_graph_features ['{}_{}' .format (feature , sparsity )] for sparsity in self .search_space ], label = 'Real Graph' , marker = 'o' )
69
- plt .xlabel ('Sparsity' )
66
+ plt .errorbar (self .search_space ,
67
+ [np .mean (self .random_graphs_features ['{}_{}' .format (feature , sparsity )]) for sparsity in self .search_space ],
68
+ yerr = [np .std (self .random_graphs_features ['{}_{}' .format (feature , sparsity )]) for sparsity in self .search_space ],
69
+ label = 'Random Graphs' ,
70
+ fmt = '-o' ,
71
+ capsize = 3 )
72
+ plt .plot (self .search_space ,
73
+ [self .fc_graph_features ['{}_{}' .format (feature , sparsity )] for sparsity in self .search_space ],
74
+ label = 'Real Graph' ,
75
+ marker = 'o' )
76
+ plt .xlabel (self .analysis_type )
70
77
plt .ylabel (feature )
71
78
plt .legend ()
72
- plt .savefig ('output/{}_sparsity .png' .format (feature ) )
79
+ plt .savefig ('output/{}_{} .png' .format (feature , self . analysis_type ), dpi = 600 )
73
80
plt .clf ()
74
81
82
+ def compute_auc (self ):
83
+ '''
84
+ Compute the AUC for a given feature.
85
+ '''
86
+ pass
87
+
75
88
76
89
if __name__ == '__main__' :
77
90
ngraphs = 1000
78
91
fc_matrix = np .loadtxt ('output/stim_0_fc_mean.csv' , delimiter = ',' )
79
- x = RandomGraphAnalyzer (fc_matrix , n_rnd_graphs = ngraphs , analysis_type = 'threshold ' , features = ['global_efficiency' , 'local_efficiency' , 'clustering_coefficient' ])
92
+ x = RandomGraphAnalyzer (fc_matrix , n_rnd_graphs = ngraphs , analysis_type = 'sparsity ' , features = ['global_efficiency' , 'local_efficiency' , 'clustering_coefficient' ])
80
93
rgraphs = x .gen_random_graphs ()
81
94
print (len (rgraphs ))
82
95
print (len (rgraphs [0 ]))
83
96
x .compute_features ()
84
- x .plot_features ()
85
-
86
-
87
-
88
-
89
- # if __name__ == '__main__':
90
- # nnodes = 10
91
- # ngraphs = 1000
92
-
93
- # # plot the variation of global efficiency with sparsity from 0 to 1
94
- # sparsity = np.linspace(0, 1, 100)
95
-
96
- # global_efficiency_mean = []
97
- # global_efficiency_std = []
98
- # global_efficiency_fnirs = []
99
-
100
- # cluster_coef_mean = []
101
- # cluster_coef_std = []
102
- # cluster_coef_fnirs = []
103
-
104
- # fnirs_adj_matrix_stim_0 = np.loadtxt('output/stim_0_fc_mean.csv', delimiter=',')
105
- # # get min and max weights ignoring nan values
106
- # min_weight = np.nanmin(fnirs_adj_matrix_stim_0)
107
- # max_weight = np.nanmax(fnirs_adj_matrix_stim_0)
108
- # print('min weight: ', min_weight)
109
- # print('max weight: ', max_weight)
110
-
111
- # for s in sparsity:
112
- # ge_list = []
113
- # cc_list = []
114
- # for i in range(ngraphs):
115
- # adj_matrix = utils.RandomBinGraph(nnodes=nnodes, binarize_type='threshold', binarize_param=s).generate(min_weight=min_weight, max_weight=max_weight)
116
- # ge = bct.efficiency_bin(adj_matrix)
117
- # cc = np.mean(bct.clustering_coef_bu(adj_matrix))
118
- # ge_list.append(ge)
119
- # cc_list.append(cc)
120
-
121
- # ge_mean = np.mean(ge_list)
122
- # cc_mean = np.mean(cc_list)
123
- # ge_std = np.std(ge_list)
124
- # cc_std = np.std(cc_list)
125
-
126
- # global_efficiency_mean.append(ge_mean)
127
- # cluster_coef_mean.append(cc_mean)
128
- # global_efficiency_std.append(ge_std)
129
- # cluster_coef_std.append(cc_std)
130
- # global_efficiency_fnirs.append(bct.efficiency_bin(utils.BinarizeMatrix(fnirs_adj_matrix_stim_0, 'threshold', s).binarize()))
131
- # cluster_coef_fnirs.append(np.mean(bct.clustering_coef_bu(utils.BinarizeMatrix(fnirs_adj_matrix_stim_0, 'threshold', s).binarize())))
132
-
133
- # plt.errorbar(sparsity, global_efficiency_mean, yerr=global_efficiency_std, fmt='-o', capsize=3)
134
- # plt.plot(sparsity, global_efficiency_fnirs, '-o')
135
- # plt.xlabel('Sparsity')
136
- # plt.ylabel('Global Efficiency - Stim 0')
137
- # plt.legend(['fnirs data', 'random graph'])
138
- # plt.savefig('output/global_efficiency_stim_0.png')
139
-
140
- # plt.clf()
141
-
142
- # plt.errorbar(sparsity, cluster_coef_mean, yerr=cluster_coef_std, fmt='-o', capsize=3)
143
- # plt.plot(sparsity, cluster_coef_fnirs, '-o')
144
- # plt.xlabel('Sparsity')
145
- # plt.ylabel('Clustering Coefficient - Stim 0')
146
- # plt.legend(['fnirs data', 'random graph'])
147
- # plt.savefig('output/clustering_coef_stim_0.png')
97
+ x .plot_features ()
0 commit comments