Spaces:
Runtime error
Runtime error
File size: 2,031 Bytes
2ccb973 32adc7d 2ccb973 e6f7712 2ccb973 2b23c3e f02b4e0 2ccb973 2b23c3e 2ccb973 2b23c3e 2ccb973 2b23c3e 2ccb973 2b23c3e 2ccb973 af10ec0 989a094 9824fa1 af10ec0 81eeb6d 2456bb6 2b23c3e 7ef05e0 62c99bf |
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 46 47 48 |
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()
## |