-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Update sklearn API for Gensim models #1473
Merged
menshikh-iv
merged 27 commits into
piskvorky:develop
from
chinmayapancholi13:renaming_skl_wrappers
Aug 10, 2017
Merged
Changes from 2 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
c55fcc9
renamed sklearn wrapper classes
dde234f
added newline for flake8 check
721806b
renamed sklearn api files
3cdcfde
updated tests for sklearn api
99dba85
updated ipynb for sklearn api
4d1eaf4
PEP8 changes
155a1ec
updated docstrings for sklearn wrappers
ae6c0f3
added 'testPersistence' and 'testModelNotFitted' tests for author top…
3c78873
removed 'set_params' function from all wrappers
chinmayapancholi13 341ed1f
removed 'get_params' function from base class
chinmayapancholi13 9113f82
removed 'get_params' function from all api classes
chinmayapancholi13 2935680
removed 'partial_fit()' from base class
chinmayapancholi13 9628f99
updated error message
chinmayapancholi13 3849d06
updated error message for 'partial_fit' function in W2VTransformer
chinmayapancholi13 6097349
removed 'BaseTransformer' class
chinmayapancholi13 5b21875
updated error message for 'partial_fit' in 'W2VTransformer'
chinmayapancholi13 6bfdb4d
added checks for setting attributes after calling 'fit'
chinmayapancholi13 9f0be87
flake8 fix
chinmayapancholi13 6004eee
using 'sparse2full' in 'transform' function
chinmayapancholi13 3262ec2
added missing imports
chinmayapancholi13 d4e560e
added comment about returning dense representation in 'transform' fun…
chinmayapancholi13 ad3f1f7
added 'testConsistencyWithGensimModel' for ldamodel
chinmayapancholi13 877632e
updated ipynb
chinmayapancholi13 0871b50
updated 'testPartialFit' for Lda and Lsi transformers
chinmayapancholi13 3f363a1
added author info
chinmayapancholi13 c0894bc
added 'testConsistencyWithGensimModel' for w2v transformer
chinmayapancholi13 9b7402d
removed merge conflicts
chinmayapancholi13 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 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 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 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 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 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 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 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 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.
As long as we're making breaking renames/refactors for clarity/concision, these package-names have a lot of redundancy, too.
gensim.sklearn_integration.sklearn_wrapper_gensim_atmodel
repeats bothsklearn
andgensim
, andintegration
andwrapper
have overlapping meanings.So perhaps just:
gensim.sklearn_wrappers.atmodel
? And that's ifat
is already easily recognized from use elsewhere as abbreviation; otherwisegensim.sklearn_wrappers.authortopicmodel
or evengensim.sklearn_wrappers.authortopic
?Or maybe even:, given that these wrappers are each pretty slight-in-size, they could either go: (1) in the respective associated model file – that is W2VTransformer goes into
gensim.models.word2vec
(and probably loses its abbreviation, to match the non-abbreviation used in that file's classes); or (2) into a singlesklearn_wrappers
file, alongside theBaseSklearnWrapper
?(And regarding
BaseSklearnWrapper
- not sure it adds much beyond alternative of using skearn's own BaseEstimator and TransformerMixin. It forces more rigor in overriding the necessary abstract-methods, which sklearn itself never does, but has less functionality inset_params()
and other aspects of introspectability.)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.
cc @piskvorky for overall library naming/organization priorities
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 vote for
from gensim.models.atmodel import AuthorTopicTransformer
, but would agree withfrom gensim.sklearn_api import AuthorTopicTransformer
too. It is neither a wrapper nor an integration, but just an API.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.
If we were to share the same module for gensim/sklearn classes, we'd have to tiptoe around the sklearn imports, because sklearn is not a dependency of gensim.
An extra subpackage sounds cleaner to me: one subpackage for sklearn / keras / spark / whatever API. Not imported automatically from gensim
__init__
, so that users need to import it explicitly, after installing sklearn/keras/spark/tensorflow/whatever.And if the subpackage becomes too unwieldy or complex (not the case with sklearn now), a separate library would make sense to me too, to decouple the release and maintenance cycle.
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 vote for
from gensim.sklearn_api import AuthorTopicTransformer
with subpackagesklearn_api
.We will not have "sklearn as dependency", but have "short and uniq import path" for sklearn wrappers.