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

    https://github.com/apache/spark/pull/11832#discussion_r57041720
  
    --- 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 --
    
    No, I was just talking about in this test suite, but nevermind, it wasn't 
very clean.  I guess if the index calculation ends up changing, these test will 
fail anyway.
    I was trying to avoid moving `def idx` to the class because then it would 
need to be called with a number to mod always, like `idx("a", 100)`, so I'll 
try something else that will hopefully be a little better.


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

Reply via email to