GS123's picture
Upload 7 files
eb59f85 verified
import streamlit as st
import joblib
import numpy as np
model = joblib.load("hdfc_life_final_model.joblib")
poly_obj = joblib.load("polynomial_object.joblib")
col1, col2 = st.columns([0.2,0.8])
with col1:
st.image("HDFC-Life-Logo.png")
with col2:
st.header("Premium Prediction App")
st.image("banner.jpg")
age = st.number_input("Enter your Age", min_value=0,
max_value= 100,step = 1,
value= 30)
label, ft_col, in_col = st.columns([0.4,0.3,0.3])
with label:
st.write("Enter your height in Feet and inches")
with ft_col:
feet = st.number_input("Feet",min_value=0, max_value=11,
value = 5,step = 1)
with in_col:
inches = st.number_input("Inches",min_value=0, max_value=11,
value = 8,step = 1)
weight = st.number_input("Enter your Weight in KG", min_value=0, max_value=150,
value = 80, step=1)
height_meter = feet*0.3048 + inches*0.0254
bmi = weight/(height_meter)**2
# Determine BMI category
if bmi < 18.5:
category = "Underweight"
elif 18.5 <= bmi < 25:
category = "Normal weight"
elif 25 <= bmi < 30:
category = "Overweight"
elif 30 <= bmi < 35:
category = "Obesity Class I (Moderate)"
elif 35 <= bmi < 40:
category = "Obesity Class II (Severe)"
else:
category = "Obesity Class III (Very severe)"
# Display result in Streamlit
st.write(f"Your BMI is: {round(bmi, 2)}, Category: **{category}**")
children = st.slider("Enter Number of Children", min_value=0, max_value=5,
value = 0, step = 1)
smoker = st.selectbox("Enter Smoking status",["Yes", "No"])
smoker_num = 1 if smoker == "Yes" else 0
test_data = [[age, bmi, children, smoker_num]]
if st.button("Get Premium"):
poly_data = poly_obj.transform(test_data)
y_pred_log = model.predict(poly_data)
y_pred = np.exp(y_pred_log)
st.write(f"**Your Premium Amount is: ${round(y_pred[0],2)}**")