-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
TST activate common tests for TSNE #25374
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
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8171b1c
TST activate common tests for TSNE
glemaitre 5a0af9e
Merge remote-tracking branch 'origin/main' into tsne_commont_tests
glemaitre 414422f
TST check for fit/transform fit_transform availability
glemaitre a406b22
FIX add _n_features_out in TSNE
glemaitre fc030d1
more duck-typing
glemaitre 1403794
apply reviews from jeremie
glemaitre 5595868
Merge remote-tracking branch 'origin/main' into tsne_commont_tests
glemaitre File filter
Filter by extension
Conversations
Failed 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
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.
I find it weird to have a sub-class of
TransformerMixin
without atransform
method. But maybe it's better than what we do currently...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.
Since the
Mixin
only definesfit_transform
and we override it, I find it fine to inherit.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 problem we are trying to solve by inheriting is having
TSNE
selected as a transformer byall_estimators
. Is there another way of doing that, other than having to inherit fromTransformerMixin
?It feels weird to inherit, which for me is saying "I am a transformer with all the things a transformer can do!" and then not have a
transform
method. But the mixin doesn't define it either. So is having atransform
method not part of being "a real transformer"?On a pragmatic level, using the mixin is a nice way to get into the list of
all_estimators
and maybe mixins aren't like real "is a" style inheritance?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.
Looking at the documentation, it seems that the original spirit is indeed to have at least
fit
andtransform
andfit_transform
is just a convenience.We could always replace by duck-typing: if an estimator implements
fit
+transform
or/andfit_transform
, then it should pass the test of a transformer.Indeed, some of our checks are ducktyping while the helper to list the estimators is checking for the mixins.
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.
Actually, the annoying part with duck-typing is that we already need to have an instance while we are playing with classes at this stage.
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 don't quite understand what you mean. To find out if a method is implemented you could do something like
"fit" in dir(Estimator)
no?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.
Indeed we could. I just had in my mind a piece of the parameter validation framework
HasMethods
that does this job already for instances.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.
According to the glossary, a transformer is an estimator that implements
transform
and/orfit_transform
, so TSNE complies with that and sinceTransformerMixin
is supposed to be the "mixing class for all transformers in scikit-learn", then I find it totally appropriate that TSNE inherits from this mixinThere 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.
Good point.
Yet, I am still not convinced we should rely on
isinstance(obj, TransformerMixin)
to discover all transformers in scikit-learn. We should rather use an estimator tag or duck-typing.But +1 with moving forward with this TSNE-specific PR which is already a net improvement in itself and delegate the discussion of how to properly discover transformers in common test to another issue/PR.
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 is related to https://github.com/scikit-learn/scikit-learn/pull/17806/files which is about all other estimator types.