Downloads · 30 days
0
priyadip/deep-seg-paradox
deep-seg-paradox is a machine learning model from priyadip. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for pytorch. The card lists the license as mit.
A 256-D customer-embedding encoder trained with pure contrastive learning (NT-Xent) on the public H&M Personalized Fashion Recommendations dataset (1.35M customers, 31.8M transactions, 2018-09 → 2020-09), plus the K-M…
Downloads · 30 days
0
Access
Public
Updated Jul 18, 2026
Repo size
7.1 MB
Likes
0
Public
Click a slice to open those files.
.pth6.9 MB · 98%
From the Hugging Face model README
A 256-D customer-embedding encoder trained with pure contrastive learning (NT-Xent) on the public H&M Personalized Fashion Recommendations dataset (1.35M customers, 31.8M transactions, 2018-09 → 2020-09), plus the K-Means centroids of the final 20-segment customer segmentation. Code, full pipeline, and experiment history: https://github.com/priyadip/deep-seg-paradox
Recommending each customer the bestsellers of their own segment instead of global bestsellers improves next-purchase prediction on a fully held-out test week by +21.6% MAP@12 (0.00710 → 0.00864; 68,984 purchasers; 15/20 segments positive). Model and K were selected exclusively on a separate validation week.

Across a three-regime ablation (DeepCluster-style pseudo-label refreshing; frozen pseudo-labels; pure contrastive), cluster-aware training objectives monotonically degraded downstream predictive utility even as internal cluster-validity metrics (silhouette) improved — internal and extrinsic segmentation quality were anti-correlated. Pure contrastive training was best throughout, peaking at 48 epochs (+17.9% validation uplift) and declining afterward (confirmed to 96 epochs). This checkpoint is that peak.
| File | Contents |
|---|---|
encoder_contrastive_48ep.pth | encoder weights (6.9MB; state_dict) |
kmeans_centroids_k20.npy | 20 × 256 segment centroids fitted on the encoder's embeddings |
model.py | self-contained architecture + loading + nearest-centroid segment assignment |
Three input views per customer → fused 256-D embedding:
club_member_status, fashion_news_frequency → MLP(128)all-MiniLM-L6-v2 embedding of purchased articles' detail_desc → MLP(512)import torch, numpy as np
from model import load_encoder, assign_segments
model = load_encoder("encoder_contrastive_48ep.pth")
with torch.no_grad():
emb, _, _ = model(demo, style, behav) # [N,7], [N,384], [N,24,2] float32
segments = assign_segments(emb.numpy()) # [N] ints in 0..19
Input construction must follow the exact recipe above (see the GitHub repo's
preprocessing.py). Customers with no purchase history: zero-fill style and behav —
the model still produces an embedding (demographic-driven cold start).
Per candidate segmentation: build top-12 bestsellers per segment from a 14-day popularity window, recommend to members, score MAP@12 against actual held-out-week purchases, and compare with a single global top-12 list. Uplift isolates what knowing the segment adds.
For research on segmentation evaluation, representation learning on retail data, and as a practical segment-assignment model for H&M-schema data. Not a competition-grade recommender (the popularity recommender is deliberately minimal). Trained on one retailer, 2018–2020; retrain for other domains. Single training seed; nearby checkpoints differ by small MAP margins. Dataset © H&M Group via Kaggle competition rules — not redistributed.