Github user BryanCutler commented on a diff in the pull request:
https://github.com/apache/spark/pull/19024#discussion_r134887435
--- Diff: docs/ml-features.md ---
@@ -211,6 +211,89 @@ for more details on the API.
</div>
</div>
+## FeatureHasher
+
+Feature hashing projects a set of categorical or numerical features into a
feature vector of
+specified dimension (typically substantially smaller than that of the
original feature
+space). This is done using the [hashing
trick](https://en.wikipedia.org/wiki/Feature_hashing)
+to map features to indices in the feature vector.
+
+The `FeatureHasher` transformer operates on multiple columns. Each column
may contain either
+numeric or categorical features. Behavior and handling of column data
types is as follows:
+
+- Numeric columns: For numeric features, the hash value of the column name
is used to map the
+feature value to its index in the feature vector. Numeric features are
never treated as
+categorical, even when they are integers. You must explicitly convert
numeric columns containing
+categorical features to strings first.
+- String columns: For categorical features, the hash value of the string
"column_name=value"
+is used to map to the vector index, with an indicator value of `1.0`.
Thus, categorical features
+are "one-hot" encoded (similarly to using
[OneHotEncoder](ml-features.html#onehotencoder) with
+`dropLast=false`).
+- Boolean columns: Boolean values are treated in the same way as string
columns. That is,
+boolean features are represented as "column_name=true" or
"column_name=false", with an indicator
+value of `1.0`.
+
+Null (missing) values are ignored (implicitly zero in the resulting
feature vector).
+
+The hash function used here is also the [MurmurHash
3](https://en.wikipedia.org/wiki/MurmurHash)
+used in [HashingTF](ml-features.html#tf-idf). Since a simple modulo is
used to transform the hash
+function to a vector index, it is advisable to use a power of two as the
numFeatures parameter;
--- End diff --
I read this as the hash function itself is transformed instead of the
output of it. Would it be more correct to say here
"Since a simple modulo is used to determine the vector index for the hashed
value,.."?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]