| 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 Prediction App") | |
| age = st.number_input("Enter your age: ", | |
| min_value = 5, max_value=70, | |
| value= 25, step = 1) | |
| 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 kg: ", | |
| min_value = 20.0, max_value=200.0, | |
| value= 70.0, step = 0.5) | |
| bmi = weight / (height/100)**2 | |
| st.write(f"Your BMI is {round(bmi,2)}") | |
| children = st.selectbox( | |
| "Enter number of children: ", | |
| (0,1,2,3,4,5) | |
| ) | |
| smoker = st.selectbox( | |
| "Smoking status: ", | |
| ("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_scaler = joblib.load("std_scaler_joblib.pkl") | |
| if st.button("Submit"): | |
| poly_test = poly.transform(test_data) | |
| std_test = std_scaler.transform(poly_test) | |
| y_pred_sqrt = model.predict(std_test) | |
| y_pred = round((y_pred_sqrt**2)[0],2) | |
| st.write(f"### Your Insurance Premium is ${y_pred}") |