Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -49,4 +49,46 @@ st.markdown("""
|
|
| 49 |
background-color: rgba(255,255,255,0.85);
|
| 50 |
border-left: 6px solid #28a745;
|
| 51 |
padding: 15px;
|
| 52 |
-
font-size:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
background-color: rgba(255,255,255,0.85);
|
| 50 |
border-left: 6px solid #28a745;
|
| 51 |
padding: 15px;
|
| 52 |
+
font-size: 20px;
|
| 53 |
+
border-radius: 10px;
|
| 54 |
+
text-align: center;
|
| 55 |
+
margin-top: 20px;
|
| 56 |
+
}
|
| 57 |
+
</style>
|
| 58 |
+
""", unsafe_allow_html=True)
|
| 59 |
+
|
| 60 |
+
# Streamlit app
|
| 61 |
+
def main():
|
| 62 |
+
st.markdown('<div class="main-title">Insurance Cost Prediction App</div>', unsafe_allow_html=True)
|
| 63 |
+
st.markdown("##")
|
| 64 |
+
|
| 65 |
+
# Two row layout using columns
|
| 66 |
+
col1, col2, col3 = st.columns(3)
|
| 67 |
+
with col1:
|
| 68 |
+
age = st.number_input("Age", min_value=18, max_value=100, value=30)
|
| 69 |
+
bmi = st.number_input("BMI", min_value=10.0, max_value=50.0, value=25.0)
|
| 70 |
+
|
| 71 |
+
with col2:
|
| 72 |
+
sex = st.selectbox("Sex", encoder["sex"].classes_)
|
| 73 |
+
sex = encoder['sex'].transform([sex])[0]
|
| 74 |
+
children = st.number_input("Children", min_value=0, max_value=10, value=0)
|
| 75 |
+
|
| 76 |
+
with col3:
|
| 77 |
+
smoker = st.selectbox("Smoker", encoder['smoker'].classes_)
|
| 78 |
+
smoker = encoder['smoker'].transform([smoker])[0]
|
| 79 |
+
region = st.selectbox("Region", encoder['region'].classes_)
|
| 80 |
+
region = encoder['region'].transform([region])[0]
|
| 81 |
+
|
| 82 |
+
# Predict button
|
| 83 |
+
if st.button("Predict Insurance Cost"):
|
| 84 |
+
values = [age, sex, bmi, children, smoker, region]
|
| 85 |
+
predict = round(model.predict([values])[0], 2)
|
| 86 |
+
|
| 87 |
+
st.markdown(f"""
|
| 88 |
+
<div class='result-box'>
|
| 89 |
+
💰 <strong>Estimated Insurance Cost:</strong> <span style='color: #28a745;'>${predict}</span>
|
| 90 |
+
</div>
|
| 91 |
+
""", unsafe_allow_html=True)
|
| 92 |
+
|
| 93 |
+
if __name__ == "__main__":
|
| 94 |
+
main()
|