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
FEA Add Nonnegative LinearRegression #17578
FEA Add Nonnegative LinearRegression #17578
Conversation
…ugh `positive` parameter. Similar to PR scikit-learn#8428, but adds parameters (`positive` and `max_iter`) to `LinearRegression` consistent with `Lasso` and `ElasticNet`. Uses `scipy.optimize.nnls` under the hood. **note** `scipy.optimize.nnls` cannot accept a sparse matrix for `X` or `y`. Passing sparse `X` throws error through `check_X_y`.
Remove `max_iter` parameter since `scipy.optimize.nnls` does not return `n_iter`.
Remove `_residues` attribute and unnecessary `np.ravel()`.
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.
As per my previous comments:
This needs to appear in the user guide. Maybe also add an example, as here?
You will also need to add a mention indoc/whats_new/v0.24.rst
.
positive
parameter.positive
parameter.
positive
parameter.positive
parameter.
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.
thanks @cmarmo , mostly looks good
I think we could also have a test showing that we get different results when positive is True vs False
Co-authored-by: Nicolas Hug <contact@nicolas-hug.com>
Co-authored-by: Nicolas Hug <contact@nicolas-hug.com>
Co-authored-by: Nicolas Hug <contact@nicolas-hug.com>
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.
Thanks @cmarmo , made another pass but mostly looks good
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 wouldn't mind a test showing positive=False/True makes no difference if positive=False already gets all non-negative coefficients.
But LGTM.
@jnothman, I have added the test. |
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.
Thanks @cmarmo , minor comments but LGTM
positive
parameter.Co-authored-by: Nicolas Hug <contact@nicolas-hug.com> Co-authored-by: Joseph Knox <jknox13@uw.edu> Co-authored-by: Joseph Knox <joseph.edward.knox@gmail.com>
Reference Issues/PRs
Fixes #8191. Resolves #11076, resolve #8428
What does this implement/fix? Explain your changes.
Adds parameters (positive and
maxiter) toLinearRegression
consistent with Lasso and ElasticNet.Any other comments?
#11076 was already approved by @TomDLT , I think I have addressed @rth comments.
Still missing