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

    https://github.com/apache/spark/pull/16811#discussion_r104330610
  
    --- Diff: 
mllib/src/test/scala/org/apache/spark/ml/feature/Word2VecSuite.scala ---
    @@ -134,13 +134,20 @@ class Word2VecSuite extends SparkFunSuite with 
MLlibTestSparkContext with Defaul
           .fit(docDF)
     
         val expectedSimilarity = Array(0.2608488929093532, -0.8271274846926078)
    -    val (synonyms, similarity) = model.findSynonyms("a", 2).rdd.map {
    +    val result = model.findSynonyms("a", 2).rdd.map {
           case Row(w: String, sim: Double) => (w, sim)
    -    }.collect().unzip
    +    }.collect()
    +    val (synonyms, similarity) = result.unzip
     
         assert(synonyms === Array("b", "c"))
         expectedSimilarity.zip(similarity).foreach {
    -      case (expected, actual) => assert(math.abs((expected - actual) / 
expected) < 1E-5)
    +      case (expected, actual) => assert(expected ~== actual absTol 1E-5)
    +    }
    +
    +    result.zip(model.findSynonymsArray("a", 2)).foreach {
    --- End diff --
    
    Technically, collect() may not return elements in the same order each time, 
so this will be more robust if we convert each result to a map: synonym -> 
similarity and compare the maps.  Could you please do that?


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