scikit-network 0.31.0__cp39-cp39-win_amd64.whl → 0.33.0__cp39-cp39-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of scikit-network might be problematic. Click here for more details.
- {scikit_network-0.31.0.dist-info → scikit_network-0.33.0.dist-info}/AUTHORS.rst +3 -1
- {scikit_network-0.31.0.dist-info → scikit_network-0.33.0.dist-info}/METADATA +27 -5
- scikit_network-0.33.0.dist-info/RECORD +228 -0
- {scikit_network-0.31.0.dist-info → scikit_network-0.33.0.dist-info}/WHEEL +1 -1
- sknetwork/__init__.py +1 -1
- sknetwork/classification/base.py +1 -1
- sknetwork/classification/base_rank.py +3 -3
- sknetwork/classification/diffusion.py +25 -16
- sknetwork/classification/knn.py +23 -16
- sknetwork/classification/metrics.py +4 -4
- sknetwork/classification/pagerank.py +12 -8
- sknetwork/classification/propagation.py +25 -17
- sknetwork/classification/tests/test_diffusion.py +10 -0
- sknetwork/classification/vote.cp39-win_amd64.pyd +0 -0
- sknetwork/classification/vote.cpp +14549 -8668
- sknetwork/clustering/__init__.py +3 -1
- sknetwork/clustering/base.py +1 -1
- sknetwork/clustering/kcenters.py +253 -0
- sknetwork/clustering/leiden.py +242 -0
- sknetwork/clustering/leiden_core.cp39-win_amd64.pyd +0 -0
- sknetwork/clustering/leiden_core.cpp +31564 -0
- sknetwork/clustering/leiden_core.pyx +124 -0
- sknetwork/clustering/louvain.py +118 -83
- sknetwork/clustering/louvain_core.cp39-win_amd64.pyd +0 -0
- sknetwork/clustering/louvain_core.cpp +21876 -16332
- sknetwork/clustering/louvain_core.pyx +86 -94
- sknetwork/clustering/postprocess.py +2 -2
- sknetwork/clustering/propagation_clustering.py +4 -4
- sknetwork/clustering/tests/test_API.py +7 -3
- sknetwork/clustering/tests/test_kcenters.py +60 -0
- sknetwork/clustering/tests/test_leiden.py +34 -0
- sknetwork/clustering/tests/test_louvain.py +2 -3
- sknetwork/data/__init__.py +1 -1
- sknetwork/data/base.py +7 -2
- sknetwork/data/load.py +20 -25
- sknetwork/data/models.py +15 -15
- sknetwork/data/parse.py +57 -34
- sknetwork/data/tests/test_API.py +3 -3
- sknetwork/data/tests/test_base.py +2 -2
- sknetwork/data/tests/test_parse.py +9 -12
- sknetwork/data/tests/test_toy_graphs.py +33 -33
- sknetwork/data/toy_graphs.py +35 -43
- sknetwork/embedding/__init__.py +0 -1
- sknetwork/embedding/base.py +23 -19
- sknetwork/embedding/force_atlas.py +3 -2
- sknetwork/embedding/louvain_embedding.py +1 -27
- sknetwork/embedding/random_projection.py +5 -3
- sknetwork/embedding/spectral.py +0 -73
- sknetwork/embedding/svd.py +0 -4
- sknetwork/embedding/tests/test_API.py +4 -28
- sknetwork/embedding/tests/test_louvain_embedding.py +13 -13
- sknetwork/embedding/tests/test_spectral.py +2 -5
- sknetwork/embedding/tests/test_svd.py +7 -1
- sknetwork/gnn/base_layer.py +3 -3
- sknetwork/gnn/gnn_classifier.py +41 -87
- sknetwork/gnn/layer.py +1 -1
- sknetwork/gnn/loss.py +1 -1
- sknetwork/gnn/optimizer.py +4 -3
- sknetwork/gnn/tests/test_base_layer.py +4 -4
- sknetwork/gnn/tests/test_gnn_classifier.py +12 -39
- sknetwork/gnn/utils.py +8 -8
- sknetwork/hierarchy/base.py +27 -0
- sknetwork/hierarchy/louvain_hierarchy.py +55 -47
- sknetwork/hierarchy/paris.cp39-win_amd64.pyd +0 -0
- sknetwork/hierarchy/paris.cpp +27667 -20915
- sknetwork/hierarchy/paris.pyx +11 -10
- sknetwork/hierarchy/postprocess.py +16 -16
- sknetwork/hierarchy/tests/test_algos.py +5 -0
- sknetwork/hierarchy/tests/test_metrics.py +4 -4
- sknetwork/linalg/__init__.py +1 -1
- sknetwork/linalg/diteration.cp39-win_amd64.pyd +0 -0
- sknetwork/linalg/diteration.cpp +13916 -8050
- sknetwork/linalg/{normalization.py → normalizer.py} +17 -14
- sknetwork/linalg/operators.py +1 -1
- sknetwork/linalg/ppr_solver.py +1 -1
- sknetwork/linalg/push.cp39-win_amd64.pyd +0 -0
- sknetwork/linalg/push.cpp +23187 -16973
- sknetwork/linalg/tests/test_normalization.py +3 -7
- sknetwork/linalg/tests/test_operators.py +2 -6
- sknetwork/linalg/tests/test_ppr.py +1 -1
- sknetwork/linkpred/base.py +12 -1
- sknetwork/linkpred/nn.py +6 -6
- sknetwork/path/distances.py +11 -4
- sknetwork/path/shortest_path.py +1 -1
- sknetwork/path/tests/test_distances.py +7 -0
- sknetwork/path/tests/test_search.py +2 -2
- sknetwork/ranking/base.py +11 -6
- sknetwork/ranking/betweenness.cp39-win_amd64.pyd +0 -0
- sknetwork/ranking/betweenness.cpp +5256 -2190
- sknetwork/ranking/pagerank.py +13 -12
- sknetwork/ranking/tests/test_API.py +0 -2
- sknetwork/ranking/tests/test_betweenness.py +1 -1
- sknetwork/ranking/tests/test_pagerank.py +11 -5
- sknetwork/regression/base.py +18 -1
- sknetwork/regression/diffusion.py +30 -14
- sknetwork/regression/tests/test_diffusion.py +8 -0
- sknetwork/topology/__init__.py +3 -1
- sknetwork/topology/cliques.cp39-win_amd64.pyd +0 -0
- sknetwork/topology/cliques.cpp +23528 -16848
- sknetwork/topology/core.cp39-win_amd64.pyd +0 -0
- sknetwork/topology/core.cpp +22849 -16581
- sknetwork/topology/cycles.py +243 -0
- sknetwork/topology/minheap.cp39-win_amd64.pyd +0 -0
- sknetwork/topology/minheap.cpp +19495 -13469
- sknetwork/topology/structure.py +2 -42
- sknetwork/topology/tests/test_cycles.py +65 -0
- sknetwork/topology/tests/test_structure.py +2 -16
- sknetwork/topology/triangles.cp39-win_amd64.pyd +0 -0
- sknetwork/topology/triangles.cpp +5283 -1397
- sknetwork/topology/triangles.pyx +7 -4
- sknetwork/topology/weisfeiler_lehman_core.cp39-win_amd64.pyd +0 -0
- sknetwork/topology/weisfeiler_lehman_core.cpp +14781 -8915
- sknetwork/utils/__init__.py +1 -1
- sknetwork/utils/format.py +1 -1
- sknetwork/utils/membership.py +2 -2
- sknetwork/utils/values.py +5 -3
- sknetwork/visualization/__init__.py +2 -2
- sknetwork/visualization/dendrograms.py +55 -7
- sknetwork/visualization/graphs.py +261 -44
- sknetwork/visualization/tests/test_dendrograms.py +9 -9
- sknetwork/visualization/tests/test_graphs.py +63 -57
- scikit_network-0.31.0.dist-info/RECORD +0 -221
- sknetwork/embedding/louvain_hierarchy.py +0 -142
- sknetwork/embedding/tests/test_louvain_hierarchy.py +0 -19
- {scikit_network-0.31.0.dist-info → scikit_network-0.33.0.dist-info}/LICENSE +0 -0
- {scikit_network-0.31.0.dist-info → scikit_network-0.33.0.dist-info}/top_level.txt +0 -0
|
@@ -22,34 +22,34 @@ class LouvainIteration(BaseHierarchy):
|
|
|
22
22
|
|
|
23
23
|
Parameters
|
|
24
24
|
----------
|
|
25
|
-
depth :
|
|
25
|
+
depth : int
|
|
26
26
|
Depth of the tree.
|
|
27
27
|
A negative value is interpreted as no limit (return a tree of maximum depth).
|
|
28
|
-
resolution :
|
|
28
|
+
resolution : float
|
|
29
29
|
Resolution parameter.
|
|
30
|
-
tol_optimization :
|
|
30
|
+
tol_optimization : float
|
|
31
31
|
Minimum increase in the objective function to enter a new optimization pass.
|
|
32
|
-
tol_aggregation :
|
|
32
|
+
tol_aggregation : float
|
|
33
33
|
Minimum increase in the objective function to enter a new aggregation pass.
|
|
34
|
-
n_aggregations :
|
|
34
|
+
n_aggregations : int
|
|
35
35
|
Maximum number of aggregations.
|
|
36
36
|
A negative value is interpreted as no limit.
|
|
37
|
-
shuffle_nodes :
|
|
38
|
-
|
|
39
|
-
random_state :
|
|
37
|
+
shuffle_nodes : bool
|
|
38
|
+
If ``True``, shuffle nodes before optimization.
|
|
39
|
+
random_state : int
|
|
40
40
|
Random number generator or random seed. If ``None``, numpy.random is used.
|
|
41
|
-
verbose :
|
|
41
|
+
verbose : bool
|
|
42
42
|
Verbose mode.
|
|
43
43
|
|
|
44
44
|
Attributes
|
|
45
45
|
----------
|
|
46
|
-
dendrogram_ :
|
|
46
|
+
dendrogram_ : np.ndarray
|
|
47
47
|
Dendrogram of the graph.
|
|
48
|
-
dendrogram_row_ :
|
|
48
|
+
dendrogram_row_ : np.ndarray
|
|
49
49
|
Dendrogram for the rows, for bipartite graphs.
|
|
50
|
-
dendrogram_col_ :
|
|
50
|
+
dendrogram_col_ : np.ndarray
|
|
51
51
|
Dendrogram for the columns, for bipartite graphs.
|
|
52
|
-
dendrogram_full_ :
|
|
52
|
+
dendrogram_full_ : np.ndarray
|
|
53
53
|
Dendrogram for both rows and columns, indexed in this order, for bipartite graphs.
|
|
54
54
|
|
|
55
55
|
Example
|
|
@@ -59,10 +59,10 @@ class LouvainIteration(BaseHierarchy):
|
|
|
59
59
|
>>> louvain = LouvainIteration()
|
|
60
60
|
>>> adjacency = house()
|
|
61
61
|
>>> louvain.fit_predict(adjacency)
|
|
62
|
-
array([[3., 2.,
|
|
63
|
-
[4., 1.,
|
|
64
|
-
[6., 0.,
|
|
65
|
-
[5., 7.,
|
|
62
|
+
array([[3., 2., 1., 2.],
|
|
63
|
+
[4., 1., 1., 2.],
|
|
64
|
+
[6., 0., 1., 3.],
|
|
65
|
+
[5., 7., 2., 5.]])
|
|
66
66
|
|
|
67
67
|
Notes
|
|
68
68
|
-----
|
|
@@ -71,6 +71,7 @@ class LouvainIteration(BaseHierarchy):
|
|
|
71
71
|
See Also
|
|
72
72
|
--------
|
|
73
73
|
scipy.cluster.hierarchy.dendrogram
|
|
74
|
+
sknetwork.clustering.Louvain
|
|
74
75
|
"""
|
|
75
76
|
|
|
76
77
|
def __init__(self, depth: int = 3, resolution: float = 1, tol_optimization: float = 1e-3,
|
|
@@ -91,11 +92,11 @@ class LouvainIteration(BaseHierarchy):
|
|
|
91
92
|
|
|
92
93
|
Parameters
|
|
93
94
|
----------
|
|
94
|
-
adjacency :
|
|
95
|
+
adjacency : sparse.csr_matrix, np.ndarray
|
|
95
96
|
Adjacency matrix of the graph.
|
|
96
|
-
depth :
|
|
97
|
+
depth : int
|
|
97
98
|
Depth of the recursion.
|
|
98
|
-
nodes :
|
|
99
|
+
nodes : np.ndarray
|
|
99
100
|
The indices of the current nodes in the original graph.
|
|
100
101
|
|
|
101
102
|
Returns
|
|
@@ -127,25 +128,27 @@ class LouvainIteration(BaseHierarchy):
|
|
|
127
128
|
tree.append(self._recursive_louvain(adjacency_cluster, depth - 1, nodes_cluster))
|
|
128
129
|
return tree
|
|
129
130
|
|
|
130
|
-
def fit(self, input_matrix: Union[sparse.csr_matrix, np.ndarray])
|
|
131
|
+
def fit(self, input_matrix: Union[sparse.csr_matrix, np.ndarray], force_bipartite: bool = False) \
|
|
132
|
+
-> 'LouvainIteration':
|
|
131
133
|
"""Fit algorithm to data.
|
|
132
134
|
|
|
133
135
|
Parameters
|
|
134
136
|
----------
|
|
135
|
-
input_matrix :
|
|
137
|
+
input_matrix : sparse.csr_matrix, np.ndarray
|
|
136
138
|
Adjacency matrix or biadjacency matrix of the graph.
|
|
139
|
+
force_bipartite :
|
|
140
|
+
If ``True``, force the input matrix to be considered as a biadjacency matrix.
|
|
137
141
|
|
|
138
142
|
Returns
|
|
139
143
|
-------
|
|
140
144
|
self: :class:`LouvainIteration`
|
|
141
145
|
"""
|
|
142
146
|
self._init_vars()
|
|
143
|
-
|
|
144
|
-
adjacency, self.bipartite = get_adjacency(input_matrix)
|
|
147
|
+
adjacency, self.bipartite = get_adjacency(input_matrix, force_bipartite=force_bipartite)
|
|
145
148
|
tree = self._recursive_louvain(adjacency, self.depth)
|
|
146
149
|
dendrogram, _ = get_dendrogram(tree)
|
|
147
150
|
dendrogram = np.array(dendrogram)
|
|
148
|
-
dendrogram[:, 2]
|
|
151
|
+
dendrogram[:, 2] += 1 - min(dendrogram[:, 2])
|
|
149
152
|
self.dendrogram_ = reorder_dendrogram(dendrogram)
|
|
150
153
|
if self.bipartite:
|
|
151
154
|
self._split_vars(input_matrix.shape)
|
|
@@ -155,30 +158,32 @@ class LouvainIteration(BaseHierarchy):
|
|
|
155
158
|
class LouvainHierarchy(BaseHierarchy):
|
|
156
159
|
"""Hierarchical clustering by Louvain (bottom-up).
|
|
157
160
|
|
|
161
|
+
Each level corresponds to an aggregation step of the Louvain algorithm.
|
|
162
|
+
|
|
158
163
|
Parameters
|
|
159
164
|
----------
|
|
160
|
-
resolution :
|
|
165
|
+
resolution : float
|
|
161
166
|
Resolution parameter.
|
|
162
|
-
tol_optimization :
|
|
167
|
+
tol_optimization : float
|
|
163
168
|
Minimum increase in the objective function to enter a new optimization pass.
|
|
164
|
-
tol_aggregation :
|
|
169
|
+
tol_aggregation : float
|
|
165
170
|
Minimum increase in the objective function to enter a new aggregation pass.
|
|
166
|
-
shuffle_nodes :
|
|
167
|
-
|
|
168
|
-
random_state :
|
|
171
|
+
shuffle_nodes : bool
|
|
172
|
+
If ``True``, shuffle nodes before optimization.
|
|
173
|
+
random_state : int
|
|
169
174
|
Random number generator or random seed. If ``None``, numpy.random is used.
|
|
170
|
-
verbose :
|
|
175
|
+
verbose : bool
|
|
171
176
|
Verbose mode.
|
|
172
177
|
|
|
173
178
|
Attributes
|
|
174
179
|
----------
|
|
175
|
-
dendrogram_ :
|
|
180
|
+
dendrogram_ : np.ndarray
|
|
176
181
|
Dendrogram of the graph.
|
|
177
|
-
dendrogram_row_ :
|
|
182
|
+
dendrogram_row_ : np.ndarray
|
|
178
183
|
Dendrogram for the rows, for bipartite graphs.
|
|
179
|
-
dendrogram_col_ :
|
|
184
|
+
dendrogram_col_ : np.ndarray
|
|
180
185
|
Dendrogram for the columns, for bipartite graphs.
|
|
181
|
-
dendrogram_full_ :
|
|
186
|
+
dendrogram_full_ : np.ndarray
|
|
182
187
|
Dendrogram for both rows and columns, indexed in this order, for bipartite graphs.
|
|
183
188
|
|
|
184
189
|
Example
|
|
@@ -188,10 +193,10 @@ class LouvainHierarchy(BaseHierarchy):
|
|
|
188
193
|
>>> louvain = LouvainHierarchy()
|
|
189
194
|
>>> adjacency = house()
|
|
190
195
|
>>> louvain.fit_predict(adjacency)
|
|
191
|
-
array([[3., 2.,
|
|
192
|
-
[4., 1.,
|
|
193
|
-
[6., 0.,
|
|
194
|
-
[5., 7.,
|
|
196
|
+
array([[3., 2., 1., 2.],
|
|
197
|
+
[4., 1., 1., 2.],
|
|
198
|
+
[6., 0., 1., 3.],
|
|
199
|
+
[5., 7., 2., 5.]])
|
|
195
200
|
|
|
196
201
|
Notes
|
|
197
202
|
-----
|
|
@@ -200,6 +205,7 @@ class LouvainHierarchy(BaseHierarchy):
|
|
|
200
205
|
See Also
|
|
201
206
|
--------
|
|
202
207
|
scipy.cluster.hierarchy.dendrogram
|
|
208
|
+
sknetwork.clustering.Louvain
|
|
203
209
|
"""
|
|
204
210
|
|
|
205
211
|
def __init__(self, resolution: float = 1, tol_optimization: float = 1e-3,
|
|
@@ -218,7 +224,7 @@ class LouvainHierarchy(BaseHierarchy):
|
|
|
218
224
|
|
|
219
225
|
Parameters
|
|
220
226
|
----------
|
|
221
|
-
adjacency :
|
|
227
|
+
adjacency : sparse.csr_matrix, np.ndarray
|
|
222
228
|
Adjacency matrix of the graph.
|
|
223
229
|
|
|
224
230
|
Returns
|
|
@@ -239,25 +245,27 @@ class LouvainHierarchy(BaseHierarchy):
|
|
|
239
245
|
labels_unique = np.unique(labels)
|
|
240
246
|
return tree
|
|
241
247
|
|
|
242
|
-
def fit(self, input_matrix: Union[sparse.csr_matrix, np.ndarray])
|
|
248
|
+
def fit(self, input_matrix: Union[sparse.csr_matrix, np.ndarray], force_bipartite: bool = False) \
|
|
249
|
+
-> 'LouvainHierarchy':
|
|
243
250
|
"""Fit algorithm to data.
|
|
244
251
|
|
|
245
252
|
Parameters
|
|
246
253
|
----------
|
|
247
|
-
input_matrix :
|
|
254
|
+
input_matrix : sparse.csr_matrix, np.ndarray
|
|
248
255
|
Adjacency matrix or biadjacency matrix of the graph.
|
|
256
|
+
force_bipartite :
|
|
257
|
+
If ``True``, force the input matrix to be considered as a biadjacency matrix.
|
|
249
258
|
|
|
250
259
|
Returns
|
|
251
260
|
-------
|
|
252
|
-
self: :class:`
|
|
261
|
+
self: :class:`LouvainHierarchy`
|
|
253
262
|
"""
|
|
254
263
|
self._init_vars()
|
|
255
|
-
|
|
256
|
-
adjacency, self.bipartite = get_adjacency(input_matrix)
|
|
264
|
+
adjacency, self.bipartite = get_adjacency(input_matrix, force_bipartite=force_bipartite)
|
|
257
265
|
tree = self._get_hierarchy(adjacency)
|
|
258
266
|
dendrogram, _ = get_dendrogram(tree)
|
|
259
267
|
dendrogram = np.array(dendrogram)
|
|
260
|
-
dendrogram[:, 2]
|
|
268
|
+
dendrogram[:, 2] += 1 - min(dendrogram[:, 2])
|
|
261
269
|
self.dendrogram_ = reorder_dendrogram(dendrogram)
|
|
262
270
|
if self.bipartite:
|
|
263
271
|
self._split_vars(input_matrix.shape)
|
|
Binary file
|