0
0
ML Pythonml~10 mins

Word embeddings concept (Word2Vec) in ML Python - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
AWord2Vec
Bword2vec
CWordVec
DWordEmbedding
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.
2fill in blank
medium

Complete 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'
Asentences
Bdata
Ccorpus
Dtext
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.
3fill in blank
hard

Fix 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'
A'King'
Bking
C['king']
D'king'
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.
4fill in blank
hard

Fill 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'
Amost_similar
B'queen'
C'king'
Dsimilar_words
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.
5fill in blank
hard

Fill 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'
Aword
B>
C<
Dlen(word)
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.