amirsoahil101's picture
add all files
b951f95
Raw
History Blame Contribute Delete
1.38 kB
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}")