tanish78 commited on
Commit
ab778b5
·
verified ·
1 Parent(s): 6eb917c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
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
- wordcloud = WordCloud(width=800, height=400, background_color='white', max_words=200, collocations=False).generate(text)
78
- plt.figure(figsize=(10, 5))
 
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()