-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
SLEP006: ClassifierChain and RegressorChain routing #24443
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
Merged
adrinjalali
merged 5 commits into
scikit-learn:sample-props
from
OmarManzoor:classifier_and_regression_chain_routing
Oct 4, 2022
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d0265b9
SLEP006: Add routing to ClassifierChain and RegressorChain fit
OmarManzoor 3ccd61d
Add a test to check that the current behavior works and raises a futu…
OmarManzoor 1b52296
Fix tests
OmarManzoor 26e8a95
Add a helper comment to specify removal of FutureWarning
OmarManzoor dbef329
Move the get_metadata_routing method to the individual child classes
OmarManzoor File filter
Filter by extension
Conversations
Faile
8000
d to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -28,6 +28,7 @@ | |||||||
Ridge, | ||||||||
SGDClassifier, | ||||||||
SGDRegressor, | ||||||||
QuantileRegressor, | ||||||||
) | ||||||||
from sklearn.metrics import jaccard_score, mean_squared_error | ||||||||
from sklearn.model_selection import GridSearchCV, train_test_split | ||||||||
|
@@ -646,7 +647,7 @@ def fit(self, X, y, **fit_params): | |||||||
self.sample_weight_ = fit_params["sample_weight"] | ||||||||
super().fit(X, y, **fit_params) | ||||||||
|
||||||||
model = RegressorChain(MySGD()) | ||||||||
model = RegressorChain(MySGD().set_fit_request(sample_weight=True)) | ||||||||
|
||||||||
# Fitting with params | ||||||||
fit_param = {"sample_weight": weight} | ||||||||
|
@@ -655,6 +656,16 @@ def fit(self, X, y, **fit_params): | |||||||
for est in model.estimators_: | ||||||||
assert est.sample_weight_ is weight | ||||||||
|
||||||||
# TODO(1.4): Remove check for FutureWarning | ||||||||
# Test that the existing behavior works and raises a FutureWarning | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this comme 6D47 ntThe reason will be displayed to describe this comment to others. Learn more. To make it easier to search for when we need to remove the warning:
Suggested change
|
||||||||
# when the underlying estimator used has a sample_weight parameter | ||||||||
# defined in it's fit method. | ||||||||
model = RegressorChain(QuantileRegressor()) | ||||||||
fit_param = {"sample_weight": weight} | ||||||||
|
||||||||
with pytest.warns(FutureWarning): | ||||||||
model.fit(X, y, **fit_param) | ||||||||
|
||||||||
|
||||||||
@pytest.mark.parametrize( | ||||||||
"MultiOutputEstimator, Estimator", | ||||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 need a test that checks that the existing behaviour still works but issues a
DeprecationWarning
.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 the common tests are supposed to do that.