FEA Add metadata routing to SelectFromModel - #27490
Conversation
adrinjalali
left a comment
There was a problem hiding this comment.
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>
adrinjalali
left a comment
There was a problem hiding this comment.
LGTM.
@glemaitre @OmarManzoor another easy one to review.
glemaitre
left a comment
There was a problem hiding this comment.
LGTM. Only a small change in the documentation and a more general question.
| 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.
are we making the call consistent by calling it **params instead of **fit_params?
There was a problem hiding this comment.
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.
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.
I personally don't care enough about these names really, users can't pass them explicitly anyway.
There was a problem hiding this comment.
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.
| `**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.
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.
adrinjalali
left a comment
There was a problem hiding this comment.
@glemaitre you okay with this version?
|
CI failing @StefanieSenger |
glemaitre
left a comment
There was a problem hiding this comment.
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
fitandpartial_fitmethods.