Weighted Alternating Least Squares (WALS) is a technique used to make predictors more precise in machine learning. It’s often applied to improve recommendations systems’ predictions, where it estimates how much a user will like a particular item.


Imagine you’re trying to guess what kind of ice cream your friends will like based on their past choices. With WALS, you make a first guess, then adjust based on one friend’s past choices, then alternate and adjust based on another friend’s choices. This back-and-forth process helps you make better guesses over time.

In-depth explanation

Weighted Alternating Least Squares (WALS) is an optimization algorithm used in the realm of machine learning, specifically in the construction and refinement of recommendation systems. The primary purpose of WALS is to solve matrix factorization tasks more efficiently.

Matrix factorization becomes necessary in scenarios where we aim to predict missing entries in a matrix. In the case of a recommendation system, this matrix usually consists of users and items, with existing entries representing previously recorded interactions or ratings. The goal, then, is to fill in the blanks—missing interactions—and recommend the most likely items a user may appreciate.

The “Alternating Least Squares” part of WALS refers to the basic principle of how the algorithm enhances its predictions. The method starts with random or heuristic-based initial predictions and then alternates between refining these guesses for the user factors and the item factors, one factor at a time.

The machinery behind this is a least squares problem solved separately for each user and item. For every iteration, while fixing item factors, we solve a least squares problem for user factors and vice versa.

The “Weighted” aspect of WALS comes to play here as well. The idea is assigning greater importance—weights—to observed interactions, with varying levels reflecting the confidence in these observations. This way, the model is not purely driven by observed interactions but takes into consideration missing interactions, dampening their impact based on confidence level.

WALS proves to be particularly useful when dealing with large datasets, due to its ability to parallelize computations even on sparse datasets, and its linear complexity with the number of observations leads to highly scalable solutions.

Matrix Factorization, Recommendation Systems, Least Squares, Collaborative Filtering, Implicit Feedback, Latent Factors, Sparse Datasets, Optimization Algorithms, Confidence Weight, TensorFlow WALS