File size: 1,776 Bytes
1821852
 
02fc6c2
1821852
0ec4a84
 
 
 
 
4636526
 
 
 
1821852
 
 
 
 
 
 
 
 
 
 
 
 
 
4636526
1821852
 
 
 
 
 
 
 
 
 
27fab8c
1821852
 
 
 
 
 
 
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
import joblib
import pandas as pd
import streamlit as st

dist_dict = {'0-1 Miles' : 1,
             '1-2 Miles' : 2,
             '2-5 Miles' : 3,
             '5-10 Miles' : 4,
             '10+ Miles' : 5}

model = joblib.load('model.joblib')
unique_values = joblib.load('unique_values.joblib')

unique_Marital_Status =  unique_values["Marital Status"]
unique_Gender =  unique_values["Gender"]
unique_Home_Owner =  unique_values["Home Owner"]
unique_Region =  unique_values["Region"]
unique_Commute_Distance =  unique_values["Commute Distance"]


def main():
    st.title("Bike buyer")

    with st.form("questionaire"):
        Marital_Status = st.selectbox("Marital Status", options=unique_Marital_Status)
        Gender = st.selectbox("Gender", options=unique_Gender)
        Home_Owner = st.selectbox("Home Owner", options=unique_Home_Owner)
        Region = st.selectbox("Region", options=unique_Region)
        Commute_Distance = st.selectbox("Commute Distance", options=unique_Commute_Distance)
        Age = st.slider("Age", min_value=0, max_value=100)


        # clicked==True only when the button is clicked
        clicked = st.form_submit_button("Predict bike buyer")
        if clicked:
            result=model.predict(pd.DataFrame({"Marital Status": [Marital_Status],
                                               "Gender": [Gender],
                                               "Home Owner": [Home_Owner],
                                               "Region" : [Region],
                                               "Commute Distance": [Commute_Distance],
                                               "Age": [Age]}))
            # Show prediction
            st.success("Purchased Bike", result)
# Run main()
if __name__ == "__main__":
    main()