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.

Files changed (126) hide show
  1. {scikit_network-0.31.0.dist-info → scikit_network-0.33.0.dist-info}/AUTHORS.rst +3 -1
  2. {scikit_network-0.31.0.dist-info → scikit_network-0.33.0.dist-info}/METADATA +27 -5
  3. scikit_network-0.33.0.dist-info/RECORD +228 -0
  4. {scikit_network-0.31.0.dist-info → scikit_network-0.33.0.dist-info}/WHEEL +1 -1
  5. sknetwork/__init__.py +1 -1
  6. sknetwork/classification/base.py +1 -1
  7. sknetwork/classification/base_rank.py +3 -3
  8. sknetwork/classification/diffusion.py +25 -16
  9. sknetwork/classification/knn.py +23 -16
  10. sknetwork/classification/metrics.py +4 -4
  11. sknetwork/classification/pagerank.py +12 -8
  12. sknetwork/classification/propagation.py +25 -17
  13. sknetwork/classification/tests/test_diffusion.py +10 -0
  14. sknetwork/classification/vote.cp39-win_amd64.pyd +0 -0
  15. sknetwork/classification/vote.cpp +14549 -8668
  16. sknetwork/clustering/__init__.py +3 -1
  17. sknetwork/clustering/base.py +1 -1
  18. sknetwork/clustering/kcenters.py +253 -0
  19. sknetwork/clustering/leiden.py +242 -0
  20. sknetwork/clustering/leiden_core.cp39-win_amd64.pyd +0 -0
  21. sknetwork/clustering/leiden_core.cpp +31564 -0
  22. sknetwork/clustering/leiden_core.pyx +124 -0
  23. sknetwork/clustering/louvain.py +118 -83
  24. sknetwork/clustering/louvain_core.cp39-win_amd64.pyd +0 -0
  25. sknetwork/clustering/louvain_core.cpp +21876 -16332
  26. sknetwork/clustering/louvain_core.pyx +86 -94
  27. sknetwork/clustering/postprocess.py +2 -2
  28. sknetwork/clustering/propagation_clustering.py +4 -4
  29. sknetwork/clustering/tests/test_API.py +7 -3
  30. sknetwork/clustering/tests/test_kcenters.py +60 -0
  31. sknetwork/clustering/tests/test_leiden.py +34 -0
  32. sknetwork/clustering/tests/test_louvain.py +2 -3
  33. sknetwork/data/__init__.py +1 -1
  34. sknetwork/data/base.py +7 -2
  35. sknetwork/data/load.py +20 -25
  36. sknetwork/data/models.py +15 -15
  37. sknetwork/data/parse.py +57 -34
  38. sknetwork/data/tests/test_API.py +3 -3
  39. sknetwork/data/tests/test_base.py +2 -2
  40. sknetwork/data/tests/test_parse.py +9 -12
  41. sknetwork/data/tests/test_toy_graphs.py +33 -33
  42. sknetwork/data/toy_graphs.py +35 -43
  43. sknetwork/embedding/__init__.py +0 -1
  44. sknetwork/embedding/base.py +23 -19
  45. sknetwork/embedding/force_atlas.py +3 -2
  46. sknetwork/embedding/louvain_embedding.py +1 -27
  47. sknetwork/embedding/random_projection.py +5 -3
  48. sknetwork/embedding/spectral.py +0 -73
  49. sknetwork/embedding/svd.py +0 -4
  50. sknetwork/embedding/tests/test_API.py +4 -28
  51. sknetwork/embedding/tests/test_louvain_embedding.py +13 -13
  52. sknetwork/embedding/tests/test_spectral.py +2 -5
  53. sknetwork/embedding/tests/test_svd.py +7 -1
  54. sknetwork/gnn/base_layer.py +3 -3
  55. sknetwork/gnn/gnn_classifier.py +41 -87
  56. sknetwork/gnn/layer.py +1 -1
  57. sknetwork/gnn/loss.py +1 -1
  58. sknetwork/gnn/optimizer.py +4 -3
  59. sknetwork/gnn/tests/test_base_layer.py +4 -4
  60. sknetwork/gnn/tests/test_gnn_classifier.py +12 -39
  61. sknetwork/gnn/utils.py +8 -8
  62. sknetwork/hierarchy/base.py +27 -0
  63. sknetwork/hierarchy/louvain_hierarchy.py +55 -47
  64. sknetwork/hierarchy/paris.cp39-win_amd64.pyd +0 -0
  65. sknetwork/hierarchy/paris.cpp +27667 -20915
  66. sknetwork/hierarchy/paris.pyx +11 -10
  67. sknetwork/hierarchy/postprocess.py +16 -16
  68. sknetwork/hierarchy/tests/test_algos.py +5 -0
  69. sknetwork/hierarchy/tests/test_metrics.py +4 -4
  70. sknetwork/linalg/__init__.py +1 -1
  71. sknetwork/linalg/diteration.cp39-win_amd64.pyd +0 -0
  72. sknetwork/linalg/diteration.cpp +13916 -8050
  73. sknetwork/linalg/{normalization.py → normalizer.py} +17 -14
  74. sknetwork/linalg/operators.py +1 -1
  75. sknetwork/linalg/ppr_solver.py +1 -1
  76. sknetwork/linalg/push.cp39-win_amd64.pyd +0 -0
  77. sknetwork/linalg/push.cpp +23187 -16973
  78. sknetwork/linalg/tests/test_normalization.py +3 -7
  79. sknetwork/linalg/tests/test_operators.py +2 -6
  80. sknetwork/linalg/tests/test_ppr.py +1 -1
  81. sknetwork/linkpred/base.py +12 -1
  82. sknetwork/linkpred/nn.py +6 -6
  83. sknetwork/path/distances.py +11 -4
  84. sknetwork/path/shortest_path.py +1 -1
  85. sknetwork/path/tests/test_distances.py +7 -0
  86. sknetwork/path/tests/test_search.py +2 -2
  87. sknetwork/ranking/base.py +11 -6
  88. sknetwork/ranking/betweenness.cp39-win_amd64.pyd +0 -0
  89. sknetwork/ranking/betweenness.cpp +5256 -2190
  90. sknetwork/ranking/pagerank.py +13 -12
  91. sknetwork/ranking/tests/test_API.py +0 -2
  92. sknetwork/ranking/tests/test_betweenness.py +1 -1
  93. sknetwork/ranking/tests/test_pagerank.py +11 -5
  94. sknetwork/regression/base.py +18 -1
  95. sknetwork/regression/diffusion.py +30 -14
  96. sknetwork/regression/tests/test_diffusion.py +8 -0
  97. sknetwork/topology/__init__.py +3 -1
  98. sknetwork/topology/cliques.cp39-win_amd64.pyd +0 -0
  99. sknetwork/topology/cliques.cpp +23528 -16848
  100. sknetwork/topology/core.cp39-win_amd64.pyd +0 -0
  101. sknetwork/topology/core.cpp +22849 -16581
  102. sknetwork/topology/cycles.py +243 -0
  103. sknetwork/topology/minheap.cp39-win_amd64.pyd +0 -0
  104. sknetwork/topology/minheap.cpp +19495 -13469
  105. sknetwork/topology/structure.py +2 -42
  106. sknetwork/topology/tests/test_cycles.py +65 -0
  107. sknetwork/topology/tests/test_structure.py +2 -16
  108. sknetwork/topology/triangles.cp39-win_amd64.pyd +0 -0
  109. sknetwork/topology/triangles.cpp +5283 -1397
  110. sknetwork/topology/triangles.pyx +7 -4
  111. sknetwork/topology/weisfeiler_lehman_core.cp39-win_amd64.pyd +0 -0
  112. sknetwork/topology/weisfeiler_lehman_core.cpp +14781 -8915
  113. sknetwork/utils/__init__.py +1 -1
  114. sknetwork/utils/format.py +1 -1
  115. sknetwork/utils/membership.py +2 -2
  116. sknetwork/utils/values.py +5 -3
  117. sknetwork/visualization/__init__.py +2 -2
  118. sknetwork/visualization/dendrograms.py +55 -7
  119. sknetwork/visualization/graphs.py +261 -44
  120. sknetwork/visualization/tests/test_dendrograms.py +9 -9
  121. sknetwork/visualization/tests/test_graphs.py +63 -57
  122. scikit_network-0.31.0.dist-info/RECORD +0 -221
  123. sknetwork/embedding/louvain_hierarchy.py +0 -142
  124. sknetwork/embedding/tests/test_louvain_hierarchy.py +0 -19
  125. {scikit_network-0.31.0.dist-info → scikit_network-0.33.0.dist-info}/LICENSE +0 -0
  126. {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
- Enables node shuffling before optimization.
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., 0., 2.],
63
- [4., 1., 0., 2.],
64
- [6., 0., 0., 3.],
65
- [5., 7., 1., 5.]])
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]) -> 'LouvainIteration':
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
- input_matrix = check_format(input_matrix)
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] -= min(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
- Enables node shuffling before optimization.
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., 0., 2.],
192
- [4., 1., 0., 2.],
193
- [6., 0., 0., 3.],
194
- [5., 7., 1., 5.]])
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]) -> 'LouvainHierarchy':
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:`LouvainIteration`
261
+ self: :class:`LouvainHierarchy`
253
262
  """
254
263
  self._init_vars()
255
- input_matrix = check_format(input_matrix)
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] -= min(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)