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

    https://github.com/apache/spark/pull/11832#discussion_r56897863
  
    --- 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)
    +    val expected = Vectors.sparse(n,
    +      Seq((idx("a"), 1.0), (idx("b"), 1.0), (idx("c"), 1.0)))
    +    assert(features ~== expected absTol 1e-14)
    +  }
    --- End diff --
    
    Yeah, maybe it is a little too redundant.  I could remove the MLlib version 
or change it to use an RDD to which would test a slightly different code path?


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