Update app.py
Browse files
app.py
CHANGED
@@ -95,26 +95,27 @@ with col2:
|
|
95 |
st.markdown("---")
|
96 |
st.title("📊 Violation Analysis Dashboard")
|
97 |
if st.session_state.history:
|
98 |
-
df = pd.DataFrame(st.session_state.history)
|
99 |
-
# 饼图
|
100 |
-
label_counts = df["label"].value_counts().reset_index()
|
101 |
-
label_counts.columns = ["Category", "Count"]
|
102 |
-
fig = px.pie(label_counts, names="Category", values="Count", title="Offensive Category Distribution")
|
103 |
-
st.plotly_chart(fig)
|
104 |
-
|
105 |
st.markdown("### 🧾 Offensive Terms & Suggestions")
|
106 |
for item in st.session_state.history:
|
107 |
st.markdown(f"- 🔹 **Input:** {item['text']}")
|
108 |
st.markdown(f" - ✨ **Translated:** {item['translated']}")
|
109 |
st.markdown(f" - ❗ **Label:** {item['label']} with **{item['score']:.2%}** confidence")
|
110 |
-
st.markdown(f" - 🔧 **Suggestion:** {item['reason']}")
|
111 |
|
112 |
# 雷达图演示示例(可替换为动态数据)
|
113 |
radar_df = pd.DataFrame({
|
114 |
"Category": ["Insult", "Abuse", "Discrimination", "Hate Speech", "Vulgarity"],
|
115 |
"Score": [0.7, 0.4, 0.3, 0.5, 0.6]
|
116 |
})
|
117 |
-
radar_fig = px.line_polar(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
st.plotly_chart(radar_fig)
|
119 |
else:
|
120 |
-
st.info("⚠️ No classification data available yet.")
|
|
|
95 |
st.markdown("---")
|
96 |
st.title("📊 Violation Analysis Dashboard")
|
97 |
if st.session_state.history:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
st.markdown("### 🧾 Offensive Terms & Suggestions")
|
99 |
for item in st.session_state.history:
|
100 |
st.markdown(f"- 🔹 **Input:** {item['text']}")
|
101 |
st.markdown(f" - ✨ **Translated:** {item['translated']}")
|
102 |
st.markdown(f" - ❗ **Label:** {item['label']} with **{item['score']:.2%}** confidence")
|
103 |
+
st.markdown(f" - 🔧 **Suggestion:** {item['reason']} ")
|
104 |
|
105 |
# 雷达图演示示例(可替换为动态数据)
|
106 |
radar_df = pd.DataFrame({
|
107 |
"Category": ["Insult", "Abuse", "Discrimination", "Hate Speech", "Vulgarity"],
|
108 |
"Score": [0.7, 0.4, 0.3, 0.5, 0.6]
|
109 |
})
|
110 |
+
radar_fig = px.line_polar(
|
111 |
+
radar_df,
|
112 |
+
r='Score',
|
113 |
+
theta='Category',
|
114 |
+
line_close=True,
|
115 |
+
title="⚠️ Risk Radar by Category",
|
116 |
+
color_discrete_sequence=['yellow'],
|
117 |
+
template='simple_white'
|
118 |
+
)
|
119 |
st.plotly_chart(radar_fig)
|
120 |
else:
|
121 |
+
st.info("⚠️ No classification data available yet.")
|