import streamlit as st import joblib import numpy as np # Load the model model = joblib.load("src/insurance_analysis_model") st.title(":orange[Insurance Premium Predictor 💰]") # Input fields 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"]) # Convert to numeric or one-hot 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] # Predict 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) # Convert to float st.success(f"Predicted Insurance Premium: 💲{round(prediction, 2)}")