FeatureHasher should have an option to not hash the values #309
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.
Description
FeatureHasher
now has an option to preserve the values of the features that it hashes, and this option is available throughTokenPipeline
. Adds a couple of tests for the new behaviour.This changes the default behaviour of
TokenPipeline
with hashing, and adds an option to the constructor to revert to the old behaviour. The old behaviour didn't make much sense, but this allows people to preserve their computations. Note that reproducing old models without this fix will turn on the new behaviour as it is defaulted to on, and so must be overridden when reproducing those models.Motivation
A term counting
TokenPipeline
should never return negative values for the term counts, but asFeatureHasher
hashes the feature values into{-1,1}
this could cause the hashed dimensions to aggregate to a negative value which causes problems elsewhere and semantically isn't term counting.Fixes #307.