Spaces:
Runtime error
Runtime error
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() |