How ALS works
The job of a recommender system is to fill in a sparse user-by-item matrix. Most cells are empty:
any one user has interacted with only a tiny slice of the catalogue. ALS solves this by
decomposing the matrix into two much smaller ones — a matrix of user vectors and a matrix of item
vectors.
The algorithm runs iteratively:
- Initialise the user and item vectors with random values
- Fix the item vectors, then optimise the user vectors (a least-squares problem)
- Fix the user vectors, then optimise the item vectors (a least-squares problem)
- Repeat until convergence
At each step the task reduces to a system of linear equations — hence “least squares”.
ALS for implicit data (iALS)
E-commerce has almost no explicit ratings. What it has is behaviour: views, add-to-basket events,
purchases. Implicit ALS reads these as confidence in a preference:
confidence(u, i) = 1 + alpha * frequency(u, i)
where frequency is the number of interactions between user u and item i, and alpha is a scaling
parameter. More interactions mean the model is more confident that the item is relevant.
| Signal | Typical weight |
|---|---|
| Purchase | High |
| Add to basket | Medium |
| Product page view | Low |
| View in a category listing | Very low |
Scalability: why ALS is popular in production
On each iteration, updating the user vectors is independent across users, so the work can run in
parallel. That makes ALS a natural fit for Apache Spark (MLlib) and other distributed compute.
Large e-commerce platforms with hundreds of millions of interactions train ALS models in a
reasonable time.
The limits of ALS
- Cold start. No history means no useful vector. New users and newly added items need their own
strategies. - No temporal context. Standard ALS does not account for preferences changing over time; that
requires extensions or different architectures such as sequential recommendations and
transformers. - Interpretability. Latent factors carry no human-readable meaning, so the model cannot explain
to a shopper why this particular product was recommended.