1. Learn
  2. /
  3. Courses
  4. /
  5. Machine Translation with Keras

Connected

Exercise

Measuring word vector similarity

In this lesson we will understand the power of word vectors using real world trained word vectors. These are word vectors extracted from a list of word vectors published by the Stanford NLP group. A word vector is a sequence or a vector of numerical values. For example, dog = (0.31, 0.92, 0.13)

The distance between word vectors can be measured using a pair-wise similarity metric. Here we will be using sklearn.metrics.pairwise.cosine_similarity. Cosine similarity produces a higher values when the element-wise similarity of two vectors is high and vice-versa.

Instructions

100 XP
  • Print the length of the cat_vector using ndarray.size attribute.
  • Compute and print the similarity between the cat_vector and window_vector using cosine_similarity.
  • Compute and print the similarity between the cat_vector and dog_vector using cosine_similarity.