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()