layout fix again

This commit is contained in:
Jesselyn Mu
2025-01-30 21:51:56 +07:00
parent 1ea0ebced9
commit 49f1f93bd9

View File

@ -463,37 +463,40 @@ def show_prediction():
with col1: with col1:
# st.image(buf, caption="SHAP Waterfall Plot", use_container_width=True) # st.image(buf, caption="SHAP Waterfall Plot", use_container_width=True)
# Tambahkan CSS styling ke HTML
st.markdown( st.markdown(
f""" """
<style> <style>
.shap-container {{ .shap-container {
display: flex; display: flex;
justify-content: center; justify-content: center;
}} align-items: center;
.shap-image {{ margin-top: 10px;
border-radius: 10px; /* Biar sudutnya membulat */ }
.shap-image {
border-radius: 10px; /* Sudut membulat */
box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.2); /* Shadow */ box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.2); /* Shadow */
border: 2px solid #ddd; /* Stroke */ border: 2px solid #ddd; /* Stroke */
padding: 5px; /* Ruang di dalam border */ padding: 5px; /* Ruang di dalam border */
background: white; /* Biar keliatan efeknya */ background: white; /* Biar keliatan efeknya */
max-width: 100%; /* Biar responsif */ max-width: 100%; /* Biar responsif */
}} }
.shap-caption {{ .shap-caption {
text-align: center; text-align: center;
font-size: 14px; font-size: 14px;
font-family: 'Poppins', sans-serif; font-family: 'Poppins', sans-serif;
color: #555; color: #555;
margin-top: 5px; margin-top: 5px;
}} }
</style> </style>
<div class="shap-container">
<img class="shap-image" src="data:image/png;base64,{buf.getvalue().decode('utf-8')}" alt="SHAP Waterfall Plot">
</div>
<p class="shap-caption">SHAP Waterfall Plot</p>
""", """,
unsafe_allow_html=True unsafe_allow_html=True
) )
# Gunakan `st.image()` untuk menampilkan gambar SHAP dari `buf`
st.markdown('<div class="shap-container">', unsafe_allow_html=True)
st.image(buf, caption="SHAP Waterfall Plot", use_container_width=True)
st.markdown('</div>', unsafe_allow_html=True)
with col2: with col2:
top_factors = sorted(shap_dict.items(), key=lambda x: abs(x[1]), reverse=True)[:5] top_factors = sorted(shap_dict.items(), key=lambda x: abs(x[1]), reverse=True)[:5]