Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,7 +5,7 @@ from sklearn.cluster import KMeans
|
|
| 5 |
import re
|
| 6 |
from io import BytesIO
|
| 7 |
import tempfile
|
| 8 |
-
from wordcloud import WordCloud
|
| 9 |
import matplotlib.pyplot as plt
|
| 10 |
from PIL import Image
|
| 11 |
|
|
@@ -74,8 +74,9 @@ def cluster_data(df, num_clusters):
|
|
| 74 |
|
| 75 |
def generate_wordcloud(df):
|
| 76 |
text = " ".join(df['texts'].tolist())
|
| 77 |
-
|
| 78 |
-
|
|
|
|
| 79 |
plt.imshow(wordcloud, interpolation='bilinear')
|
| 80 |
plt.axis('off')
|
| 81 |
buf = BytesIO()
|
|
|
|
| 5 |
import re
|
| 6 |
from io import BytesIO
|
| 7 |
import tempfile
|
| 8 |
+
from wordcloud import WordCloud, STOPWORDS
|
| 9 |
import matplotlib.pyplot as plt
|
| 10 |
from PIL import Image
|
| 11 |
|
|
|
|
| 74 |
|
| 75 |
def generate_wordcloud(df):
|
| 76 |
text = " ".join(df['texts'].tolist())
|
| 77 |
+
stopwords = set(STOPWORDS)
|
| 78 |
+
wordcloud = WordCloud(width=1000, height=500, background_color='white', max_words=300, collocations=False, min_font_size=5, max_font_size=100, prefer_horizontal=1.0, stopwords=stopwords).generate(text)
|
| 79 |
+
plt.figure(figsize=(15, 7))
|
| 80 |
plt.imshow(wordcloud, interpolation='bilinear')
|
| 81 |
plt.axis('off')
|
| 82 |
buf = BytesIO()
|