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 metadata routing to SelectFromModel #27490
FEA Add metadata routing to SelectFromModel #27490
Conversation
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.
also, could you please move the estimator from unsupported, to supported in metadata_routing.rst
?
Co-authored-by: Adrin Jalali <adrin.jalali@gmail.com>
Co-authored-by: Adrin Jalali <adrin.jalali@gmail.com>
Co-authored-by: Adrin Jalali <adrin.jalali@gmail.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.
LGTM.
@glemaitre @OmarManzoor another easy one to review.
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.
LGTM. Only a small change in the documentation and a more general question.
@@ -387,7 +408,7 @@ def threshold_(self): | |||
# SelectFromModel.estimator is not validated yet | |||
prefer_skip_nested_validation=False | |||
) | |||
def partial_fit(self, X, y=None, **fit_params): | |||
def partial_fit(self, X, y=None, **params): |
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.
are we making the call consistent by calling it **params
instead of **fit_params
?
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.
In my opinion, it might avoid confusion to call those params like the function they are routing from (partial_fit_params
, in this case). Imagining several sets of params being routed between several methods, this would help to read the code more easily.
I'm not sure if Adrin shares the same sentiment about the term 'partial_fit_params,' @adrinjalali?
For me, the more explicit, the better.
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.
For me fit_params
or partial_fit_params
makes sense when those parameters are only dispatched to the fit
or partial_fit_params
from the underlying learners. If there is a scorer for instance, I am fine with params
.
This is a bit the reason that I was a bit surprised here because we only pass it to the partial_fit_params
of the sub-estimator.
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 personally don't care enough about these names really, users can't pass them explicitly anyway.
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.
So let's be intuitive and consistent for the sake of the documentation :).
`**partial_fit_params` are routed to the sub-estimator, if | ||
`enable_metadata_routing=True` is set via | ||
:func:`~sklearn.set_config`, which allows for aliasing. |
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.
`**partial_fit_params` are routed to the sub-estimator, if | |
`enable_metadata_routing=True` is set via | |
:func:`~sklearn.set_config`, which allows for aliasing. | |
Only available if `enable_metadata_routing=True`, | |
which can be set by using | |
``sklearn.set_config(enable_metadata_routing=True)``. | |
See :ref:`Metadata Routing User Guide <metadata_routing>` for | |
more details. |
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.
Actually, I would suggest to leave this part below .. versionchanged:: 1.4
mostly away. We already wrote all of this before and after. And it looks difficult to read.
What about this?
**partial_fit_params : dict
- If `enable_metadata_routing=False` (default):
Parameters directly passed to the `partial_fit` method of the
sub-estimator. They are ignored if `prefit=True`.
- If `enable_metadata_routing=True`:
Parameters safely routed to the `partial_fit` method of the
sub-estimator. They are ignored if `prefit=True`.
.. versionchanged:: 1.4
See :ref:`Metadata Routing User Guide <metadata_routing>` for
more details.
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 agree.
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.
@glemaitre you okay with this version?
CI failing @StefanieSenger |
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.
Yes I am fine with this version. We can merge once the CI is green.
I've dealt with the errors in the docstring and hope now the CI will be all green. |
Thanks @StefanieSenger Merging. |
Co-authored-by: Adrin Jalali <adrin.jalali@gmail.com>
Co-authored-by: Adrin Jalali <adrin.jalali@gmail.com>
Co-authored-by: Adrin Jalali <adrin.jalali@gmail.com>
Reference Issues/PRs
Towards #22893
What does this implement/fix? Explain your changes.
Adds metadata routing to
SelectFromModel
.The routing is added in the
fit
andpartial_fit
methods.