In an earlier post I explained why my customer segmentation project uses K-Means with three clusters. This one is about what came after the notebook: getting that model somewhere two different apps could use it.
The project has two clients, a Streamlit web app and a native Android app (the Android app was built with AI help). Neither of them runs the model. Both send a customer's recency, frequency and monetary value to one FastAPI service on AWS EC2 and get a segment back. That means both apps give the same answer for the same customer, and a refitted model only has to be deployed in one place.
Three files out of the notebook
The last cells of the notebook fit the final model, KMeans(n_clusters=3, random_state=42, n_init=10) on the scaled RFM features, and save three files with joblib :
scaler.joblib , the StandardScaler fitted on the training customers,
kmeans_model.joblib , the model itself,
segment_names.joblib , a small dictionary from cluster number to name.
The scaler has to travel with the…