|
8 | 8 | # License: BSD 3 clause |
9 | 9 | import itertools |
10 | 10 | from abc import ABCMeta, abstractmethod |
| 11 | +import warnings |
11 | 12 |
|
12 | 13 | import numpy as np |
13 | 14 | from scipy.sparse import issparse |
|
19 | 20 | from ..externals import six |
20 | 21 | from ..externals.joblib import Memory, Parallel, delayed |
21 | 22 | from ..utils import (as_float_array, check_random_state, safe_asarray, |
22 | | - check_arrays, safe_mask) |
| 23 | + check_arrays, safe_mask, ConvergenceWarning) |
23 | 24 | from .least_angle import lars_path, LassoLarsIC |
24 | 25 | from .logistic import LogisticRegression |
25 | 26 |
|
@@ -158,11 +159,13 @@ def _randomized_lasso(X, y, weights, mask, alpha=1., verbose=False, |
158 | 159 | alpha = np.atleast_1d(np.asarray(alpha, dtype=np.float)) |
159 | 160 |
|
160 | 161 | X = (1 - weights) * X |
161 | | - alphas_, _, coef_ = lars_path(X, y, |
162 | | - Gram=precompute, copy_X=False, |
163 | | - copy_Gram=False, alpha_min=np.min(alpha), |
164 | | - method='lasso', verbose=verbose, |
165 | | - max_iter=max_iter, eps=eps) |
| 162 | + with warnings.catch_warnings(): |
| 163 | + warnings.simplefilter('ignore', ConvergenceWarning) |
| 164 | + alphas_, _, coef_ = lars_path(X, y, |
| 165 | + Gram=precompute, copy_X=False, |
| 166 | + copy_Gram=False, alpha_min=np.min(alpha), |
| 167 | + method='lasso', verbose=verbose, |
| 168 | + max_iter=max_iter, eps=eps) |
166 | 169 |
|
167 | 170 | if len(alpha) > 1: |
168 | 171 | if len(alphas_) > 1: # np.min(alpha) < alpha_min |
@@ -504,8 +507,10 @@ def _lasso_stability_path(X, y, mask, weights, eps): |
504 | 507 |
|
505 | 508 | alpha_max = np.max(np.abs(np.dot(X.T, y))) / X.shape[0] |
506 | 509 | alpha_min = eps * alpha_max # set for early stopping in path |
507 | | - alphas, _, coefs = lars_path(X, y, method='lasso', verbose=False, |
508 | | - alpha_min=alpha_min) |
| 510 | + with warnings.catch_warnings(): |
| 511 | + warnings.simplefilter('ignore', ConvergenceWarning) |
| 512 | + alphas, _, coefs = lars_path(X, y, method='lasso', verbose=False, |
| 513 | + alpha_min=alpha_min) |
509 | 514 | # Scale alpha by alpha_max |
510 | 515 | alphas /= alphas[0] |
511 | 516 | # Sort alphas in assending order |
|
0 commit comments