|
|
import streamlit as st |
|
|
import joblib |
|
|
import numpy as np |
|
|
|
|
|
|
|
|
model = joblib.load("src/insurance_analysis_model") |
|
|
|
|
|
st.title(":orange[Insurance Premium Predictor 💰]") |
|
|
|
|
|
|
|
|
age = st.slider("Age", 18, 100, step=1) |
|
|
bmi = st.number_input("BMI", min_value=10.0, max_value=50.0, step=0.1) |
|
|
children = st.number_input("Number of Children", min_value=0, max_value=10, step=1) |
|
|
sex = st.selectbox("Sex", ["male", "female"]) |
|
|
smoker = st.selectbox("Smoker", ["yes", "no"]) |
|
|
region = st.selectbox("Region", ["northeast", "southeast", "southwest", "northwest"]) |
|
|
|
|
|
|
|
|
sex_val = 1 if sex == "male" else 0 |
|
|
smoker_val = 1 if smoker == "yes" else 0 |
|
|
region_val = {"northeast": 0, "southeast": 1, "southwest": 2, "northwest": 3}[region] |
|
|
|
|
|
|
|
|
if st.button("Predict"): |
|
|
st.snow() |
|
|
input_data = np.array([[age, bmi, children, sex_val, smoker_val, region_val]]) |
|
|
prediction = model.predict(input_data)[0] |
|
|
prediction = float(prediction) |
|
|
st.success(f"Predicted Insurance Premium: 💲{round(prediction, 2)}") |
|
|
|
|
|
|