Skip to content
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

FIX #13117: Remove multiple output from LinearModelCV doc #13131

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

albertotb
Copy link
Contributor

Reference Issues/PRs

Fixes #13117

What does this implement/fix? Explain your changes.

Fixes documentation of class LinearModelCV(), since it there is a check that
does not allow y to have more than 1 dimension (multiple outputs)

Any other comments?

I thinks this could be improved, since both ElasticNet() and Lasso() support multiple targets. I don't see a reason why LinearModelCV() could not accept multiple targets as well.

@albertotb albertotb changed the title Remove multiple output from LinearModelCV doc FIX #13117: Remove multiple output from LinearModelCV doc Feb 11, 2019
@@ -1084,7 +1084,7 @@ def fit(self, X, y):
to avoid unnecessary memory duplication. If y is mono-output,
X can be sparse.

y : array-like, shape (n_samples,) or (n_samples, n_targets)
y : array-like, shape (n_samples,)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also used by MultiTask{Lasso,ElasticNet}CV so it is now more inaccurate than before!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then maybe instead of removing or (n_samples, n_targets), add to the description something like:

- shape (n_samples,) is valid for `ElasticNetCV` and `LassoCV`.
- shape (n_samples, n_targets) is valid for `MultiTaskElasticNetCV` and `MultitaskLassoCV`.

?

Copy link
Contributor Author

@albertotb albertotb Feb 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Now I understand why {Lasso,ElasticNet}CV do not support multiple outputs. To fix this I can think of two ways:

  • different documentation for MultiTask/standard
  • different classes LinearModelCV, MultiTaskLinearModelCV so multiple outputs are also supported.

Edit: @adrinjalali that also works, I think it is probably better to change n_targets by n_tasks, as in MultiTaskElasticNet

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adrinjalali I just updated the doc with @adrinjalali suggestion. We can maybe open a new PR for extending multioutput to {Lasso,ElasticNet}CV

sklearn/linear_model/coordinate_descent.py Outdated Show resolved Hide resolved
@@ -1086,7 +1086,7 @@ def fit(self, X, y):

y : array-like, shape
- (n_samples,), valid for `ElasticNetCV` and `LassoCV`.
- (n_samples, n_targets), valid for `MultiTaskElasticNetCV` and `MultitaskLassoCV`.
- (n_samples, n_tasks), valid for `MultiTaskElasticNetCV` and `MultitaskLassoCV`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is n_tasks used elsewhere in scikit-learn?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is the term used in MultiTaskElasticNet to refer to the extra dim of y, intercept_ and coef_

@jnothman
Copy link
Member

jnothman commented Feb 19, 2019 via email

@albertotb
Copy link
Contributor Author

@jnothman I believe the semantics are a little bit different between multiple targets and multiple tasks. For instance ElasticNet and MultiTaskElasticNet both accept a 2D y argument to the fit function, but in the first one the models are independent (n_targets), while the latter imposes the same sparsity pattern to all of them (n_tasks) and thus are somewhat related.

@jnothman
Copy link
Member

jnothman commented Feb 19, 2019 via email

y : array-like,
- shape (n_samples,), valid for `ElasticNetCV` and `LassoCV`.
- shape (n_samples, n_tasks), valid for `MultiTaskElasticNetCV`
and `MultitaskLassoCV`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this renders fine:

https://50700-843222-gh.circle-artifacts.com/0/doc/modules/generated/sklearn.linear_model.ElasticNetCV.html#sklearn.linear_model.ElasticNetCV.fit

but it's not great that docstring of ElasticNetCV mentions estimators which are unrelated.... I am tempted to implement the fit in ElasticNetCV that will call super().fit just to have a good docstring...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't we also need to implement fit methods in LassoCV, MultiTaskElasticNetCV and MultitaskLassoCV just for the doctring?

@agramfort
Copy link
Member

agramfort commented Mar 6, 2019 via email

@amueller
Copy link
Member

potentially related to #13392

@vaibhavmehrotraml
Copy link

Any updates on this issue? Novice contributor looking to help out.

Base automatically changed from master to main January 22, 2021 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Possible error in documentation of ElasticNetCV()
6 participants