Github user MLnick commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11832#discussion_r56948444
  
    --- Diff: 
mllib/src/test/scala/org/apache/spark/ml/feature/HashingTFSuite.scala ---
    @@ -52,6 +52,27 @@ class HashingTFSuite extends SparkFunSuite with 
MLlibTestSparkContext with Defau
         assert(features ~== expected absTol 1e-14)
       }
     
    +  test("applying binary term freqs") {
    +    val df = sqlContext.createDataFrame(Seq(
    +      (0, "a a b c c c".split(" ").toSeq)
    +    )).toDF("id", "words")
    +    val n = 100
    +    val hashingTF = new HashingTF()
    +        .setInputCol("words")
    +        .setOutputCol("features")
    +        .setNumFeatures(n)
    +        .setBinary(true)
    +    val output = hashingTF.transform(df)
    +    val attrGroup = 
AttributeGroup.fromStructField(output.schema("features"))
    +    require(attrGroup.numAttributes === Some(n))
    +    val features = output.select("features").first().getAs[Vector](0)
    +    // Assume perfect hash on "a", "b", "c".
    +    def idx(any: Any): Int = Utils.nonNegativeMod(any.##, n)
    --- End diff --
    
    this `def` could be moved out and used in both tests


---
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]

Reply via email to