Commit ·
b951f95
1
Parent(s): 7952a9a
add all files
Browse files- app.py +54 -0
- columns.pkl +3 -0
- model.pkl +3 -0
- scaler.pkl +3 -0
app.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
import streamlit as st
|
| 3 |
+
import numpy as np
|
| 4 |
+
import joblib
|
| 5 |
+
import warnings
|
| 6 |
+
warnings.filterwarnings("ignore")
|
| 7 |
+
|
| 8 |
+
model = joblib.load("model.pkl")
|
| 9 |
+
scaler = joblib.load("scaler.pkl")
|
| 10 |
+
col = joblib.load("columns.pkl")
|
| 11 |
+
|
| 12 |
+
st.set_page_config(page_title="Insurance charges prediction",page_icon="🪙")
|
| 13 |
+
|
| 14 |
+
st.title("Insurance charges prediction 📜💸")
|
| 15 |
+
|
| 16 |
+
age = st.slider("Age",17,100,50)
|
| 17 |
+
sex = st.selectbox("Gender",["female","male"])
|
| 18 |
+
bmi = st.slider("BMI",1.0,30.0,10.0)
|
| 19 |
+
chid = st.number_input("Children",0,10,2)
|
| 20 |
+
smo = st.selectbox("Smoker",["yes","no"])
|
| 21 |
+
reg = st.selectbox("Region",['southwest', 'southeast', 'northwest', 'northeast'])
|
| 22 |
+
# reg = st.selectbox("Region",[0,1])
|
| 23 |
+
bmi_cat = st.selectbox("BMI categor obese",[0,1])
|
| 24 |
+
|
| 25 |
+
if(sex == "female"):
|
| 26 |
+
sex = 1
|
| 27 |
+
else:
|
| 28 |
+
sex = 0
|
| 29 |
+
if(smo == "yes"):
|
| 30 |
+
smo = 1
|
| 31 |
+
else:
|
| 32 |
+
smo = 0
|
| 33 |
+
if(reg == "southeast"):
|
| 34 |
+
reg = 1
|
| 35 |
+
else:
|
| 36 |
+
reg = 0
|
| 37 |
+
|
| 38 |
+
if st.button("predic"):
|
| 39 |
+
user_df = pd.DataFrame([{
|
| 40 |
+
"age":age,
|
| 41 |
+
"is_female":sex,
|
| 42 |
+
"bmi":bmi,
|
| 43 |
+
"children":chid,
|
| 44 |
+
"is_smoker" :smo,
|
| 45 |
+
"region_southeast":reg,
|
| 46 |
+
"bmi_category_Obese":bmi_cat
|
| 47 |
+
}])
|
| 48 |
+
c = ["age","bmi","children"]
|
| 49 |
+
user_df[c] = scaler.transform(user_df[c])
|
| 50 |
+
prediction = model.predict(user_df)[0]
|
| 51 |
+
pred = round(prediction,2)
|
| 52 |
+
# print(prediction)
|
| 53 |
+
st.success(f"Your insurance charges prediction is ₹ {pred}")
|
| 54 |
+
|
columns.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0eb30a212025bd870582199c083d178a53807c0aab166246f68fec1316c3f523
|
| 3 |
+
size 103
|
model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:320122568bd155ac54ff454a04997b481a27ff48575c4660ffae6d1d300ce328
|
| 3 |
+
size 1009
|
scaler.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:99dbf247a2c4e8be343712fdcdfd26c2594f280f14264e2a0d24dae788686bad
|
| 3 |
+
size 943
|