Skip to content

Commit

Permalink
Fix sklearn.cross_decomposition.test_pls.test_scale_and_stability
Browse files Browse the repository at this point in the history
  • Loading branch information
lesteve committed May 3, 2016
1 parent e04ec78 commit bc5b670
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sklearn/cross_decomposition/pls_.py
Expand Up @@ -53,6 +53,11 @@ def _nipals_twoblocks_inner_loop(X, Y, mode="A", max_iter=500, tol=1e-06,
else: # mode A
# Mode A regress each X column on y_score
x_weights = np.dot(X.T, y_score) / np.dot(y_score.T, y_score)
# If y_score only has zeros x_weights will only have zeros. In
# this case add an epsilon to converge to a more acceptable
# solution
if np.dot(x_weights.T, x_weights) < eps:
x_weights += eps
# 1.2 Normalize u
x_weights /= np.sqrt(np.dot(x_weights.T, x_weights)) + eps
# 1.3 Update x_score: the X latent scores
Expand Down

0 comments on commit bc5b670

Please sign in to comment.