GS123's picture
Upload 5 files
85ae9b4 verified
raw
history blame contribute delete
973 Bytes
import streamlit as st
import numpy as np
import joblib
st.title("Premium prediction app")
st.image("banner.jpg")
age = st.number_input("Enter your age", value = 30, step = 1)
gender = st.selectbox(label = "Select gender", options = ["Male", "Female"])
bmi = st.number_input("enter your bmi", value = 22.1, step = .1)
children = st.selectbox(label = "Select number of children", options = [0,1,2,3,4,5])
smoker = st.selectbox(label = "Smoking status", options = ["yes", "no"])
gender_num = 0 if gender == "Male" else 1
smoker_num = 0 if smoker == "no" else 1
test_data = np.array([[age, bmi, children, smoker_num]])
poly = joblib.load("poly_obj")
model = joblib.load("insurance_joblib")
submit_bn = st.button("Submit")
if submit_bn:
test_poly = poly.transform(test_data)
y_pred_log = model.predict(test_poly)
y_pred = np.exp(y_pred_log)
st.write(f"## Insurance Premium Amount: ${np.round(y_pred[0], 2)}")