Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -81,15 +81,22 @@ if st.button("🔮 開始預測"):
|
|
81 |
st.subheader("🧠 模型決策解釋圖(SHAP Waterfall plot)")
|
82 |
|
83 |
shap_values = explainer(input_df)
|
84 |
-
ax = shap.plots.waterfall(shap_values[0], show=False)
|
85 |
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
|
94 |
st.pyplot(ax.figure)
|
95 |
plt.close(ax.figure)
|
|
|
81 |
st.subheader("🧠 模型決策解釋圖(SHAP Waterfall plot)")
|
82 |
|
83 |
shap_values = explainer(input_df)
|
|
|
84 |
|
85 |
+
# 改 feature_names
|
86 |
+
feature_name_map = {
|
87 |
+
"航線組合數": "Route Count",
|
88 |
+
"年": "Year",
|
89 |
+
"月": "Month",
|
90 |
+
"船舶種類_編碼": "Ship Type Code"
|
91 |
+
}
|
92 |
+
shap_values.feature_names = [feature_name_map.get(f, f) for f in shap_values.feature_names]
|
93 |
+
|
94 |
+
ax = shap.plots.waterfall(shap_values[0], show=False)
|
95 |
+
|
96 |
+
# 負號替換
|
97 |
+
for text in ax.texts:
|
98 |
+
if text.get_text().startswith('\u2212'):
|
99 |
+
text.set_text(text.get_text().replace('\u2212', '-'))
|
100 |
|
101 |
st.pyplot(ax.figure)
|
102 |
plt.close(ax.figure)
|