You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/07/26 13:44:25 UTC

[GitHub] [spark] viirya commented on a change in pull request #25250: [SPARK-21481][ML] Add indexOf method in ml.feature.HashingTF

viirya commented on a change in pull request #25250: [SPARK-21481][ML] Add indexOf method in ml.feature.HashingTF
URL: https://github.com/apache/spark/pull/25250#discussion_r307746126
 
 

 ##########
 File path: mllib/src/main/scala/org/apache/spark/ml/feature/HashingTF.scala
 ##########
 @@ -94,15 +99,22 @@ class HashingTF @Since("1.4.0") (@Since("1.4.0") override val uid: String)
   @Since("2.0.0")
   override def transform(dataset: Dataset[_]): DataFrame = {
     val outputSchema = transformSchema(dataset.schema)
-
-    val hashingTF = new OldHashingTF($(numFeatures)).setBinary($(binary))
-    val func = (terms: Seq[_]) => {
-      val seq = hashingTF.transformImpl(terms)
-      Vectors.sparse(hashingTF.numFeatures, seq)
+    val hashUDF = udf { terms: Seq[_] =>
+      val numOfFeatures = $(numFeatures)
+      val isBinary = $(binary)
+      val termFrequencies = mutable.HashMap.empty[Int, Double].withDefaultValue(0.0)
+      terms.foreach { term =>
+        val i = indexOf (term)
 
 Review comment:
   Remove extra space after `indexOf`?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org