File size: 1,892 Bytes
a85234e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import joblib
import pandas as pd
import streamlist as st


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_Occupation =  unique_values["Occupation"]
unique_Home_Owner =  unique_values["Home Owner"]
unique_Region =  unique_values["Region"]
unique_Education =  unique_values["Education"]
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)
        Education = st.selectbox("Education", options=unique_Education)
        Occupation = st.selectbox("Occupation", options=unique_Occupation)
        Home_Owner = st.selectbox("Home Owner", options=unique_Home_Owner)
        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],
                                               "Education": [Education],
                                               "Occupation": [Occupation],
                                               "Home Owner": [Home_Owner],
                                               "Commute Distance": [Commute_Distance],
                                               "Age": [Age]}))
            # Show prediction
            st.success(f"Purchased Bike {result}")
# Run main()
if __name__ == "__main__":
    main()