File size: 1,376 Bytes
b951f95 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | import pandas as pd
import streamlit as st
import numpy as np
import joblib
import warnings
warnings.filterwarnings("ignore")
model = joblib.load("model.pkl")
scaler = joblib.load("scaler.pkl")
col = joblib.load("columns.pkl")
st.set_page_config(page_title="Insurance charges prediction",page_icon="🪙")
st.title("Insurance charges prediction 📜💸")
age = st.slider("Age",17,100,50)
sex = st.selectbox("Gender",["female","male"])
bmi = st.slider("BMI",1.0,30.0,10.0)
chid = st.number_input("Children",0,10,2)
smo = st.selectbox("Smoker",["yes","no"])
reg = st.selectbox("Region",['southwest', 'southeast', 'northwest', 'northeast'])
# reg = st.selectbox("Region",[0,1])
bmi_cat = st.selectbox("BMI categor obese",[0,1])
if(sex == "female"):
sex = 1
else:
sex = 0
if(smo == "yes"):
smo = 1
else:
smo = 0
if(reg == "southeast"):
reg = 1
else:
reg = 0
if st.button("predic"):
user_df = pd.DataFrame([{
"age":age,
"is_female":sex,
"bmi":bmi,
"children":chid,
"is_smoker" :smo,
"region_southeast":reg,
"bmi_category_Obese":bmi_cat
}])
c = ["age","bmi","children"]
user_df[c] = scaler.transform(user_df[c])
prediction = model.predict(user_df)[0]
pred = round(prediction,2)
# print(prediction)
st.success(f"Your insurance charges prediction is ₹ {pred}")
|