0
0
NLPml~10 mins

Visualizing topics (pyLDAvis) in NLP - 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 pyLDAvis library.

NLP
import [1]
Drag options to blanks, or click blank then click option'
ApyLDAvis
Bmatplotlib
Csklearn
Dpandas
Attempts:
3 left
💡 Hint
Common Mistakes
Importing unrelated libraries like matplotlib or pandas.
Misspelling the library name.
2fill in blank
medium

Complete the code to prepare the visualization data for an LDA model.

NLP
vis_data = pyLDAvis.[1](lda_model, corpus, dictionary)
Drag options to blanks, or click blank then click option'
Aplot
Bprepare
Cshow
Dfit
Attempts:
3 left
💡 Hint
Common Mistakes
Using plot or show instead of prepare.
Confusing model fitting with visualization preparation.
3fill in blank
hard

Fix the error in the code to display the pyLDAvis visualization in a Jupyter notebook.

NLP
pyLDAvis.[1](vis_data)
Drag options to blanks, or click blank then click option'
Ashow
Bdisplay
Crender
Dplot
Attempts:
3 left
💡 Hint
Common Mistakes
Using display which is not a pyLDAvis function.
Trying to use plot or render which do not exist.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that filters topics with probability greater than 0.1.

NLP
filtered_topics = {topic: prob for topic, prob in topic_probs.items() if prob [1] [2]
Drag options to blanks, or click blank then click option'
A>
B0.1
C<
D0.5
Attempts:
3 left
💡 Hint
Common Mistakes
Using less than symbol instead of greater than.
Using 0.5 instead of 0.1 as threshold.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps topic names to their top words if the word frequency is above 0.05.

NLP
top_words = {topic[1]: word for topic, words in topic_word_dist.items() for word, freq in words if freq [2] [3]
Drag options to blanks, or click blank then click option'
A.upper()
B>
C0.05
D.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase instead of uppercase for topic names.
Using less than symbol or wrong threshold for frequency.