-
-
Notifications
You must be signed in to change notification settings - Fork 26k
[MRG+1] copy not passed from linear_model/base.py:_pre_fit to _preprocess_data #9347
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
[MRG+1] copy not passed from linear_model/base.py:_pre_fit to _preprocess_data #9347
Conversation
…a in the sparse case
sklearn/linear_model/base.py
Outdated
@@ -523,7 +523,7 @@ def _pre_fit(X, y, Xy, precompute, normalize, fit_intercept, copy): | |||
precompute = False | |||
X, y, X_offset, y_offset, X_scale = _preprocess_data( | |||
X, y, fit_intercept=fit_intercept, normalize=normalize, | |||
return_mean=True) | |||
copy=copy, return_mean=True) |
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.
I suspect you should never copy for a sparse matrix as X will not be densified hence modified anyway. So copy should be False all the time. Can you check?
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, got it. Let me change to copy=False.
Read through this now
copy : boolean (default=False)
Whether a forced copy will be triggered. If copy=False, a copy might
be triggered by a conversion.
LGTM +1 for MRG |
why |
because if you pass copy=True it makes a copy of X although X is not modified inplace when X is sparse. clear? |
@agramfort not really clear unless you go read the code of the |
+1 to add a comment of why this is False here.
|
Added a comment. |
thx @bmanohar16 |
…cess_data (scikit-learn#9347) * copy not passed from linear_model/base.py:_pre_fit to _preprocess_data in the sparse case * Pass copy as False for sparse matrix to _preprocess_data * Add comment with reason for copy=False
…cess_data (scikit-learn#9347) * copy not passed from linear_model/base.py:_pre_fit to _preprocess_data in the sparse case * Pass copy as False for sparse matrix to _preprocess_data * Add comment with reason for copy=False
…cess_data (scikit-learn#9347) * copy not passed from linear_model/base.py:_pre_fit to _preprocess_data in the sparse case * Pass copy as False for sparse matrix to _preprocess_data * Add comment with reason for copy=False
…cess_data (scikit-learn#9347) * copy not passed from linear_model/base.py:_pre_fit to _preprocess_data in the sparse case * Pass copy as False for sparse matrix to _preprocess_data * Add comment with reason for copy=False
…cess_data (scikit-learn#9347) * copy not passed from linear_model/base.py:_pre_fit to _preprocess_data in the sparse case * Pass copy as False for sparse matrix to _preprocess_data * Add comment with reason for copy=False
…cess_data (scikit-learn#9347) * copy not passed from linear_model/base.py:_pre_fit to _preprocess_data in the sparse case * Pass copy as False for sparse matrix to _preprocess_data * Add comment with reason for copy=False
…cess_data (scikit-learn#9347) * copy not passed from linear_model/base.py:_pre_fit to _preprocess_data in the sparse case * Pass copy as False for sparse matrix to _preprocess_data * Add comment with reason for copy=False
…cess_data (scikit-learn#9347) * copy not passed from linear_model/base.py:_pre_fit to _preprocess_data in the sparse case * Pass copy as False for sparse matrix to _preprocess_data * Add comment with reason for copy=False
Reference Issue
Fixes #9345
What does this implement/fix? Explain your changes.
Added copy parameter to _preprocess_data method
Fixes issue discussed in lgtmhq/lgtm-queries#14