Skip to content

Commit 1d724ec

Browse files
committed
revert changes to label_propagation _build_graph which are now in gh31924
1 parent b17feb6 commit 1d724ec

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

sklearn/semi_supervised/_label_propagation.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -463,15 +463,7 @@ class distributions will exceed 1 (normalization may be desired).
463463
affinity_matrix = self._get_kernel(self.X_)
464464
normalizer = affinity_matrix.sum(axis=0)
465465
if sparse.issparse(affinity_matrix):
466-
normalizer = np.array(normalizer) # convert np.matrix to np.array
467-
if normalizer.ndim == 2:
468-
# old spmatrix treatment. RHS is a scalar (b/c normalizer is 2D row)
469-
affinity_matrix.data /= np.diag(normalizer)
470-
else:
471-
# We could use the (questionable) spmatrix treatment using:
472-
# affinity_matrix.data /= np.diag(np.array(normalizer[np.newaxis, :]))
473-
# Instead: use numpy treatment dividing each row by its normalizer.
474-
affinity_matrix.data /= normalizer[affinity_matrix.indices]
466+
affinity_matrix.data /= np.diag(np.array(normalizer))
475467
else:
476468
affinity_matrix /= normalizer[:, np.newaxis]
477469
return affinity_matrix

0 commit comments

Comments
 (0)