Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/6308#discussion_r30853851
--- Diff: mllib/src/main/scala/org/apache/spark/ml/feature/HashingTF.scala
---
@@ -50,10 +59,22 @@ class HashingTF(override val uid: String) extends
UnaryTransformer[Iterable[_],
/** @group setParam */
def setNumFeatures(value: Int): this.type = set(numFeatures, value)
- override protected def createTransformFunc: Iterable[_] => Vector = {
+
+
+ override def transform(dataset: DataFrame): DataFrame = {
+ val outputSchema = transformSchema(dataset.schema)
val hashingTF = new feature.HashingTF($(numFeatures))
- hashingTF.transform
+ val t = udf { terms: Seq[_] => hashingTF.transform(terms) }
+ val metadata = outputSchema($(outputCol)).metadata
+ dataset.select(col("*"), t(col($(inputCol))).as($(outputCol),
metadata))
}
- override protected def outputDataType: DataType = new VectorUDT()
+ override def transformSchema(schema: StructType): StructType = {
+ val inputType = schema($(inputCol)).dataType
+ require(inputType.isInstanceOf[ArrayType],
+ s"The input column must be array type, but got $inputType.")
--- End diff --
"array type" --> "ArrayType"
---
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]