Spaces:
Build error
Build error
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +3 -15
src/streamlit_app.py
CHANGED
|
@@ -1,27 +1,17 @@
|
|
| 1 |
-
# python -m streamlit run app.py
|
| 2 |
-
|
| 3 |
import streamlit as st
|
| 4 |
import pandas as pd
|
| 5 |
import plotly.express as px
|
| 6 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
|
| 7 |
import os
|
| 8 |
-
import zipfile
|
| 9 |
-
|
| 10 |
-
if not os.path.exists("Senti_real"):
|
| 11 |
-
base_path = os.path.dirname(os.path.dirname(__file__)) # ขึ้นจาก src ไป root
|
| 12 |
-
zip_path = os.path.join(base_path, "Senti_real.zip")
|
| 13 |
-
with zipfile.ZipFile(zip_path, "r") as zip_ref:
|
| 14 |
-
zip_ref.extractall(base_path)
|
| 15 |
-
|
| 16 |
|
| 17 |
# ---------- CONFIG ----------
|
| 18 |
st.set_page_config(page_title="CheckPD Sentiment Dashboard", layout="wide")
|
| 19 |
st.title("ภาพรวมความรู้สึกของผู้ใช้ CheckPD (Real-time)")
|
| 20 |
|
| 21 |
# ---------- LOAD DATA ----------
|
|
|
|
| 22 |
def load_data():
|
| 23 |
-
|
| 24 |
-
file_path = os.path.join(base_path, "Senti_real", "Sentiment", "checkpd_sentiment.csv")
|
| 25 |
df = pd.read_csv(file_path)
|
| 26 |
return df
|
| 27 |
|
|
@@ -79,7 +69,6 @@ if menu == "Dashboard สรุป":
|
|
| 79 |
st.plotly_chart(fig_total, use_container_width=True)
|
| 80 |
|
| 81 |
st.subheader("3. ข้อความที่ให้ความคิดเห็น (ตามตัวกรอง)")
|
| 82 |
-
|
| 83 |
cols_to_show = [
|
| 84 |
'service_location',
|
| 85 |
'user_feeling_first_use',
|
|
@@ -88,9 +77,8 @@ if menu == "Dashboard สรุป":
|
|
| 88 |
]
|
| 89 |
st.dataframe(df_filtered[cols_to_show], use_container_width=True)
|
| 90 |
|
| 91 |
-
|
| 92 |
elif menu == "Bar Chart เปรียบเทียบความรู้สึก":
|
| 93 |
-
st.subheader("ปรียบเทียบความรู้สึกในแต่ละหมวดด้วย Bar Chart")
|
| 94 |
text_columns = {
|
| 95 |
'user_feeling_first_use_sentiment': 'รู้สึกเมื่อใช้งานครั้งแรก',
|
| 96 |
'staff_emotion_feedback_sentiment': 'รู้สึกต่อเจ้าหน้าที่',
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
import plotly.express as px
|
| 4 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
|
| 5 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
# ---------- CONFIG ----------
|
| 8 |
st.set_page_config(page_title="CheckPD Sentiment Dashboard", layout="wide")
|
| 9 |
st.title("ภาพรวมความรู้สึกของผู้ใช้ CheckPD (Real-time)")
|
| 10 |
|
| 11 |
# ---------- LOAD DATA ----------
|
| 12 |
+
@st.cache_data
|
| 13 |
def load_data():
|
| 14 |
+
file_path = "src/Senti_real/Sentiment/checkpd_sentiment.csv" # ✅ แก้ path ตรงนี้
|
|
|
|
| 15 |
df = pd.read_csv(file_path)
|
| 16 |
return df
|
| 17 |
|
|
|
|
| 69 |
st.plotly_chart(fig_total, use_container_width=True)
|
| 70 |
|
| 71 |
st.subheader("3. ข้อความที่ให้ความคิดเห็น (ตามตัวกรอง)")
|
|
|
|
| 72 |
cols_to_show = [
|
| 73 |
'service_location',
|
| 74 |
'user_feeling_first_use',
|
|
|
|
| 77 |
]
|
| 78 |
st.dataframe(df_filtered[cols_to_show], use_container_width=True)
|
| 79 |
|
|
|
|
| 80 |
elif menu == "Bar Chart เปรียบเทียบความรู้สึก":
|
| 81 |
+
st.subheader("เปรียบเทียบความรู้สึกในแต่ละหมวดด้วย Bar Chart")
|
| 82 |
text_columns = {
|
| 83 |
'user_feeling_first_use_sentiment': 'รู้สึกเมื่อใช้งานครั้งแรก',
|
| 84 |
'staff_emotion_feedback_sentiment': 'รู้สึกต่อเจ้าหน้าที่',
|