Spaces:
Running
Running
delete fungsi yang tidak digunakan pada app.py and visualization.py
Browse files- app.py +0 -1
- visualization.py +1 -42
app.py
CHANGED
|
@@ -31,7 +31,6 @@ from visualization import (
|
|
| 31 |
show_sentiment_by_semester,
|
| 32 |
show_sentiment_by_prodi,
|
| 33 |
show_sentiment_by_top10_matkul,
|
| 34 |
-
show_sentiment_stacked_percentage,
|
| 35 |
)
|
| 36 |
from preprocessing import text_preprocessing_pipeline
|
| 37 |
|
|
|
|
| 31 |
show_sentiment_by_semester,
|
| 32 |
show_sentiment_by_prodi,
|
| 33 |
show_sentiment_by_top10_matkul,
|
|
|
|
| 34 |
)
|
| 35 |
from preprocessing import text_preprocessing_pipeline
|
| 36 |
|
visualization.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
"""
|
| 2 |
-
|
| 3 |
----------------------
|
| 4 |
Berisi fungsi-fungsi untuk menampilkan berbagai visualisasi data kritik dan saran
|
| 5 |
dalam bentuk bar chart, pie chart, serta distribusi berdasarkan tahun, semester,
|
|
@@ -325,44 +325,3 @@ def show_sentiment_by_top10_matkul(df, aspek_columns):
|
|
| 325 |
)
|
| 326 |
st.plotly_chart(fig, use_container_width=True, config=config_options)
|
| 327 |
return True
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
def show_sentiment_stacked_percentage(df, aspek_columns):
|
| 331 |
-
"""Menampilkan stacked bar chart dengan persentase sentimen per aspek."""
|
| 332 |
-
|
| 333 |
-
if df.empty or not set(aspek_columns).issubset(df.columns):
|
| 334 |
-
st.warning("Data atau kolom aspek tidak tersedia.")
|
| 335 |
-
return
|
| 336 |
-
|
| 337 |
-
df_long = df.melt(
|
| 338 |
-
value_vars=aspek_columns,
|
| 339 |
-
var_name="aspek",
|
| 340 |
-
value_name="sentimen"
|
| 341 |
-
)
|
| 342 |
-
|
| 343 |
-
# Hitung persentase
|
| 344 |
-
count_data = df_long.groupby(
|
| 345 |
-
['aspek', 'sentimen']).size().reset_index(name='jumlah')
|
| 346 |
-
total_per_aspek = count_data.groupby('aspek')['jumlah'].sum().reset_index()
|
| 347 |
-
total_per_aspek.columns = ['aspek', 'total']
|
| 348 |
-
count_data = count_data.merge(total_per_aspek, on='aspek')
|
| 349 |
-
count_data['persentase'] = (
|
| 350 |
-
count_data['jumlah'] / count_data['total']) * 100
|
| 351 |
-
|
| 352 |
-
fig = px.bar(
|
| 353 |
-
count_data,
|
| 354 |
-
x="aspek",
|
| 355 |
-
y="persentase",
|
| 356 |
-
color="sentimen",
|
| 357 |
-
title="Persentase Distribusi Sentimen per Aspek",
|
| 358 |
-
color_discrete_map=sentimen_palette,
|
| 359 |
-
category_orders={
|
| 360 |
-
"sentimen": category_order,
|
| 361 |
-
"aspek": aspek_columns
|
| 362 |
-
}
|
| 363 |
-
)
|
| 364 |
-
fig.update_layout(
|
| 365 |
-
yaxis_title="Persentase (%)",
|
| 366 |
-
xaxis_title="Aspek"
|
| 367 |
-
)
|
| 368 |
-
st.plotly_chart(fig, use_container_width=True, config=config_options)
|
|
|
|
| 1 |
"""
|
| 2 |
+
visualization.py
|
| 3 |
----------------------
|
| 4 |
Berisi fungsi-fungsi untuk menampilkan berbagai visualisasi data kritik dan saran
|
| 5 |
dalam bentuk bar chart, pie chart, serta distribusi berdasarkan tahun, semester,
|
|
|
|
| 325 |
)
|
| 326 |
st.plotly_chart(fig, use_container_width=True, config=config_options)
|
| 327 |
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|