Algorithm selectorCollaborative Filtering

[Recommendation]

Collaborative Filtering.

Recommends items based on user-item interaction patterns.

Movie recommendationsProduct suggestionsMusic playlists

SPEC SHEET

FamilyRecommendation
InterpretabilityMedium
Training speedMedium
Data neededLarge
ComplexityMedium

C — How it actually works

Skip item attributes entirely: people who agreed in the past will agree again. Factorise the giant sparse user×item rating matrix into slim user and item vectors so that their dot product predicts affinity. The learned dimensions end up encoding taste - genre-ness, price-sensitivity - without anyone defining them.

D — The math

Matrix factorisation: minimise Σ_{(u,i) observed} (r_ui − μ − b_u − b_i − p_uᵀq_i)² + λ(‖p‖²+‖q‖²+…), trained by ALS or SGD. Implicit-feedback variants (BPR, weighted ALS) rank clicks/plays instead of predicting ratings.

Training

O(nnz · k) per epoch (nnz = observed interactions)

Inference

O(k) per user-item pair + ANN search for top-N

E — When NOT to use it

  • Cold start dominates (new marketplace, fast-churning catalogue) - lean on content features first
  • Interactions are extremely sparse (< a handful per user)
  • One-shot purchase domains (real estate) where taste barely repeats

F — Tuning that matters

  • Latent dimension k = 32-128; regularisation λ matters more than k
  • For implicit data use implicit-ALS or BPR - never treat unclicked as rated-zero
  • Add user/item bias terms before anything fancy; they capture a shocking share of signal
  • Evaluate with time-based splits and ranking metrics (recall@k, NDCG), not RMSE

G — Production pitfalls

  • Random train/test splits that leak future interactions into training
  • Popularity bias: the model happily recommends bestsellers to everyone - measure coverage too
  • Feedback loops: recommending X causes clicks on X which reinforces X (log exploration traffic)
  • Ignoring business rules (stock, region, age-rating) until after the model ships

H — Minimal starting point

PYTHON
import implicit  # implicit-feedback ALS

model = implicit.als.AlternatingLeastSquares(factors=64, regularization=0.05)
model.fit(user_item_csr)             # confidence-weighted clicks/plays
ids, scores = model.recommend(user_id, user_item_csr[user_id], N=10)

I — The interview question

How do you recommend anything for a brand-new user?

Cold start has no interactions to factorise, so: onboard with popularity/editorial lists, use content features (metadata embeddings) as priors, or ask 2-3 taste questions; then blend in collaborative signal as interactions accumulate. Hybrid rankers formalise this handoff.

J — In the wild

The Netflix Prize made matrix factorisation famous, and its descendants still drive "Because you watched…" rows - modern stacks wrap the same latent-factor idea inside two-tower neural retrieval plus a ranking model.

K — Consider instead