Github user lionelfeng commented on the pull request:

    https://github.com/apache/spark/pull/12265#issuecomment-207841507
  
    Can I change the test a bit since the order of terms with same frequency 
shouldn't matter in the vocabulary. 
    
    ```scala
    test("CountVectorizer common cases") {
        val df = sqlContext.createDataFrame(Seq(
          (0, split("a b c d d e"),
            Vectors.sparse(5, Seq((0, 1.0), (1, 1.0), (2, 1.0), (3, 2.0), (4, 
1.0)))),
          (1, split("a a a a a a"), Vectors.sparse(5, Seq((0, 6.0)))),
          (2, split("c"), Vectors.sparse(5, Seq((2, 1.0)))),
          (3, split("b b b b b"), Vectors.sparse(5, Seq((1, 5.0)))))
        ).toDF("id", "words", "expected")
        val cv = new CountVectorizer()
          .setInputCol("words")
          .setOutputCol("features")
          .fit(df)
        assert(cv.vocabulary === Array("a", "b", "c", "d", "e"))
    
        cv.transform(df).select("features", "expected").collect().foreach {
          case Row(features: Vector, expected: Vector) =>
            assert(features ~== expected absTol 1e-14)
        }
      }
    
    ```
     


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