Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import numpy as np | |
| import joblib | |
| html_temp = """ | |
| <div style="background-color:black;padding:10px"> | |
| <h2 style="color:white;text-align:center;">Customer Clustering App </h2> | |
| </div> | |
| """ | |
| st.markdown(html_temp, unsafe_allow_html=True) | |
| image_url="https://tse4.mm.bing.net/th?id=OIP.Sri9wahqIBdLwFTc85-tvgHaEK&pid=Api&P=0&h=180" | |
| st.image(image_url, use_container_width=True) | |
| st.markdown(f""" | |
| <style> | |
| /* Set the background image for the entire app */ | |
| .stApp {{ | |
| background-color: #a27250; | |
| background-size: 100px; | |
| background-repeat:no; | |
| background-attachment: auto; | |
| background-position:full; | |
| }} | |
| </style> | |
| """, unsafe_allow_html=True) | |
| km_model=joblib.load("coffe_customer_prediction_model.joblib") | |
| def clustering(monetary, frequency): | |
| new_customer = np.array([[monetary, frequency]]) | |
| predicted_cluster = km_model.predict(new_customer) | |
| if predicted_cluster[0]==1: | |
| return "Daily" | |
| else: | |
| return "Weekely" | |
| monetary=float(st.slider("Slide Size of the monetary",min_value=1,max_value=459,value=1)) | |
| frequency=float(st.slider("Slide Size of the frequency",min_value=1,max_value=25,value=1)) | |
| if st.button("Submit"): | |
| predicted_cluster = clustering(monetary, frequency) | |
| st.text_area("",f'New Customer assigned to Cluster: {predicted_cluster}') | |
| st.write("") |