/api/purchasing_segmentationX-Customer-Api-Id: <uuid>
X-Secret: <secret>
Content-Type: application/json
customers: array<object>
id: string (unique)
frequency: int ≥ 1
amount_spent: float ≥ 0
product_types: array<string> (≥ 1)
k_range: array<int 3–30> (optional)
algorithms: array<kmeans|gmm|agglo|dbscan> (optional)
{
"customers": [
{ "id": "C001", "frequency": 28, "amount_spent": 4120.75, "product_types": ["laptop","mouse","keyboard","monitor"] },
{ "id": "C002", "frequency": 5, "amount_spent": 190.40, "product_types": ["tea","coffee"] },
{ "id": "C003", "frequency": 12, "amount_spent": 845.10, "product_types": ["jeans","t-shirt","sneakers"] },
{ "id": "C004", "frequency": 2, "amount_spent": 75.00, "product_types": ["notebook"] },
{ "id": "C005", "frequency": 17, "amount_spent": 1324.55, "product_types": ["smartphone","earbuds"] },
{ "id": "C006", "frequency": 8, "amount_spent": 510.30, "product_types": ["dog food","cat food"] },
{ "id": "C007", "frequency": 24, "amount_spent": 2780.90, "product_types": ["smart-tv","soundbar","hdmi-cable"] },
{ "id": "C008", "frequency": 10, "amount_spent": 660.00, "product_types": ["yogurt","milk","cheese"] },
{ "id": "C009", "frequency": 3, "amount_spent": 120.00, "product_types": ["stationery"] },
{ "id": "C010", "frequency": 15, "amount_spent": 975.65, "product_types": ["beer","wine","snacks"] },
{ "id": "C011", "frequency": 7, "amount_spent": 450.25, "product_types": ["books","pens"] },
{ "id": "C012", "frequency": 25, "amount_spent": 3015.90, "product_types": ["tablet","stylus","cover"] },
{ "id": "C013", "frequency": 6, "amount_spent": 210.10, "product_types": ["pasta","sauce"] },
{ "id": "C014", "frequency": 20, "amount_spent": 1884.00, "product_types": ["fitness-watch"] },
{ "id": "C015", "frequency": 1, "amount_spent": 40.00, "product_types": ["batteries"] },
{ "id": "C016", "frequency": 13, "amount_spent": 1105.35, "product_types": ["printer","ink"] },
{ "id": "C017", "frequency": 4, "amount_spent": 160.00, "product_types": ["flour","sugar","eggs"] },
{ "id": "C018", "frequency": 30, "amount_spent": 4522.60, "product_types": ["gaming-pc","rgb-mouse","gaming-chair","headset"] },
{ "id": "C019", "frequency": 11, "amount_spent": 720.00, "product_types": ["makeup","skincare"] },
{ "id": "C020", "frequency": 9, "amount_spent": 585.40, "product_types": ["toys","board-games"] },
{ "id": "C021", "frequency": 2, "amount_spent": 55.00, "product_types": ["candles"] },
{ "id": "C022", "frequency": 18, "amount_spent": 1410.70, "product_types": ["camera","sd-card"] },
{ "id": "C023", "frequency": 14, "amount_spent": 992.00, "product_types": ["office-chair","desk-lamp"] },
{ "id": "C024", "frequency": 3, "amount_spent": 135.00, "product_types": ["juice","cookies"] },
{ "id": "C025", "frequency": 12, "amount_spent": 830.20, "product_types": ["running-shoes","sports-socks"] },
{ "id": "C026", "frequency": 23, "amount_spent": 2560.00, "product_types": ["fridge","water-filter"] },
{ "id": "C027", "frequency": 6, "amount_spent": 260.40, "product_types": ["vitamins"] },
{ "id": "C028", "frequency": 5, "amount_spent": 195.99, "product_types": ["wine","cheese"] },
{ "id": "C029", "frequency": 19, "amount_spent": 1599.95, "product_types": ["e-reader","ebooks"] },
{ "id": "C030", "frequency": 22, "amount_spent": 2345.00, "product_types": ["washing-machine","detergent"] },
{ "id": "C031", "frequency": 4, "amount_spent": 175.50, "product_types": ["herbs","spices"] },
{ "id": "C032", "frequency": 8, "amount_spent": 540.00, "product_types": ["diapers","baby-wipes","formula"] },
{ "id": "C033", "frequency": 27, "amount_spent": 3350.80, "product_types": ["console","controller","games"] },
{ "id": "C034", "frequency": 10, "amount_spent": 705.35, "product_types": ["sunscreen","after-sun"] },
{ "id": "C035", "frequency": 3, "amount_spent": 150.00, "product_types": ["frozen-pizza"] },
{ "id": "C036", "frequency": 16, "amount_spent": 1240.60, "product_types": ["tool-set","drill"] },
{ "id": "C037", "frequency": 9, "amount_spent": 610.10, "product_types": ["organic-vegetables"] },
{ "id": "C038", "frequency": 21, "amount_spent": 2105.00, "product_types": ["air-fryer","cookbook"] },
{ "id": "C039", "frequency": 7, "amount_spent": 435.75, "product_types": ["flowers","vase"] },
{ "id": "C040", "frequency": 14, "amount_spent": 1015.90, "product_types": ["winter-jacket","gloves","scarf"] }
],
"k_range": [3,4,5,6]
}
{
"benchmark":[
{"algo":"kmeans","k":3,"silhouette":0.597453236579895,"davies_bouldin":0.5546427618629307},
{"algo":"kmeans","k":4,"silhouette":0.5596717000007629,"davies_bouldin":0.5109844153948895},
{"algo":"kmeans","k":5,"silhouette":0.5498684644699097,"davies_bouldin":0.46947742357211847},
{"algo":"kmeans","k":6,"silhouette":0.515194296836853,"davies_bouldin":0.4158492744102214},
{"algo":"gmm","k":3,"silhouette":0.5820122957229614,"davies_bouldin":0.5638253915641692},
{"algo":"gmm","k":4,"silhouette":0.51613849401474,"davies_bouldin":0.5061519518619599},
{"algo":"gmm","k":5,"silhouette":0.5426244139671326,"davies_bouldin":0.44539875895043995},
{"algo":"gmm","k":6,"silhouette":0.5039973258972168,"davies_bouldin":0.39578372055882266},
{"algo":"agglo","k":3,"silhouette":0.678362250328064,"davies_bouldin":0.376151934569577},
{"algo":"agglo","k":4,"silhouette":0.5551854372024536,"davies_bouldin":0.4501147341595592},
{"algo":"agglo","k":5,"silhouette":0.6081505417823792,"davies_bouldin":0.43129043959670116},
{"algo":"agglo","k":6,"silhouette":0.6091357469558716,"davies_bouldin":0.4559881260676169},
{"algo":"dbscan","k":null,"silhouette":-1.0,"davies_bouldin":null}
],
"best_model":{"algo":"agglo","k":3,"silhouette":0.678362250328064,"davies_bouldin":0.376151934569577,"n_clusters":3},
"centroids":[
[8.806451797485352,591.1141967773438,1.9677419662475586],
[23.14285659790039,2577.371337890625,2.2857143878936768],
[29.0,4321.6748046875,4.0]
],
"labels":{
"C001":2,"C002":0,"C003":0,"C004":0,"C005":0,"C006":0,"C007":1,"C008":0,"C009":0,"C010":0,
"C011":0,"C012":1,"C013":0,"C014":1,"C015":0,"C016":0,"C017":0,"C018":2,"C019":0,"C020":0,
"C021":0,"C022":0,"C023":0,"C024":0,"C025":0,"C026":1,"C027":0,"C028":0,"C029":0,"C030":1,
"C031":0,"C032":0,"C033":1,"C034":0,"C035":0,"C036":0,"C037":0,"C038":1,"C039":0,"C040":0
},
"interpretations_en":{
"0":"31 customers, avg spend 591, 8.8 purchases/mo. Top categories: wine, cheese, diapers.",
"1":"7 customers, avg spend 2,577, 23.1 purchases/mo. Top categories: smart-tv, soundbar, hdmi-cable.",
"2":"2 customers, avg spend 4,322, 29.0 purchases/mo. Top categories: laptop, mouse, keyboard."
},
"dendrogram":{
"linkage_matrix":[[1,27,5.59,2],[16,34,10.25,2],[10,38,14.5,2],…],
"columns":["child1","child2","distance","sample_count"],
"leaf_labels":["C001","C002",…,"C040"],
"cluster_legend":[
{"cluster_id":0,"n_customers":31,"avg_spend":591.11,"avg_frequency":8.81,"top_categories":"wine, cheese, diapers"},
{"cluster_id":1,"n_customers":7,"avg_spend":2577.37,"avg_frequency":23.14,"top_categories":"smart-tv, soundbar, hdmi-cable"},
{"cluster_id":2,"n_customers":2,"avg_spend":4321.68,"avg_frequency":29.0,"top_categories":"laptop, mouse, keyboard"}
]
}
}
Benchmark four clustering families (K-Means, Gaussian-Mixture, Agglomerative, DBSCAN), auto-select the best model by silhouette/Davies-Bouldin, and return cluster labels, centroids, marketing-ready personas, and the full dendrogram linkage for charting.
Cluster 0 – Value Basket: low spend/mid frequency → product discovery emails Cluster 1 – Power Shoppers: high spend/frequency → VIP tier, bundles Cluster 2 – Tech Whales: highest spend/frequency → concierge & exclusive launches Combine with CLV/churn scores for 360° segmentation.
← Back to all routes