FEAT add SLEP006 with a feature flag#26103
FEAT add SLEP006 with a feature flag#26103glemaitre merged 11 commits intoscikit-learn:sample-propsfrom
Conversation
| # the fit method already accepts everything, therefore we don't | ||
| # specify parameters. The value passed to ``child`` needs to be the | ||
| # same as what's passed to ``add`` above, in this case | ||
| # `"estimator"`. | ||
| .warn_on(child="estimator", method="fit", params=None) |
There was a problem hiding this comment.
we don't need to be backward compatible now when the feature flag is on, so these lines are removed.
| "warns_on": { | ||
| "fit": ["sample_weight", "metadata"], | ||
| "partial_fit": ["sample_weight"], | ||
| }, |
There was a problem hiding this comment.
removing these and corresponding tests since we don't deal with backward compatibility now.
glemaitre
left a comment
There was a problem hiding this comment.
The changes looks good. In a subsequent PR, I think that we should have a way to test both legacy weighting and the new metadata routing at least in the common test.
| return re.sub(r"\s", "", str(obj)) | ||
|
|
||
|
|
||
| def _weighted(estimator): |
There was a problem hiding this comment.
I am wondering if a subsequent PR, we could have a way to test the legacy and new way:
SKLEARN_METADATA_ROUTING="enable" pytest sklearn/test/test_common.pyand then have two constructor selected depending on the config.
Common test could be quite useful to catch up some bugs.
There was a problem hiding this comment.
yeah there can be some tests in common tests, happy to work on it on a subsequent PR (but probably not a blocker to merge sample-props into main).
| @@ -121,15 +126,26 @@ def partial_fit(self, X, y, classes=None, sample_weight=None, **partial_fit_para | |||
| weights. | |||
|
|
|||
| **partial_fit_params : dict of str -> object | |||
There was a problem hiding this comment.
For reviewer: This parameter was added in sample_props branch.
| ) | ||
|
|
||
| if sample_weight is not None: | ||
| kwargs["sample_weight"] = sample_weight |
There was a problem hiding this comment.
I was about to say that we modify a mutable here and it should be safer to copy. However, now I see that we pass **kwargs and not kwargs so it should be fine.
| SGDRegressor, | ||
| QuantileRegressor, | ||
| ) | ||
| from sklearn.linear_model import Lasso |
There was a problem hiding this comment.
I would like so much to have isort to avoid thinking about those changes :)
adrinjalali
left a comment
There was a problem hiding this comment.
Right now we basically test all the old routing in our tests, and we have dedicated tests for the new routing. But we can certainly work on some tests for common tests, and have a list of meta estimators for which they fail.
| routed_params = process_routing( | ||
| obj=self, method="fit", other_params=fit_params, sample_weight=sample_weight | ||
| ) | ||
| if _routing_enabled(): |
There was a problem hiding this comment.
maybe worth a PR then :P
| return re.sub(r"\s", "", str(obj)) | ||
|
|
||
|
|
||
| def _weighted(estimator): |
There was a problem hiding this comment.
yeah there can be some tests in common tests, happy to work on it on a subsequent PR (but probably not a blocker to merge sample-props into main).
ogrisel
left a comment
There was a problem hiding this comment.
I think we should completely get rid of .warn_on. The warning message would not make sense for third party library and we won't need it in scikit-learn.
Besides that, looks good to me. But I would need to see the PR against main to decide whether this is mergeable in main as it is or not.
|
|
||
| class _MultiOutputEstimator(MetaEstimatorMixin, BaseEstimator, metaclass=ABCMeta): | ||
| _parameter_constraints = { | ||
| _parameter_constraints: dict = { |
There was a problem hiding this comment.
seems unrelated and unusual in scikit-learn.
There was a problem hiding this comment.
I'd agree, but this one is also not me here, it's from main:
scikit-learn/sklearn/multioutput.py
Line 87 in 66a4d96
adrinjalali
left a comment
There was a problem hiding this comment.
Besides that, looks good to me. But I would need to see the PR against
mainto decide whether this is mergeable inmainas it is or not.
@ogrisel it isn't ready for merge after this. I'll submit another PR once this is merged to prepare the sample-props branch for merge, with all the nits we need to do before merging, after that PR we can review the big PR and merge.
|
|
||
| class _MultiOutputEstimator(MetaEstimatorMixin, BaseEstimator, metaclass=ABCMeta): | ||
| _parameter_constraints = { | ||
| _parameter_constraints: dict = { |
There was a problem hiding this comment.
I'd agree, but this one is also not me here, it's from main:
scikit-learn/sklearn/multioutput.py
Line 87 in 66a4d96
|
Merging since all points had been addressed and the remaining discussion will be linked to another PR. |
This PR adds a
enable_metadata_routingflag as a global configuration, which isFalseby default.A good way to review this PR is to compare some of the files with
maininstead ofsample-props.test_calibration.pyandtest_multioutput.pyare copied frommainhere, so the diff here is only compared tosample-propsbranch, and this PR roles back previous changes to these files.towards: #26045