Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import the Word2Vec model from gensim.
ML Python
from gensim.models import [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'word2vec' which is incorrect.
Using 'WordVec' missing the '2'.
Using 'WordEmbedding' which is not the class name.
✗ Incorrect
The correct class name to import is 'Word2Vec' with capital W and V.
2fill in blank
mediumComplete the code to train a Word2Vec model on sentences.
ML Python
model = Word2Vec(sentences=[1], vector_size=100, window=5, min_count=1, workers=4)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'sentences' as a variable when it is not defined.
Using 'text' which is usually raw string, not tokenized sentences.
Using 'data' which is too generic and may not be defined.
✗ Incorrect
The training data variable is commonly called 'corpus' representing the list of sentences.
3fill in blank
hardFix the error in accessing the vector for the word 'king'.
ML Python
vector = model.wv[[1]] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using capitalized 'King' which may not be in vocabulary.
Using the variable king without quotes causing NameError.
Using a list ['king'] which is invalid for key access.
✗ Incorrect
The word must be a lowercase string 'king' to match the vocabulary key.
4fill in blank
hardFill both blanks to find the most similar words to 'queen'.
ML Python
similar_words = model.wv.[1](positive=[[2]], topn=5)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'similar_words' as method which is incorrect.
Passing 'king' instead of 'queen' as the positive word.
Not using quotes around the word.
✗ Incorrect
The method to find similar words is 'most_similar' and the input word must be a string 'queen'.
5fill in blank
hardFill both blanks to create a dictionary of word vectors for words with length greater than 4.
ML Python
word_vectors = {word: model.wv[[1]] for word in model.wv.index_to_key if len(word) [2] 4} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'len(word)' as dictionary key which is incorrect.
Using '<' instead of '>' causing wrong filtering.
Using variable names not defined in the comprehension.
✗ Incorrect
We use 'word' as the key to get vectors, and filter words with length greater than 4 using '>'.