Github user WeichenXu123 commented on a diff in the pull request:
https://github.com/apache/spark/pull/18736#discussion_r133080201
--- Diff:
mllib/src/test/scala/org/apache/spark/ml/feature/HashingTFSuite.scala ---
@@ -69,6 +69,20 @@ class HashingTFSuite extends SparkFunSuite with
MLlibTestSparkContext with Defau
assert(features ~== expected absTol 1e-14)
}
+ test("indexOf method") {
+ val df = Seq((0, "a a b b c d".split(" ").toSeq)).toDF("id", "words")
+ val n = 100
+ val hashingTF = new HashingTF()
+ .setInputCol("words")
+ .setOutputCol("features")
+ .setNumFeatures(n)
+ hashingTF.transform(df)
+ assert(hashingTF.indexOf("a") === 70)
+ assert(hashingTF.indexOf("b") === 61)
+ assert(hashingTF.indexOf("c") === 22)
+ assert(hashingTF.indexOf("d") === 94)
--- End diff --
I prefer the testcase compare the result between `ml.feature.HashingTF` and
`mllib.feature.HashingTF`, avoid hardcoding the computing result here.
---
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]