molokhovdmitry commited on
Commit
fceb303
1 Parent(s): d51b260

Refactor app.py

Browse files
Files changed (1) hide show
  1. src/app.py +7 -15
src/app.py CHANGED
@@ -303,7 +303,7 @@ with st.form(key='input'):
303
  "Topics (NMF Components)",
304
  min_value=2,
305
  max_value=20,
306
- value=10,
307
  step=1,
308
  )
309
 
@@ -371,13 +371,15 @@ if submit:
371
  emotion_cols = list(df.columns[11:])
372
 
373
  # Get emotion distribution figure
374
- emotion_fig = emotion_dist_plot(df, emotion_cols)
375
-
376
- # TODO: Get emotion contribution figure
377
 
378
  # Get top 2 emotions
379
  df = df.apply(add_top_2_emotions, axis=1)
380
 
 
 
 
 
381
  if nmf_checkbox:
382
  # NMF
383
  df, nmf_figs = nmf_plots(df, nmf_components, tfidf_max_features)
@@ -392,17 +394,7 @@ if submit:
392
  tsne_perplexity)
393
  plots.extend(tsne_figs)
394
 
395
- if map_checkbox:
396
- df = detect_languages(df, lang_model)
397
- map_figure = lang_map(df)
398
-
399
- # Plot all figures
400
- if emotions_checkbox:
401
- st.plotly_chart(emotion_fig, use_container_width=True)
402
-
403
- if map_checkbox:
404
- st.plotly_chart(map_figure, use_container_width=True)
405
-
406
  for i, plot in enumerate(plots):
407
  st.plotly_chart(
408
  plot, sharing='streamlit',
 
303
  "Topics (NMF Components)",
304
  min_value=2,
305
  max_value=20,
306
+ value=8,
307
  step=1,
308
  )
309
 
 
371
  emotion_cols = list(df.columns[11:])
372
 
373
  # Get emotion distribution figure
374
+ plots.append(emotion_dist_plot(df, emotion_cols))
 
 
375
 
376
  # Get top 2 emotions
377
  df = df.apply(add_top_2_emotions, axis=1)
378
 
379
+ if map_checkbox:
380
+ df = detect_languages(df, lang_model)
381
+ plots.append(lang_map(df))
382
+
383
  if nmf_checkbox:
384
  # NMF
385
  df, nmf_figs = nmf_plots(df, nmf_components, tfidf_max_features)
 
394
  tsne_perplexity)
395
  plots.extend(tsne_figs)
396
 
397
+ # Draw the plots
 
 
 
 
 
 
 
 
 
 
398
  for i, plot in enumerate(plots):
399
  st.plotly_chart(
400
  plot, sharing='streamlit',