Spotify could use the intricate mathematics of counterfactuals to determine your future favorite song
The complex mathematics behind counterfactual analysis, a precise technique used for identifying the causes of past events and predicting future outcomes, has been captured by a novel machine-learning model developed by a team of researchers at Spotify, the music-streaming company. This marks the first time such a model has been created.
According to an article published earlier this year in the scientific journal Nature Machine Intelligence, the machine-learning model developed by Spotify's research team has the potential to enhance the precision of automated decision making, particularly in tailored recommendations, across various fields such as healthcare and finance.
Counterfactuals involve imagining how a situation could have played out differently if certain key elements had been altered, essentially rewinding the world and changing specific details to observe the outcomes. By manipulating the appropriate factors, it becomes possible to distinguish genuine causation from mere correlation or happenstance.
Ciaran Gilligan-Lee, co-creator of the machine-learning model and head of Spotify's Causal Inference Research Lab, emphasizes the critical role of comprehending cause and effect in decision making. Anticipating the future consequences of present decisions is crucial, and understanding the impact of each choice is imperative.
Spotify could utilize the concept of counterfactuals to determine which songs to display or when to release new albums by artists. Although the company is not currently utilizing this method, Gilligan-Lee believes it could provide solutions to the everyday issues faced by the organization.
Counterfactuals are a way of understanding how the world works by imagining how things might have unfolded differently. Although they are intuitive to most people, they can be challenging to express mathematically. The technique involves calculating the likelihood of an event occurring based on a set of circumstances that never occurred.
To address these mathematical complexities, Ciaran Gilligan-Lee and his co-authors developed a new machine-learning model based on a theoretical framework for counterfactuals known as twin networks. Twin networks were initially devised in the 1990s by Andrew Balke and Judea Pearl to work through basic examples, and Pearl won the Turing Award in 2011 for his work in causal reasoning and AI.
The team based their model on the twin networks framework, treating counterfactuals as a set of probabilistic models. One model represents the actual world, while the other represents an alternative version of the same world with specific changes applied. The models are linked in a way that the fictional world model is kept identical to the actual world model, except for the adjustments being made.
Gilligan-Lee and his colleagues developed a neural network based on the twin networks framework and trained it to make predictions about how events would unfold in the fictional world. The resulting program is a versatile tool for conducting counterfactual reasoning, allowing users to explore any scenario they wish. According to Gilligan-Lee, the program can answer a wide range of counterfactual questions about any given situation.
The team at Spotify applied their model to various real-world scenarios, including credit approval in Germany, an international clinical trial for stroke medication, and assessing the safety of the water supply in Kenya.
As an example, in 2020, researchers studied the effectiveness of installing pipes and concrete containers to protect springs from bacterial contamination in a specific region of Kenya to reduce the incidence of childhood diarrhea. While the study found a positive effect, Gilligan-Lee points out that it is essential to determine the actual cause of the outcome. Before rolling out concrete walls around wells across the country, it is necessary to be certain that the decline in sickness was a direct result of the intervention, and not just a side effect.
Spotify is not the only tech company racing to build machine-learning models that can reason about cause and effect. In the last few years, firms such as Meta, Amazon, LinkedIn, and TikTok’s owner ByteDance have also begun to develop the technology.
“Causal reasoning is critical for machine learning,” says Nailong Zhang, a software engineer at Meta. Meta is using causal inference in a machine-learning model that manages how many and what kinds of notifications Instagram should send its users to keep them coming back.
Romila Pradhan, a data scientist at Purdue University in Indiana, is using counterfactuals to make automated decision making more transparent. Organizations now use machine-learning models to choose who gets credit, jobs, parole, even housing (and who doesn’t). Regulators have started to require organizations to explain the outcome of many of these decisions to those affected by them. But reconstructing the steps made by a complex algorithm is hard.
Pradhan thinks counterfactuals can help. Let’s say a bank’s machine-learning model rejects your loan application and you want to know why. One way to answer that question is with counterfactuals. Given that the application was rejected in the actual world, would it have been rejected in a fictional world in which your credit history was different? What about if you had a different zip code, job, income, and so on? Building the ability to answer such questions into future loan approval programs, Pradhan says, would give banks a way to offer customers reasons rather than just a yes or no.
Counterfactuals are important because it’s how people think about different outcomes, says Pradhan: “They are a good way to capture explanations.”
They can also help companies predict people’s behavior. Because counterfactuals make it possible to infer what might happen in a particular situation, not just on average, tech platforms can use it to pigeonhole people with more precision than ever.
The same logic that can disentangle the effects of dirty water or lending decisions can be used to hone the impact of Spotify playlists, Instagram notifications, and ad targeting. If we play this song, will that user listen for longer? If we show this picture, will that person keep scrolling? “Companies want to understand how to give recommendations to specific users rather than the average user,” says Gilligan-Lee.