File size: 1,404 Bytes
25a0c38
 
0f04e34
25a0c38
 
 
0f04e34
 
25a0c38
 
0f04e34
 
 
25a0c38
0f04e34
25a0c38
 
0f04e34
 
 
9b9ef7a
0f04e34
 
 
25a0c38
 
0f04e34
25a0c38
 
 
0f04e34
 
 
 
9b9ef7a
 
0f04e34
 
25a0c38
 
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
import joblib
import pandas as pd
import streamlit as st



model = joblib.load('model.joblib')
unique_values = joblib.load('unique_values.joblib')
    
unique_sex =  unique_values["sex"]
unique_smoker =  unique_values["smoker"]
unique_region =  unique_values["region"]

def main():
    st.title("medical expenses")

    with st.form("questionaire"):
        age = st.slider("Age", min_value =10,max_value=100)
        sex = st.selectbox("Sex", options=unique_sex)
        bmi = st.slider("Bmi",min_value=10,max_value=100)
        children = st.slider("Children", min_value=0,max_value=10)
        smoker = st.selectbox("Smoker", options=unique_smoker)
        region = st.selectbox("Region",options=unique_region)
        

        # clicked==True only when the button is clicked
        clicked = st.form_submit_button("Predict medical expenses")
        if clicked:
            result=model.predict(pd.DataFrame({"age": [age],
                                               "sex": [sex],
                                               "bmi": [bmi],
                                               "children": [children],
                                               "smoker": [smoker],
                                               "region": [region]}))
            st.success(f"You predict medical expenses is {result}")
            
if __name__ == "__main__":
    main()            

# Run main()