Spaces:
Runtime error
Runtime error
Update app.py
Browse files207 unmodified lines208209210211212213214207 unmodified linesshap.plots.beeswarm(shap_values, max_display=10)fig_shap = plt.gcf()st.pyplot(fig_shap)# 衛教建議st.subheader("📝 衛教建議")categorize_risk = create_categorize_risk_fn(0.75, 0.4)207 unmodified lines208209210211212213214215216217218219220221222223224225226227228207 unmodified linesshap.plots.beeswarm(shap_values, max_display=10)fig_shap = plt.gcf()st.pyplot(fig_shap)st.subheader("📑 全部 1000 人預測與分級")all_proba = model.predict_proba(X)[:, 1]data["預測機率"] = all_probadata["風險等級"] = data["預測機率"].apply(categorize_risk)st.dataframe(data[["年齡", "性別", "預測機率", "風險等級"]])# 匯出按鈕def to_excel(df):output = BytesIO()with pd.ExcelWriter(output, engine="xlsxwriter") as writer:df.to_excel(writer, index=False)output.seek(0)return outputst.download_button("下載全部預測名單", data=to_excel(data), file_name="all_fallrisk_pred.xlsx")# 衛教建議st.subheader("📝 衛教建議")categorize_risk = create_categorize_risk_fn(0.75, 0.4)
app.py+15-1