How do we define when two songs are similar? By genre? By BPM? By the emotions they evoke? As a passionate music lover, I decided to create an application that, based on a selected song, suggests 5 similar ones. Literally similar.
What if I told you that Eminem’s Lose Yourself and Taylor Swift’s Dancing with Our Hands Tied are similar? At least, that’s what this app says. I was surprised too, but it will make sense.
The way it works is by converting each song into a vector of musical features. These include valence (the musical positivity of the song), acousticness, danceability, energy, loudness, the proportion of purely instrumental sections, and of course, tempo (all of this information comes from Spotify’s dataset). Once the songs are represented as vectors, the app calculates the cosine similarity between them – a mathematical way to measure how close two songs are in their characteristics.
It definitely produces very interesting results, from Indian pop songs to bands I discovered while testing the app (and continued listening to). Even a simple approach like KNN (K-nearest neighbors) can give meaningful results, or make you laugh, and maybe even amaze you as it did me (highly recommend The Black Angels).