tanish78 commited on
Commit
911b2cf
·
verified ·
1 Parent(s): 9586bba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -3
app.py CHANGED
@@ -117,7 +117,6 @@ def cluster_data(df, num_clusters):
117
 
118
  return df, kmeans
119
 
120
-
121
  def generate_wordcloud(df):
122
  text = " ".join(df['texts'].tolist())
123
  stopwords = set(STOPWORDS)
@@ -153,6 +152,7 @@ def generate_bar_chart(df, num_clusters_to_display):
153
 
154
  category_top_words = df_top_categories.groupby('Category', observed=False)['texts'].apply(lambda x: ' '.join(x)).reset_index()
155
  category_top_words['top_word'] = category_top_words['texts'].apply(lambda x: ' '.join([word for word in pd.Series(x.split()).value_counts().index if word not in common_words][:3]))
 
156
  category_sizes = df_top_categories['Category'].value_counts().reset_index()
157
  category_sizes.columns = ['Category', 'Count']
158
  category_sizes = category_sizes.merge(category_top_words[['Category', 'top_word']], on='Category')
@@ -175,7 +175,6 @@ def main(file, num_clusters_to_display):
175
 
176
  df = preprocess_data(df)
177
 
178
-
179
  wordcloud_img = generate_wordcloud(df)
180
  bar_chart_img = generate_bar_chart(df, num_clusters_to_display)
181
 
@@ -200,7 +199,7 @@ interface = gr.Interface(
200
  gr.Image(label="Bar Chart")
201
  ],
202
  title="Unanswered User Queries Categorization",
203
- description="Categorize unanswered user queries into predefined categories"
204
  )
205
 
206
  interface.launch(share=True)
 
117
 
118
  return df, kmeans
119
 
 
120
  def generate_wordcloud(df):
121
  text = " ".join(df['texts'].tolist())
122
  stopwords = set(STOPWORDS)
 
152
 
153
  category_top_words = df_top_categories.groupby('Category', observed=False)['texts'].apply(lambda x: ' '.join(x)).reset_index()
154
  category_top_words['top_word'] = category_top_words['texts'].apply(lambda x: ' '.join([word for word in pd.Series(x.split()).value_counts().index if word not in common_words][:3]))
155
+
156
  category_sizes = df_top_categories['Category'].value_counts().reset_index()
157
  category_sizes.columns = ['Category', 'Count']
158
  category_sizes = category_sizes.merge(category_top_words[['Category', 'top_word']], on='Category')
 
175
 
176
  df = preprocess_data(df)
177
 
 
178
  wordcloud_img = generate_wordcloud(df)
179
  bar_chart_img = generate_bar_chart(df, num_clusters_to_display)
180
 
 
199
  gr.Image(label="Bar Chart")
200
  ],
201
  title="Unanswered User Queries Categorization",
202
+ description="Categorize Unanswered User Queries"
203
  )
204
 
205
  interface.launch(share=True)