8000 Apply pylint fixes in extmath to randomized_pca · scikit-learn/scikit-learn@f39254e · GitHub
[go: up one dir, main page]

Skip to content

Commit f39254e

Browse files
Apply pylint fixes in extmath to randomized_pca
1 parent 46c2540 commit f39254e

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

sklearn/utils/extmath.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,8 @@ def randomized_pca(A, n_components, n_oversamples=10, n_iter="auto",
440440
"""
441441
if n_iter == "auto":
442442
# Checks if the number of iterations is explicitly specified
443-
# Adjust n_iter. 7 was found a good compromise for PCA. See sklearn #5299
443+
# Adjust n_iter. 7 was found a good compromise for PCA.
444+
# See sklearn #5299
444445
n_iter = 7 if n_components < .1 * min(A.shape) else 4
445446

446447
# Deal with "auto" mode
@@ -464,30 +465,36 @@ def randomized_pca(A, n_components, n_oversamples=10, n_iter="auto",
464465

465466
# Normalized power iterations
466467
for _ in range(n_iter):
467-
Q = safe_sparse_dot(A.T, Q) - safe_sparse_dot(c.T, Q.sum(axis=0)[None, :])
468+
Q = safe_sparse_dot(A.T, Q) - \
469+
safe_sparse_dot(c.T, Q.sum(axis=0)[None, :])
468470
Q = _normalize_power_iteration(Q, power_iteration_normalizer)
469471
Q = safe_sparse_dot(A, Q) - safe_sparse_dot(c, Q)
470472
Q = _normalize_power_iteration(Q, power_iteration_normalizer)
471473

472474
Q, _ = linalg.qr(Q, mode="economic")
473475

474-
QA = safe_sparse_dot(A.T, Q) - safe_sparse_dot(c.T, Q.sum(axis=0)[None, :])
476+
QA = safe_sparse_dot(A.T, Q) - \
477+
safe_sparse_dot(c.T, Q.sum(axis=0)[None, :])
475478
R, s, V = linalg.svd(QA.T, full_matrices=False)
476479
U = Q.dot(R)
477480

478481
else: # n_features > n_samples
479-
Q = random_state.normal(size=(n_samples, n_components + n_oversamples))
482+
Q = random_state.normal(
483+
size=(n_samples, n_components + n_oversamples)
484+
)
480485
if A.dtype.kind == "f":
481486
# Ensure f32 is preserved as f32
482487
Q = Q.astype(A.dtype, copy=False)
483488

484-
Q = safe_sparse_dot(A.T, Q) - safe_sparse_dot(c.T, Q.sum(axis=0)[None, :])
489+
Q = safe_sparse_dot(A.T, Q) - \
490+
safe_sparse_dot(c.T, Q.sum(axis=0)[None, :])
485491

486492
# Normalized power iterations
487493
for _ in range(n_iter):
488494
Q = safe_sparse_dot(A, Q) - safe_sparse_dot(c, Q)
489495
Q = _normalize_power_iteration(Q, power_iteration_normalizer)
490-
Q = safe_sparse_dot(A.T, Q) - safe_sparse_dot(c.T, Q.sum(axis=0)[None, :])
496+
Q = safe_sparse_dot(A.T, Q) - \
497+
safe_sparse_dot(c.T, Q.sum(axis=0)[None, :])
491498
Q = _normalize_power_iteration(Q, power_iteration_normalizer)
492499

493500
Q, _ = linalg.qr(Q, mode="economic")

0 commit comments

Comments
 (0)
0