Github user sethah commented on a diff in the pull request: https://github.com/apache/spark/pull/18513#discussion_r128786226 --- Diff: mllib/src/main/scala/org/apache/spark/ml/feature/FeatureHasher.scala --- @@ -0,0 +1,189 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.spark.ml.feature + +import org.apache.spark.annotation.Since +import org.apache.spark.ml.Transformer +import org.apache.spark.ml.attribute.AttributeGroup +import org.apache.spark.ml.linalg.Vectors +import org.apache.spark.ml.param.{IntParam, ParamMap, ParamValidators} +import org.apache.spark.ml.param.shared.{HasInputCols, HasOutputCol} +import org.apache.spark.ml.util.{DefaultParamsReadable, DefaultParamsWritable, Identifiable, SchemaUtils} +import org.apache.spark.mllib.feature.{HashingTF => OldHashingTF} +import org.apache.spark.sql.{DataFrame, Dataset, Row} +import org.apache.spark.sql.functions._ +import org.apache.spark.sql.types._ +import org.apache.spark.util.Utils +import org.apache.spark.util.collection.OpenHashMap + +/** + * 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 be numeric + * (representing a real feature) or string (representing a categorical feature). Boolean columns --- End diff -- It might be good to make the behavior for each type of column clearer here. Specifically for numeric columns that are meant to be categories. Something like: ````scala /** * Behavior * -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 convert * categorical columns to strings first. * -String columns: ... * -Boolean columns: ... */ ```` Anyway, this is a very minor suggestion and I think it's also ok to leave as is.
--- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org