naufalnashif
commited on
Commit
•
31d2328
1
Parent(s):
4a3ec7a
Update app.py
Browse files
app.py
CHANGED
@@ -254,11 +254,10 @@ with st.expander("General Settings :"):
|
|
254 |
texts = df['Text'] # Sesuaikan dengan nama kolom di berkas XLSX Anda
|
255 |
if 'Date' in df.columns :
|
256 |
dates = df['Date']
|
|
|
257 |
#-----------------------------------------------------Preference Settings--------------------------------------------------
|
258 |
with st.expander ("Preference Settings :"):
|
259 |
colormap = st.selectbox("Pilih Warna Wordclouds :", ["Greys", "Purples", "Blues", "Greens", "Oranges", "Reds", "YlOrBr", "YlOrRd", "OrRd", "PuRd", "RdPu", "BuPu", "GnBu", "PuBu", "YlGnBu", "PuBuGn", "BuGn", "YlGn"])
|
260 |
-
if dates:
|
261 |
-
target_year = st.selectbox("Pilih Tahun Bar Chart :", (2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025), index = 5)
|
262 |
# Analisis sentimen
|
263 |
results = []
|
264 |
analisis = False
|
@@ -341,28 +340,29 @@ if results and analisis == True:
|
|
341 |
if 'Date' in df_results.columns:
|
342 |
with columns[1]:
|
343 |
buat_chart(df_results, target_year)
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
|
|
366 |
|
367 |
# Menampilkan hasil analisis sentimen dalam kotak yang dapat diperluas
|
368 |
with st.expander("Hasil Analisis Sentimen"):
|
|
|
254 |
texts = df['Text'] # Sesuaikan dengan nama kolom di berkas XLSX Anda
|
255 |
if 'Date' in df.columns :
|
256 |
dates = df['Date']
|
257 |
+
target_year = st.selectbox("Pilih Tahun Bar Chart :", dates.unique())
|
258 |
#-----------------------------------------------------Preference Settings--------------------------------------------------
|
259 |
with st.expander ("Preference Settings :"):
|
260 |
colormap = st.selectbox("Pilih Warna Wordclouds :", ["Greys", "Purples", "Blues", "Greens", "Oranges", "Reds", "YlOrBr", "YlOrRd", "OrRd", "PuRd", "RdPu", "BuPu", "GnBu", "PuBu", "YlGnBu", "PuBuGn", "BuGn", "YlGn"])
|
|
|
|
|
261 |
# Analisis sentimen
|
262 |
results = []
|
263 |
analisis = False
|
|
|
340 |
if 'Date' in df_results.columns:
|
341 |
with columns[1]:
|
342 |
buat_chart(df_results, target_year)
|
343 |
+
else :
|
344 |
+
# Kolom kedua untuk Bar Chart
|
345 |
+
with columns[1]:
|
346 |
+
st.write("Bar Chart :")
|
347 |
+
# Menentukan warna untuk setiap kategori dalam kolom 'score'
|
348 |
+
warna_label = {
|
349 |
+
'Negatif': '#FF9AA2',
|
350 |
+
'Netral': '#FFDAC1',
|
351 |
+
'Positif': '#B5EAD7'
|
352 |
+
}
|
353 |
+
# Menyiapkan label kelas
|
354 |
+
class_labels = ["Negatif", "Netral", "Positif"]
|
355 |
+
|
356 |
+
# Menghitung nilai hitungan per label
|
357 |
+
value_counts = df_results["label"].value_counts()
|
358 |
+
|
359 |
+
# Mengurutkan nilai hitungan berdasarkan label
|
360 |
+
value_counts = value_counts.reindex(class_labels)
|
361 |
+
|
362 |
+
st.bar_chart(
|
363 |
+
x=value_counts.index, y=value_counts.values,
|
364 |
+
color=[warna_label[label] for label in class_labels]
|
365 |
+
)
|
366 |
|
367 |
# Menampilkan hasil analisis sentimen dalam kotak yang dapat diperluas
|
368 |
with st.expander("Hasil Analisis Sentimen"):
|