This folder contains the two serialised files needed to score new customers without retraining.
The trained K-Means model with K=4 fitted on the full RFM dataset.
- Algorithm:
sklearn.cluster.KMeans - n_clusters: 4
- random_state: 42
- n_init: 10
- max_iter: 300
- Silhouette Score: ~0.38
The fitted StandardScaler used to preprocess RFM features before clustering.
- Algorithm:
sklearn.preprocessing.StandardScaler - Features scaled: Recency, Frequency, Monetary
- Fitted on: the full cleaned RFM customer dataset (~4,300 customers)
Important: Always use this exact scaler — never refit on new data. The scaler must apply the same mean and std from training for cluster assignments to be valid.
| Cluster ID | Segment Name | Profile |
|---|---|---|
| Varies | Champions | Low Recency, High Frequency, High Monetary |
| Varies | Loyal Customers | Medium R/F/M across all three |
| Varies | New Customers | Low Recency, Low Frequency, Low Monetary |
| Varies | At-Risk | High Recency, Low Frequency, Low Monetary |
The cluster ID numbers (0–3) mapped to segment names depend on the data. See the notebook (Cell 253) for the dynamic label mapping logic.
import joblib
import pandas as pd
# Load saved artefacts
model = joblib.load('models/kmeans_customer_segmentation.pkl')
scaler = joblib.load('models/rfm_standard_scaler.pkl')
# Define a new customer's RFM values
new_customer = pd.DataFrame({
'Recency': [10], # days since last purchase
'Frequency': [8], # number of unique orders
'Monetary': [450.0] # total spend in GBP
})
# Scale using the training scaler
scaled = scaler.transform(new_customer)
# Predict cluster
cluster_id = model.predict(scaled)[0]
print(f'Assigned cluster: {cluster_id}')
# Map cluster_id to segment name using label_map from the notebookIf you want to retrain from scratch:
- Open
notebooks/Myntra_Customer_Segmentation.ipynb - Run all cells (Kernel → Restart & Run All)
- The
joblib.dump()calls in Section 8 will overwrite these files