Worthäufigkeiten visualisieren
Nachdem du die häufigsten Wörter mit und ohne Stoppwörter berechnet hast, ist es Zeit, die Unterschiede zu visualisieren. In dieser Übung verwendest du matplotlib, um für beide Fälle Balkendiagramme zu erstellen.
Die folgenden Listen wurden für dich vorab geladen: top_words_without_stopwords, top_counts_without_stopwords, top_words_with_stopwords, top_counts_with_stopwords.
Diese Übung ist Teil des Kurses
Natural Language Processing (NLP) in Python
Anleitung zur Übung
- Verwende
plt.bar(), um die Top-10-Worthäufigkeiten mit Stoppwörtern zu plotten. - Verwende
plt.bar(), um die Top-10-Worthäufigkeiten ohne Stoppwörter zu plotten.
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
import matplotlib.pyplot as plt
# Plot the frequencies with stop words
plt.bar(____, ____)
plt.title("Top 10 word frequencies (with stop words)")
plt.xlabel("Words")
plt.ylabel("Frequency")
plt.show()
# Plot the frequencies without stop words
plt.figure()
plt.bar(____, ____)
plt.title("Top 10 word frequencies (without stop words)")
plt.xlabel("Words")
plt.ylabel("Frequency")
plt.show()