-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
FEAT add SLEP006 with a feature flag #26103
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
FEAT add SLEP006 with a feature flag #26103
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removing these and corresponding tests since we don't deal with backward compatibility now.
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.
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.
@@ -391,13 +391,6 @@ def _get_check_estimator_ids(obj): | |||
return re.sub(r"\s", "", str(obj)) | |||
|
|||
|
|||
def _weighted(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 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.py
and 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like so much to have isort
to avoid thinking about those changes :)
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe worth a PR then :P
@@ -391,13 +391,6 @@ def _get_check_estimator_ids(obj): | |||
return re.sub(r"\s", "", str(obj)) | |||
|
|||
|
|||
def _weighted(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.
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
).
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. Thanks @adrinjalali
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 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.
@@ -84,7 +89,7 @@ def _check(self): | |||
|
|||
|
|||
class _MultiOutputEstimator(MetaEstimatorMixin, BaseEstimator, metaclass=ABCMeta): | |||
_parameter_constraints = { | |||
_parameter_constraints: dict = { |
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.
seems unrelated and unusual in scikit-learn.
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'd agree, but this one is also not me here, it's from main
:
scikit-learn/sklearn/multioutput.py
Line 87 in 66a4d96
_parameter_constraints: dict = { |
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.
mypy
stuff
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.
Besides that, looks good to me. But I would need to see the PR against
main
to decide whether this is mergeable inmain
as 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.
@@ -84,7 +89,7 @@ def _check(self): | |||
|
|||
|
|||
class _MultiOutputEstimator(MetaEstimatorMixin, BaseEstimator, metaclass=ABCMeta): | |||
_parameter_constraints = { | |||
_parameter_constraints: dict = { |
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'd agree, but this one is also not me here, it's from main
:
scikit-learn/sklearn/multioutput.py
Line 87 in 66a4d96
_parameter_constraints: dict = { |
Merging since all points had been addressed and the remaining discussion will be linked to another PR. |
This PR adds a
enable_metadata_routing
flag as a global configuration, which isFalse
by default.A good way to review this PR is to compare some of the files with
main
instead ofsample-props
.test_calibration.py
andtest_multioutput.py
are copied frommain
here, so the diff here is only compared tosample-props
branch, and this PR roles back previous changes to these files.towards: #26045