Memory-Based Collaborative Filtering for Recommendation Service | ||
| ||
| Memory-Based Collaborative Filtering (CF) makes recommendations from patterns of agreement across many users, without using any item content features. It is “memory-based” because it operates directly on the stored user–item interaction matrix at prediction time, computing similarities on demand rather than learning a compact parametric model. There are two complementary formulations:
How It Works (The Math)Let User-based predictionFirst compute similarity between users. Pearson correlation over their co-rated items
Then predict the target rating as a similarity-weighted, mean-centered average over the neighborhood
Item-based predictionCompute item–item similarity, commonly adjusted cosine (centered on user means to remove rating bias):
Predict from the items the user has already rated:
Item-based CF is usually preferred in production because item–item similarities are more stable over time than user–user similarities and can be precomputed offline.
Requirements
Simplified Architecture
Reference Architecture
Reference Architecture (with Technology Stack)The same flow on concrete tooling — Kafka for events, Spark for the nightly similarity job, and Redis (or Cassandra) for the precomputed item–item neighbor store.
Signals & FeaturesMemory-based CF consumes only interaction signals: explicit ratings, or implicit signals such as clicks, purchases, watches, add-to-cart, and dwell. Implicit feedback is treated as positive-only with confidence weighting. No item or user metadata is required, which is both the method’s strength (no feature engineering) and its limitation (it cannot reason about why items are similar).
Training & Serving ConsiderationsThere is no parametric “training” in the gradient-descent sense. The expensive step is computing the similarity matrix, which is
EvaluationRating-prediction variants are scored with RMSE (Root Mean Square Error) / MAE (Mean Absolute Error); top-N recommendation is evaluated with precision@k, recall@k, MAP (Mean Average Precision), and NDCG (Normalized Discounted Cumulative Gain). Watch coverage and cold-item exposure closely, since memory-based CF systematically underexposes new and long-tail items (the popularity bias and cold-start problem).
Strengths & WeaknessesStrengths: simple, intuitive, and explainable (“because you liked X”); requires no item features; item-based variant precomputes well and serves fast. Weaknesses: scales poorly on huge user/item sets due to
When to Use ItMemory-based CF is a strong baseline for small-to-medium catalogs with reasonable interaction density, for e-commerce “related items” modules (item-based CF), and as an interpretable benchmark to beat before investing in matrix factorization or deep models. On web-scale, sparse data it is typically superseded by model-based CF and deep retrieval, though item-based co-occurrence still appears as one signal inside larger hybrid systems. | ||
| | ||
| |