ins_app / app.py
Garvit893's picture
Upload 9 files
6b5e942 verified
import streamlit as st
import numpy as np
import joblib
st.image('banner.jpg')
col1, col2 = st.columns([1,3])
col1.image('logo.png')
col2.title("Insurance Premium Predction App")
age= st.number_input("Enter Your Age:",
min_value= 5.0, max_value= 75.0, value= 25.0, step =1.0)
height= st.number_input('Enter Your Height in cms: ',
min_value= 100.0, max_value= 350.0, value=167.0, step= 0.5)
weight= st.number_input('Enter Your Weight in kgs: ',
min_value=20.0, max_value=250.0, value= 75.0, step=0.5)
bmi= round(weight/((height/100)**2),2)
st.write(f'Your Body Mass Index is: {bmi}')
children= st.selectbox(
'Enter number of children: ', (0,1,2,3,4,5)
)
smoker= st.selectbox(
'Addicted to Smoking: ', ('Yes', 'No')
)
smoker_num= 0 if smoker== 'No' else 1
test_data= [[age, bmi, children, smoker_num]]
model= joblib.load('hdfc_ergo_model_joblib.pkl')
poly= joblib.load('poly_joblib.pkl')
std_scalar= joblib.load('std_scalar_joblib.pkl')
if st.button('Calculate'):
poly_test= poly.transform(test_data)
std_test= std_scalar.transform(poly_test)
y_pred_sqrt = model.predict(std_test)
ypred= round((y_pred_sqrt**2)[0],2)
st.write(f'Your Insurance Premium is: ${ypred}')