Github user MLnick commented on a diff in the pull request:
https://github.com/apache/spark/pull/10152#discussion_r50671686
--- 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 --
@srowen if either of the vector norms are 0, the cosine similarity should
be 0. Though by definition I think here `v._2` will be 0 if the norm is 0, what
do you think about making this `if vecNorm == 0) 0 ...` to be explicit?
(follows what you did in
https://github.com/apache/spark/commit/94b39f7777ecff3794727c186bd681fa4c6af4fd#diff-88f4b62c382b26ef8e856b23f5167ccdR542)
---
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]