Working on a Music Playlist Generator of sorts

I recently scraped a large music DB with info on ~1.3 million artists. While the methods or the motives for how that came to be should be left for another post, I think it’s interesting to spend a few words on my findings so far.

The DB provides meta-data on each artist and what I was particularly interested in was the “Related Artists” field. Every musician/band has a few Related Artists and with all those connections it’s possible to create a Directed Graph, or a Music Map if you will. With 1,335,458 nodes (artists) and 27,749,616 edges (related artists), this is quite a sparse graph with each node having an average of ~21 links.

So what do you do with a Graph of this size? First of all, you calculate the Centrality. After quite a bit of crunching, I discovered with great pleasure that the artist closest to all other artists is:

Thelonius Monk

 

Another idea I had while toying with the data is a Playlist Generator that can find the shortest path between artists. Applying the Travelling Salesman Problem, it is possible to find the optimal path between a few* artists and create playlists that gradually morphs between very different genres, say from Classical to Grunge. It could be fun to use for parties when people like different kinds of music and it’s nice to transition smoothly through the music-sphere.

After hacking a few lines of code, here are a few samples of the playlists that this generator would come up with. If you have Spotify installed on your device, you can actually listen to the playlist generated.

In:

  • Japanese New Wave POLYSICS
  • American Alternative Rock Ween
  • German Baroque J. S. Bach

Out:

In:

  • American Minimalist Terry Riley
  • Canadian Pop Justin Bieber
  • Italian Progressive Area
  • American Surf Rock Man Or Astro-Man?

Out:

In:

  • Madagascar Traditional Folk Hiran’ny Tanoran’ny Ntao Lo
  • Uruguayan/Argentine Indie Onda Vaga

Out:

This could be improved a lot and upgraded to a Project. For instance, it could be interesting to take into account the Beats Per Minute of a song in order to make the transition even smoother.

*a few = I only ventured in the naive, all-permutations approach which allows up to only 9-10 waypoints. Probably enough for any practical use.

Post a Comment through Mastodon

If you have a Mastodon account, .

Post a Comment through WordPress

Your email address will not be published. Required fields are marked *

Name *