Problem
An online store wants to show relevant products to visitors it knows nothing about, so it has to rely on the current session alone. Anonymous users have no purchase history and no earlier sessions, so user-based recommenders have nothing to work with. Recommending from the same category is simple, but categories are coarse and products inside one differ a lot, so the suggestions feel irrelevant. The goal is a next-click recommendation built only from what the visitor has viewed in the current session, which should raise the chance of a cart addition and purchase.
Example from the article: a visitor views a pair of headphones, and the model returns ten other headphones from different brands.
Solution in brief
Treat each session as a "sentence" and each product ID as a "word", then train Word2Vec (CBOW) on all sessions. Products that appear in similar sessions end up with similar vectors, and the model's predicted output words for a viewed product serve as recommendations. The result is checked by reading top-10 lists and by plotting the embeddings with UMAP.
Questions this case answers
- How to recommend the next item to a user with no history, using only the items interacted with in the current session
- How to recommend next products to an anonymous visitor using only the current browsing session?
- How to build product embeddings from session logs without user IDs or purchase history?
- How to sanity-check session-based recommendations without a labelled test set?
Tools and methods
- Word2Vec (CBOW) — learns product embeddings from co-occurrence within sessions
- Gensim — trains the model and returns predicted output words as recommendations
- pandas — cleans the event log and groups it into sessions
- UMAP — reduces embeddings to 2D to check that products cluster by category
Google or a one-time email code. No password.