We need to check the feature vector quality during the evaluation process. This will give us an idea of the quality of the Word2Vec model that was generated. In this recipe, we will follow two different approaches to evaluate the Word2Vec model.
Evaluating the model
How to do it...
- Find similar words to a given word:
Collection<String> words = model.wordsNearest("season",10);
You will see an n output similar to the following:
week
game
team
year
world
night
time
country
last
group
- Find the cosine similarity of the given two words:
double cosSimilarity = model.similarity("season","program");
System.out.println(cosSimilarity);
For the preceding example, the cosine similarity is calculated as...