jung-ming commited on
Commit
b591b01
·
verified ·
1 Parent(s): 75c5c29

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -80,15 +80,16 @@ if st.button("🔮 開始預測"):
80
 
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)
@@ -98,5 +99,6 @@ 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)
 
 
80
 
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
+
93
  shap_values.feature_names = [feature_name_map.get(f, f) for f in shap_values.feature_names]
94
 
95
  ax = shap.plots.waterfall(shap_values[0], show=False)
 
99
  if text.get_text().startswith('\u2212'):
100
  text.set_text(text.get_text().replace('\u2212', '-'))
101
 
102
+ st.pyplot(ax.figure)
103
+ plt.close(ax.figure)
104
+