Spaces:
Runtime error
Runtime error
import joblib | |
import pandas as pd | |
import streamlit as st | |
SPENDING_DICT = {'Low': 1, | |
'Average': 2, | |
'High': 3, | |
} | |
model = joblib.load('model.joblib')# | |
unique_values = joblib.load('unique_value.joblib')# | |
unique_gender = unique_values["Gender"] | |
unique_married = unique_values["Ever_Married"] | |
unique_graduated = unique_values["Graduated"] | |
unique_profession = unique_values["Profession"] | |
unique_spending = unique_values["Spending_Score"] | |
def main(): | |
st.title("Segmentation") | |
with st.form("questionaire"): | |
gender = st.selectbox("Gender",options=unique_gender)# user's input | |
married = st.selectbox("Married",options=unique_married)# user's input | |
age = st.slider("Age",min_value=10,max_value=60)# user's input | |
graduated = st.selectbox("Graduated",options=unique_graduated)# user's input | |
profession = st.selectbox("Profession",options=unique_profession)# user's input | |
workEX = st.slider("Work Experience",min_value=0,max_value=15)# user's input | |
spending = st.selectbox("Spending Score",options=unique_spending)# user's input | |
family = st.slider("Family",min_value=0,max_value=10)# user's input | |
clicked = st.form_submit_button("Predict segmentation") | |
if clicked: | |
result=model.predict(pd.DataFrame({"Age": [age], | |
"Work_Experience": [workEX], | |
"Spending_Score": [SPENDING_DICT[spending]], | |
"Gender": [gender], | |
"Graduated": [graduated], | |
"Profession": [profession], | |
"Ever_Married": [married], | |
"Family_Size": [family]})) | |
result = "A" if result[0] == 0 else "Not A" | |
st.success("Your segmentation is "+result) | |
if __name__=="__main__": | |
main() | |
## |