-
-
Notifications
You must be signed in to change notification settings - Fork 26.2k
[MRG] Change the default of precompute from "auto" to False #3249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
from .base import LinearModel, _pre_fit | ||
from ..base import RegressorMixin | ||
from .base import center_data, sparse_center_data | ||
from ..utils import check_array | ||
from ..utils import check_array, check_X_y | ||
from ..utils.validation import check_random_state | ||
from ..cross_validation import _check_cv as check_cv | ||
from ..externals.joblib import Parallel, delayed | ||
|
@@ -604,6 +604,8 @@ class ElasticNet(LinearModel, RegressorMixin): | |
calculations. If set to ``'auto'`` let us decide. The Gram | ||
matrix can also be passed as argument. For sparse input | ||
this option is always ``True`` to preserve sparsity. | ||
WARNING : The ``'auto'`` option is deprecated and will | ||
be removed in 0.18. | ||
|
||
max_iter : int, optional | ||
The maximum number of iterations | ||
|
@@ -665,7 +667,7 @@ class ElasticNet(LinearModel, RegressorMixin): | |
path = staticmethod(enet_path) | ||
|
||
def __init__(self, alpha=1.0, l1_ratio=0.5, fit_intercept=True, | ||
normalize=False, precompute='auto', max_iter=1000, | ||
normalize=False, precompute=False, max_iter=1000, | ||
copy_X=True, tol=1e-4, warm_start=False, positive=False, | ||
random_state=None, selection='cyclic'): | ||
self.alpha = alpha | ||
|
@@ -708,10 +710,16 @@ def fit(self, X, y): | |
warnings.warn("With alpha=0, this algorithm does not converge " | ||
"well. You are advised to use the LinearRegression " | ||
"estimator", stacklevel=2) | ||
X = check_array(X, 'csc', dtype=np.float64, order='F', copy=self.copy_X | ||
and self.fit_intercept) | ||
# From now on X can be touched inplace | ||
y = np.asarray(y, dtype=np.float64) | ||
|
||
if self.precompute == 'auto': | ||
warnings.warn("Setting precompute to 'auto', was found to be " | ||
"slower even when n_samples > n_features. Hence " | ||
"it will be removed in 0.18.", | ||
DeprecationWarning, stacklevel=2) | ||
|
||
X, y = check_X_y(X, y, accept_sparse='csc', dtype=np.float64, | ||
order='F', copy=self.copy_X and self.fit_intercept, | ||
multi_output=True) | ||
|
||
X, y, X_mean, y_mean, X_std, precompute, Xy = \ | ||
_pre_fit(X, y, None, self.precompute, self.normalize, | ||
|
@@ -830,6 +838,8 @@ class Lasso(ElasticNet): | |
calculations. If set to ``'auto'`` let us decide. The Gram | ||
matrix can also be passed as argument. For sparse input | ||
this option is always ``True`` to preserve sparsity. | ||
WARNING : The ``'auto'`` option is deprecated and will | ||
be removed in 0.18. | ||
|
||
max_iter : int, optional | ||
The maximum number of iterations | ||
|
@@ -880,7 +890,7 @@ class Lasso(ElasticNet): | |
>>> clf = linear_model.Lasso(alpha=0.1) | ||
>>> clf.fit([[0,0], [1, 1], [2, 2]], [0, 1, 2]) | ||
Lasso(alpha=0.1, copy_X=True, fit_intercept=True, max_iter=1000, | ||
normalize=False, positive=False, precompute='auto', random_state=None, | ||
normalize=False, positive=False, precompute=False, random_state=None, | ||
selection='cyclic', tol=0.0001, warm_start=False) | ||
>>> print(clf.coef_) | ||
[ 0.85 0. ] | ||
|
@@ -906,7 +916,7 @@ class Lasso(ElasticNet): | |
path = staticmethod(enet_path) | ||
|
||
def __init__(self, alpha=1.0, fit_intercept=True, normalize=False, | ||
precompute='auto', copy_X=True, max_iter=1000, | ||
precompute=False, copy_X=True, max_iter=1000, | ||
tol=1e-4, warm_start=False, positive=False, | ||
random_state=None, selection='cyclic'): | ||
super(Lasso, self).__init__( | ||
|
@@ -1207,6 +1217,7 @@ def fit(self, X, y): | |
model.alpha = best_alpha | ||
model.l1_ratio = best_l1_ratio | ||
model.copy_X = copy_X | ||
model.precompute = False | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the last fit.
This is basically to make the last fit as fast as possible. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok got it. |
||
model.fit(X, y) | ||
if not hasattr(self, 'l1_ratio'): | ||
del self.l1_ratio_ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why 0.18?
I would raise the warning in 0.16 and remove in 0.17
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok I thought the warnings were for two versions ;)