Repository navigation
Add tfidf_transformer - #3178
Merged
Merged
Conversation
A tool that learns TF-IDF weights from sparse term-count vectors.
Contributor
Author
|
If you're ok with it, I might submit a couple more PRs after this one:
|
Owner
|
Nice, this is a great PR. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
As discussed in #3176, this PR adds
tfidf_transformer, which learns TF-IDF weights from sparse vectors of term counts and turns documents into TF-IDF vectors that the sparse linear trainers can use directly.I needed it for a page classifier that trains dlib's linear SVM on hashed n-grams, where it replaced our hand-written TF-IDF code with identical results. The defaults follow scikit-learn's
TfidfTransformer(smoothed idf, raw counts, unit length).In a separate commit, I also added
normalize()andnormalize_inplace()for sparse vectors, since the transformer needs it. Let me know if you'd rather not have it, and I'll drop it.The only doubt I have is around the name
normalize_inplace: I followedmake_sparse_vector_inplace, but maybe there's a better one.Closes #3176