FEA Add Nonnegative LinearRegression #17578
Merged
Conversation
…e` parameter. Similar to PR #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()`.
positive parameter.positive parameter.
positive parameter.positive parameter.
|
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>
|
Thanks @cmarmo , made another pass but mostly looks good |
|
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. |
|
Thanks @cmarmo , minor comments but LGTM |
positive parameter.075d424
into
scikit-learn:master
21 checks passed
21 checks passed
scikit-learn.scikit-learn (Linux pylatest_pip_openblas_pandas)
Linux pylatest_pip_openblas_pandas succeeded
Details
scikit-learn.scikit-learn (Linux32 py36_ubuntu_atlas_32bit)
Linux32 py36_ubuntu_atlas_32bit succeeded
Details
scikit-learn.scikit-learn (Linux_Runs pylatest_conda_mkl)
Linux_Runs pylatest_conda_mkl succeeded
Details
scikit-learn.scikit-learn (Windows py36_pip_openblas_32bit)
Windows py36_pip_openblas_32bit succeeded
Details
scikit-learn.scikit-learn (macOS pylatest_conda_mkl_no_openmp)
macOS pylatest_conda_mkl_no_openmp succeeded
Details
jayzed82
added a commit
to jayzed82/scikit-learn
that referenced
this pull request
Oct 22, 2020
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>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Reference Issues/PRs
Fixes #8191. Resolves #11076, resolve #8428
What does this implement/fix? Explain your changes.
Adds parameters (positive and
maxiter) toLinearRegressionconsistent with Lasso and ElasticNet.Any other comments?
#11076 was already approved by @TomDLT , I think I have addressed @rth comments.
Still missing