Music Recommendation on Spotify

23 Dec 2015

MusicManager is an other personal project on which I’m currently working. I am using Echo Nest and Spotify APIs to build my own recommender system directly on Spotify. Thanks to Echo Nest, I get all the information I need on the music I can listen (eg. which artists are similar to the artists I like), while Spotify is a really nice player. Even though there is still a lot to do, I’ve now a usable Music Manager that can automatically find music I’m likely to appreciate, add it to one of my Spotify playlists, and keep track of my tastes when I listen to its suggestions.

Most of the recommender systems look for similarities in users so that they can guess a given user’s opinion for a given object (here, it would be a song I haven’t listened to). Unfortunately I don’t have access on all this data, and even though Spotify could give me some similar information, it’s not provided by the API. So I decided to try another approach that works in two steps. First, I’m more focusing on the artists. Precisely I am building a graph of artists, starting with those I know I like, and adding similar artists. This is possible thanks to the Echo Nest API. Actually, I am also adding similar artists of the artists that are similar to those I like, and even similar artists of the latter, etc… From this graph, I compute some score for each artist, based on its depth (0: an artist I like, d+1: an artist similar to an artist of depth d), its popularity, and its degree in the artist graph. And I can finally keep only the best artists with regards to this metric. Below is an example of the subgraph with the best artists.

From the selected artists, I look for their hotness (as defined by Echo Nest) song that I haven’t listened to yet, and add them to one of my Spotify playlist. I can then go on Spotify and listen to these recommendations. And while I’m listening, I can easily give feedback to the Music Manager so that it will record my tastes and make better suggestions in the future. For example, I can remove a song I don’t like by running $python player.py pass track_id in the console, where track_id is the Spotify ID of the song (obtained in one click in the player).

During all these steps, I am keeping track of all the songs suggested and the feedback I gave when listening to them. I am also downloading the songs’ characteristics via the Echo Nest API. So I get a database that looks like this :

The opinion field is the feedback I gave and can be either 0 (disliked), 1 (liked), or -1 (don’t know yet). I am planning to mine this database to refine the suggestions the Music Manager could do later, so there is more to come !

In the meanwhile, you can already use it as it is. You’ll find the code and instructions in my GitHub repo. And please reach out if you want to participate to the project or if you want to provide any feedback !