K-Nearest Neighbors
In this chapter, we will be learning how to calculate K-nearest neighbors based on cosine similarity.
We'll cover the following...
Chapter Goals:
- Learn about K-nearest neighbors in terms of word similarity
- Create a function that computes the K-nearest neighbors for a given word
A. Similar words
When comparing cosine similarities for word embeddings, a common procedure is to find the K-nearest neighbors for a given word. This means that for a given a word w and an integer K, we can find the K vocabulary words whose embedding vectors have the highest cosine similarity to the embedding vector for w.
Using K-nearest neighbors can help us ...