File size: 693 Bytes
902677e 60abed1 902677e 60abed1 902677e 60abed1 902677e 60abed1 902677e 60abed1 | 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 | import streamlit as st
import pandas as pd
import joblib
model = joblib.load("src/kmeans_model.pkl")
scaler = joblib.load("src/scaler.pkl")
st.title("Mall Customer Segmentation")
st.write(
"Customer segmentation using KMeans Clustering"
)
income = st.slider(
"Annual Income (k$)",
0,
150,
50
)
spending = st.slider(
"Spending Score",
1,
100,
50
)
input_data = pd.DataFrame({
"Annual Income (k$)": [income],
"Spending Score (1-100)": [spending]
})
scaled_data = scaler.transform(input_data)
prediction = model.predict(scaled_data)[0]
if st.button("Predict Cluster"):
st.success(
f"Customer belongs to Cluster {prediction}"
) |