Recommend Complementary Items for the Add to Cart Moment
Last updated: November 29, 2026
Quick Overview
When a shopper adds an item to cart, show a carousel of complementary items (batteries for a toy, chips for salsa). Explain how you would model complementarity, handle cold start items, and avoid recommending substitutes.
Walmart Labs
November 29, 20260
0
0 solved
When a shopper adds an item to cart, show a carousel of complementary items (batteries for a toy, chips for salsa). Explain how you would model complementarity, handle cold start items, and avoid recommending substitutes.
Basket building is central to Walmart's grocery and general merchandise business, and complementary recommendations at add to cart drive basket size. Interviewers look for the difference between co-purchase and similarity, a candidate generation and ranking split, and a strategy for the many new and long tail items in the catalog.
What the Interviewer Expects
- Distinguish complements from substitutes and explain why similarity fails
- Build candidates from co-purchase statistics normalized for popularity
- Use category-level and content embeddings for cold start
- Rank with a model trained on add to cart from the carousel
- Define offline and online metrics, including basket size and attach rate
Key Topics to Cover
How to Approach This
- Understand the bias-variance trade-off. High training accuracy but low test accuracy signals overfitting.
- Choose evaluation metrics carefully based on the problem. Accuracy alone is often insufficient.
- Feature engineering is often more impactful than model selection.
- Know when to use tree-based models (tabular data) vs neural networks (unstructured data).
- Handle class imbalance with SMOTE, class weights, or appropriate loss functions.
Possible Follow-up Questions
- Why is raw co-occurrence count a bad complement score?
- How would you prevent recommending another brand of the same salsa?
- How would you recommend for an item added yesterday by a new seller?
- How do you account for the store's local availability?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Explore ML Interview PrepSample Answer
Clarify
Trigger: an item added to cart, possibly with the rest of the cart as context. Output: 10 items available for the shopper's fulfillment option. Goal: attach rate (carousel add to cart per impression) ...
Approach
Candidates. From baskets, compute an asymmetric score normalized by popularity, such as lift or a smoothed PMI. Raw counts favor bananas and milk for ever...