Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import joblib
|
2 |
+
import pandas as pd
|
3 |
+
import streamlist as st
|
4 |
+
|
5 |
+
|
6 |
+
model = joblib.load('model.joblib')
|
7 |
+
unique_values = joblib.load('unique_values.joblib')
|
8 |
+
|
9 |
+
unique_Marital_Status = unique_values["Marital Status"]
|
10 |
+
unique_Gender = unique_values["Gender"]
|
11 |
+
unique_Occupation = unique_values["Occupation"]
|
12 |
+
unique_Home_Owner = unique_values["Home Owner"]
|
13 |
+
unique_Region = unique_values["Region"]
|
14 |
+
unique_Education = unique_values["Education"]
|
15 |
+
unique_Commute_Distance = unique_values["Commute Distance"]
|
16 |
+
|
17 |
+
|
18 |
+
def main():
|
19 |
+
st.title("Bike buyer")
|
20 |
+
|
21 |
+
with st.form("questionaire"):
|
22 |
+
Marital_Status = st.selectbox("Marital Status", options=unique_Marital_Status)
|
23 |
+
Gender = st.selectbox("Gender", options=unique_Gender)
|
24 |
+
Education = st.selectbox("Education", options=unique_Education)
|
25 |
+
Occupation = st.selectbox("Occupation", options=unique_Occupation)
|
26 |
+
Home_Owner = st.selectbox("Home Owner", options=unique_Home_Owner)
|
27 |
+
Commute_Distance = st.selectbox("Commute Distance", options=unique_Commute_Distance)
|
28 |
+
Age = st.slider("Age", min_value=0, max_value=100)
|
29 |
+
|
30 |
+
|
31 |
+
# clicked==True only when the button is clicked
|
32 |
+
clicked = st.form_submit_button("Predict bike buyer")
|
33 |
+
if clicked:
|
34 |
+
result=model.predict(pd.DataFrame({"Marital Status": [Marital_Status],
|
35 |
+
"Gender": [Gender],
|
36 |
+
"Education": [Education],
|
37 |
+
"Occupation": [Occupation],
|
38 |
+
"Home Owner": [Home_Owner],
|
39 |
+
"Commute Distance": [Commute_Distance],
|
40 |
+
"Age": [Age]}))
|
41 |
+
# Show prediction
|
42 |
+
st.success(f"Purchased Bike {result}")
|
43 |
+
# Run main()
|
44 |
+
if __name__ == "__main__":
|
45 |
+
main()
|