# Spark MLLib's Word2Vec cosine similarity greater than 1

On the spark implementation of word2vec, when the number of iterations or data partitions are greater than one, for some reason, the cosine similarity is greater than 1.

In my knowledge, cosine similarity should always be about $-1 < \cos\theta < 1$. Does anyone know why?

• Not sure about MlLib, but it happens on Scipy too. They use a different formula. Check this answer. So, check out whether MlLib uses a different formula too. – Dawny33 Oct 27 '15 at 5:07
• Perhaps the vectors are not normalized? – Vladislavs Dovgalecs Oct 27 '15 at 5:37