naufalnashif commited on
Commit
00f20fe
·
1 Parent(s): 78cee2e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -9
app.py CHANGED
@@ -10,7 +10,7 @@ from sklearn.feature_extraction.text import TfidfVectorizer
10
  # Impor library tambahan
11
  #import matplotlib.pyplot as plt
12
  #import seaborn as sns
13
- import plotly.express as px
14
  from wordcloud import WordCloud
15
  import nltk
16
  from nltk.corpus import stopwords
@@ -349,7 +349,7 @@ if results and analisis == True:
349
  # Kolom kedua untuk Bar Chart
350
  with columns[1]:
351
  st.write("Bar Chart :")
352
- # Menentukan warna untuk setiap kategori dalam kolom 'label'
353
  warna_label = {
354
  'Negatif': '#FF9AA2',
355
  'Netral': '#FFDAC1',
@@ -359,13 +359,11 @@ if results and analisis == True:
359
  # Menambahkan kolom baru 'color' berdasarkan label
360
  df_results['color'] = df_results['label'].map(warna_label)
361
 
362
- # Membuat bar chart dengan plotly
363
- #fig = px.bar(df_results, x='label', y='label', color='color') # Replace 'value' with the correct column name
364
- # Alternatively, if you want to count the occurrences of each label, you can use:
365
- fig = px.bar(df_results, x='label', y=df_results['label'].value_counts(), color='color')
366
-
367
- # Menampilkan chart menggunakan Streamlit
368
- st.plotly_chart(fig)
369
  # Menampilkan hasil analisis sentimen dalam kotak yang dapat diperluas
370
  with st.expander("Hasil Analisis Sentimen"):
371
  # Tampilkan tabel hasil analisis sentimen
 
10
  # Impor library tambahan
11
  #import matplotlib.pyplot as plt
12
  #import seaborn as sns
13
+ #import plotly.express as px
14
  from wordcloud import WordCloud
15
  import nltk
16
  from nltk.corpus import stopwords
 
349
  # Kolom kedua untuk Bar Chart
350
  with columns[1]:
351
  st.write("Bar Chart :")
352
+ # Menentukan warna untuk setiap kategori dalam kolom 'score'
353
  warna_label = {
354
  'Negatif': '#FF9AA2',
355
  'Netral': '#FFDAC1',
 
359
  # Menambahkan kolom baru 'color' berdasarkan label
360
  df_results['color'] = df_results['label'].map(warna_label)
361
 
362
+ # Membuat bar chart
363
+ st.bar_chart(
364
+ df_results["label"].value_counts(),
365
+ color=df_results['color'].unique().tolist()
366
+ )
 
 
367
  # Menampilkan hasil analisis sentimen dalam kotak yang dapat diperluas
368
  with st.expander("Hasil Analisis Sentimen"):
369
  # Tampilkan tabel hasil analisis sentimen