Kentoh/Shutterstock.com (Background); Dave J Hogan/Getty Images (Taylor Swift); Kevin Mazur/Getty Images for NARAS (Bruno Mars); Glenn Hunt/Getty Images (Ed Sheeran); Kevin Mazur/Getty Images for One Love Manchester (Ariana Grande)

STANDARDS

CCSS: 7.SP.C.5, MP1, MP2, MP3

TEKS: 7.6I, 6.4G

Predicting Your Playlist

A computer algorithm helps Spotify listeners find brand-new music they will love

Courtesy of Ed Newett

For millions of Spotify users, Mondays mean new music. The app was launched 10 years ago, on October 7, 2008, to allow listeners to stream their favorite songs. Normally, users choose their own music. The Discover Weekly playlist, however, offers something totally unexpected. The playlist is packed with artists that listeners have probably never heard of but whose music perfectly matches their tastes.

To some listeners, the playlists can be almost eerily perfect. The feature was added in 2015 and has been carefully crafting playlists ever since. But there’s no dark magic behind the recommendations—it’s all data analysis, probability, and computer science.

Ed Newett is a computer scientist at Spotify. He created the Discover Weekly algorithm, which assembles those perfect playlists. An algorithm is a set of rules that a computer follows to solve a problem. It takes inputs, or provided information, and creates outputs, or results, based on the algorithm’s rules. 

Discover Weekly’s algorithm consists of two steps. “The first step is learning how songs are related to one another,” explains Newett. It learns this by studying the playlists that users have already created. The more frequently songs appear together on user-created playlists, the stronger the relationship between the songs, and the stronger the likelihood that someone who likes one song will like the other. Spotify’s Discover Weekly algorithm has a staggering amount of data to learn from: 35 million songs found in more than 2 billion user-created playlists!

For millions of Spotify users, Mondays mean new music. The app was launched 10 years ago, on October 7, 2008. It allows listeners to stream their favorite songs. Normally, users choose their own music. But the Discover Weekly playlist offers something totally different. The playlist is packed with artists that listeners have probably never heard of. But often, the music perfectly matches their tastes.

Spotify added the Discover Weekly feature in 2015. It's been carefully crafting playlists ever since. To some listeners, the playlists can be so perfect it's almost creepy. But there's no dark magic behind the recommendations. It's all data analysis, probability, and computer science.

Ed Newett is a computer scientist at Spotify. He created the Discover Weekly algorithm, which assembles those perfect playlists. An algorithm is a set of rules that a computer follows to solve a problem. The computer starts with inputs, or provided information. It creates outputs, or results, based on the rules of the algorithm. 

Discover Weekly's algorithm consists of two steps. "The first step is learning how songs are related to one another," explains Newett. It learns this by studying the playlists that users have already created. It looks for songs that appear together on user-created playlists. The more frequently this happens, the stronger the relationship between the songs is. That means that someone who likes one of the songs will be more likely to like the other one too. Spotify's Discover Weekly algorithm has a staggering amount of data to learn from. There are 35 million songs on more than 2 billion user-created playlists!

Courtesy of Ed Newett

Ed Newett writes hundreds of lines of code to keep new music coming to  your Spotify’s Discover Weekly playlist.

The second step is actually creating a playlist for each user based on what listeners already like. The algorithm analyzes what a listener is streaming and builds a brand-new playlist around that information. To keep each Discover Weekly playlist new and interesting, the algorithm never puts a song on a person’s playlist if that person has already streamed that song on Spotify.

But how does the algorithm know which songs and artists to recommend? It all boils down to probability. “If you have 100 million playlists that contain Bruno Mars, and then 90 million of those also contain Ed Sheeran, that’s a strong probabilistic relationship,” says Newett. “That’s what this Discover Weekly algorithm learns over time.”

The algorithm is constantly learning from newly-created playlists using the latest hit songs—which means there’s always more music on your Discover Weekly playlist each week!

The second step is creating a new Discover Weekly playlist for each user. The algorithm does this based on what each listener already likes. The algorithm analyzes what a listener chooses to stream on Spotify. Then it uses that information to build a brand-new playlist of related songs. To keep each Discover Weekly playlist new and interesting, the algorithm checks which songs a person has already listened to. It never puts a song on the playlist if that person has already streamed the song on Spotify. 

But how does the algorithm know which songs and artists to recommend? It all boils down to probability. "If you have 100 million playlists that contain Bruno Mars, and then 90 million of those also contain Ed Sheeran, that's a strong probabilistic relationship," says Newett. "That's what this Discover Weekly algorithm learns over time."

The algorithm is constantly learning. When users create new playlists using the latest hit songs, it adds those to the mix. That means there's always new music on your Discover Weekly playlist each week!

Use the playlists to answer questions about the theoretical probability that songs by certain artists will be played. Write your answers as percents, rounded to the nearest percent. Record your work and answers on our answer sheet.

Use the playlists to answer questions about the theoretical probability that songs by certain artists will be played. Write your answers as percents, rounded to the nearest percent. Record your work and answers on our answer sheet.

What’s the theoretical probability of a Selena Gomez song being played when starting Playlist 3 on shuffle?

What’s the theoretical probability of a Selena Gomez song being played when starting Playlist 3 on shuffle?

A. What’s the theoretical probability of a song by Shawn Mendes playing when starting Playlist 1 on shuffle?

A. What’s the theoretical probability of a song by Shawn Mendes playing when starting Playlist 1 on shuffle?

B. What’s the probability of a song by Shawn Mendes playing when starting all four playlists shuffled together?

B. What’s the probability of a song by Shawn Mendes playing when starting all four playlists shuffled together?

A. What’s the theoretical probability of choosing a playlist containing Beyoncé?

A. What’s the theoretical probability of choosing a playlist containing Beyoncé?

B. What’s the probability of choosing a playlist containing Beyoncé and John Legend?

B. What’s the probability of choosing a playlist containing Beyoncé and John Legend?

What‘s the probability that the first song when all four playlists are shuffled together will be by Maroon 5?

What‘s the probability that the first song when all four playlists are shuffled together will be by Maroon 5?

While listening to Playlist 2 on shuffle, a John Legend song and a Shawn Mendes song play. What’s the theoretical probability that the next one to play will be by BTS?

While listening to Playlist 2 on shuffle, a John Legend song and a Shawn Mendes song play. What’s the theoretical probability that the next one to play will be by BTS?

Skills Sheets (4)
Skills Sheets (4)
Skills Sheets (4)
Skills Sheets (4)
Games (1)
Lesson Plan (2)
Lesson Plan (2)
Text-to-Speech