KatInterview

Building a Recommender: From Neighbors to Latent Factors

Machine LearningModel answer
HardModel answerMachine Learningrecommender-systemscollaborative-filteringmatrix-factorization

Last updated

Compare neighborhood and matrix factorization recommenders, and explain loss, regularization, cold start, popularity bias, evaluation and large-catalog scaling.

You are asked to design the modeling core of a recommender for a large e-commerce or media catalog, using only the interaction history between users and items (no hand-built rules). Walk through how you would approach it.

Cover the following points:

  1. Problem framing. What does the user–item matrix look like, and how do explicit signals (ratings) differ from implicit signals (clicks, purchases, views)?
  2. Neighborhood methods. Compare user-based and item-based collaborative filtering: how predictions are formed, which similarity measures you would use, and where each breaks down.
  3. Matrix factorization. Describe how latent-factor models work for explicit feedback and how the formulation changes for implicit feedback.
  4. Loss functions. Contrast pointwise, pairwise and listwise/sampled-softmax objectives, and explain the role of negative sampling.
  5. Regularization. What do you regularize and how do you tune it?
  6. Cold start. How do you serve brand-new users and brand-new items?
  7. Popularity bias. Why does it arise, and how would you reduce it in training, re-ranking and measurement?
  8. Evaluation. How would you evaluate offline (splits, NDCG, MAP) and online?
  9. Scale. What changes when there are hundreds of millions of users and millions of items?

A strong answer is structured, gives the key formulas, and states the trade-offs behind each choice rather than only listing techniques.

Hints

Hint 1

Start by separating what the data means: explicit ratings contain negatives, while implicit logs only contain positives and a missing entry is ambiguous. This decides whether you predict a score or rank items.

Hint 2

For implicit matrix factorization, think about treating every unobserved pair as a low-confidence zero and weighting observed pairs more heavily. Then ask how alternating least squares keeps that sum over all pairs tractable.

Hint 3

For pairwise and sampled-softmax losses, the choice of negatives matters as much as the loss. Consider what happens with uniform negatives, and how in-batch negatives oversample popular items.

Hint 4

Offline evaluation should respect time: split by timestamp, not randomly. Pair accuracy metrics with coverage and novelty so popularity bias is visible.