File size: 970 Bytes
382a39b
64a481a
03e4bb7
64a481a
03e4bb7
64a481a
03e4bb7
 
 
 
 
 
64a481a
03e4bb7
 
 
 
 
 
 
 
 
64a481a
03e4bb7
 
 
 
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
import streamlit as st
import pandas as pd
import joblib

# Load the pre-trained model

# Define the input widgets
age = st.slider('Age', 18, 99, 25)
gender = st.selectbox('Gender', ['Male', 'Female'])
smoker = st.selectbox('Smoker', ['Yes', 'No'])
region = st.selectbox('Region', ['Northeast', 'Northwest', 'Southeast', 'Southwest'])
bmi = st.number_input('BMI', min_value=10.0, max_value=50.0, step=0.1)

# Define a function to make the prediction
def predict(age, gender, smoker, region, bmi):
    data = pd.DataFrame({'age': [age],
                         'sex': [gender],
                         'smoker': [smoker],
                         'region': [region],
                         'bmi': [bmi]})
    prediction = model.predict(data)[0]
    return prediction

# Call the predict function and display the result
if st.button('Predict'):
    result = predict(age, gender, smoker, region, bmi)
    st.write('The predicted insurance cost is $', round(result, 2))