-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
FEA SLEP006: Metadata routing for SelfTrainingClassifier
#28494
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
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.
A few notes, thanks @adam2392
Signed-off-by: Adam Li <adam2392@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.
Thank you for the review and pointers! I went thru and fixed the issues in the doc-strings and Bunch
.
Signed-off-by: Adam Li <adam2392@gmail.com>
…learn into self-learn-meta
Resolved conflicts. Feel free to ping me if there's additional changes desired |
Signed-off-by: Adam Li <adam2392@gmail.com>
This PR should not be affected by #28734 |
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.
Thanks for the updates. A few other comments.
if method_name in ["fit", "partial_fit", "score"]: | ||
# `fit`, `partial_fit`, 'score' accept y, others don't. | ||
method(X, y, **method_kwargs) | ||
except TypeError: | ||
else: |
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 with try, except we don't really need to bother to maintain this list. However I am fine with either way. I'll let @adrinjalali finalise.
Signed-off-by: Adam Li <adam2392@gmail.com>
Thanks for the review @OmarManzoor! I'll change the last comment if @adrinjalali has any issues (#28494 (comment)) |
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 @adam2392
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.
Thanks @adam2392
if method_name in ["fit", "partial_fit", "score"]: | ||
# `fit`, `partial_fit`, 'score' accept y, others don't. | ||
method(X, y, **method_kwargs) | ||
except TypeError: | ||
else: |
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'm not sure why this makes things hard to debug really. The try/except is more foolproof since a library like imbalance-learn adds some methods to the whole system by patching a few things in sklearn and things would just work.
Co-authored-by: Adrin Jalali <adrin.jalali@gmail.com>
…learn into self-learn-meta
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.
Thanks for the review @adrinjalali ! I addressed your comments in 3b5a3f0
if method_name in ["fit", "partial_fit", "score"]: | ||
# `fit`, `partial_fit`, 'score' accept y, others don't. | ||
method(X, y, **method_kwargs) | ||
except TypeError: | ||
else: |
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.
Fair. I think it was hard before because the error message was not very clear on what method was failing from what class, so I assume that's been fixed with #29226
if method_name in ["fit", "partial_fit", "score"]: | ||
# `fit`, `partial_fit`, 'score' accept y, others don't. | ||
method(X, y, **method_kwargs) | ||
except TypeError: | ||
else: |
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 reverted it to the try/except
Signed-off-by: Adam Li <adam2392@gmail.com>
) | ||
else: | ||
estimator_ = clone(self.estimator) | ||
return 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.
still missing the case where both estimator
and base_estimator
are passed, in which case we need to raise
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.
|
||
|
||
# TODO(1.8): remove in 1.8 | ||
def test_deprecation_warning_base_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.
this should also test for all other cases in _get_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.
Signed-off-by: Adam Li <adam2392@gmail.com>
Signed-off-by: Adam Li <adam2392@gmail.com>
Lmk if I missed anything else @adrinjalali. Thanks for the review and patience! |
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.
Otherwise LGTM.
I'll let @OmarManzoor have another look since this changed a bit since last he reviewed.
Signed-off-by: Adam Li <adam2392@gmail.com>
SG! Thanks for the reviews. |
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 @adam2392
Reference Issues/PRs
Towards: #22893
What does this implement/fix? Explain your changes.
Implements metadata routing for
SelfTrainingClassifier
. Note the added code diff simply comes from a replacement ofbase_estimator
forestimator
.NonConsumingClassifier
fixes some minor design choices in the unit-testing framework oftest_metaestimators_metadata_routing.py
(e.g.try/except
->if/else
to be more transparent)Any other comments?
cc: @adrinjalali
Some open questions:
1. I presume, we want to forward metadata within all the functions possibly?2. As a result, I'm not sure if the unit-testing approach is the best, so I was wondering if you have any suggestions? Should I try potentially refactoring the existing unit-testing code to allow testing for more than justfit
?