My Attempt at Genre Classification

I did this for a school project. I’m a noobie when it comes to Deep Learning and I know there are others that have done a better job but here is my shot at it:

% correctness under strict measure: 76.9
% correctness under the regex standard: 60.6
% Top 3 correctness: 88.9
% Top 5 correctness: 92.8
% Top 10 correctness: 96.7

Unfortunately, part of the reason why I’m getting a decent accuracy is because the dataset is populated mostly by rock music and spams that a lot. I should try to retrain my model with a lower class weight for the “rock” genre to see if that changes things.

Here are the accuracy for the genres when I take out the “main genres”:

% correctness under strict measure: 23.6
% correctness under the regex standard: 51.9
% Top 3 correctness: 47.2
% Top 5 correctness: 59.9
% Top 10 correctness: 76.1

The results from training:

The model itself. It’s fairly unbiased in terms of selecting features since I know little about which features would end up being the most important:


This is great work! Thanks for posting it. I’m still looking through the code, but it looks like a really thorough exploration of the genre data in Musicbrainz.
It would be great if you could also include the mapping that you used of musicbrainz ids -> genres. This would be useful for other people who wanted to try and build a better model using the same dataset.
Two things that we typically do in machine learning tasks which you might want to further apply here:

  • Balance the classes. Normally we will ensure that there are the same number of items in each class. As you said, retraining your model with weights or manually limiting all classes to the same size should help here
  • Perform artist filtering: This is so that the model doesn’t accidentally learn specific features that a representative of a particular musician. Often we will choose only one recording per album (if we don’t have a lot of original data), or even better only one recording per artist. Given that you have the metadata from musicbrainz too, this could be really interesting - it’d be interesting to see what other filters you could apply. Does music from particular producers sound the same? What about solo artists after they’ve played in a band?

I’ll take a further look at this with some of my colleagues, it definitely looks like something that we’d be happy to give you more feedback on if you want to continue working on the project. Thanks again!


Thanks a lot for the feedback, I also had some hopes of implementing some sort of clustering as well to see what songs sound similar to each other or even if they used their samples but I never got around to it due to deadlines. I also recently just found out about word embeddings which might better take into account subgenres whereas I just encoded everything into a matrix.

I should try to include some of the datasets, and some more of the code as well. But there is some cleaning I have to do.

For now I have another project to attend to but I’ll most certainly try and revisit this one right after.

EDIT: I have uploaded my gid/mbid to genre mapping in the main directory along with the final model and predictor in the “music_predictor” directory.

1 Like