Github user MLnick commented on a diff in the pull request: https://github.com/apache/spark/pull/10152#discussion_r50684006 --- Diff: mllib/src/main/scala/org/apache/spark/mllib/feature/Word2Vec.scala --- @@ -556,6 +571,7 @@ class Word2VecModel private[spark] ( .sortBy(- _._2) .take(num + 1) .tail + .map(v => (if (vecNorm == 0) v else (v._1, v._2 / vecNorm))) --- End diff -- Strictly speaking we could throw an error or warning if passing in a zero vector as it's meaningless as you say. Still, I think in real usage that's unlikely, so I'd just go for the first option. I don't think there are real world efficiency gains to be had with the second option.
--- 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