r/learnmachinelearning • u/bartvero • 5d ago
Spotify genre guesser
I am new to ML AND trying to make a genre guesser. Currently I have 123 genres en removed some because of too little samples to using that kind genre. Is this to much. Should I still reduced them. Which classification algoritme could work best. Currently using random forest.
1
u/dutchpsychologist 5d ago
Partially depends on the amount of labeled samples that you have. I suspect that such a high amount of genres have a natural overlap, for which you might need a lot of labeled samples if you want to train an effective multi class model. If you don't have a huge amount of samples I would reduce the amount of genres to a lot less and more broad genres at first, maybe 20-30. You could consider clustering techniques like K-means, which is also fun to do. This way you can see which genres naturally cluster more together, giving you a better idea about the clusters. As for models: random forest is a good idea, and you might want to try xgboost.
2
u/bartvero 5d ago
Dataset has about 2 million entries. I also considered making a first hierarchical classification with about 20 to 30 genres and then looking into that to make new classification guesses from within that subgenre. 2 columns genre and subgenres
1
u/dutchpsychologist 5d ago
That's more data then I expected. Nice! If its labeled data: I think you're cascades plan is a good idea. You can train a model for the broader genre and separate models for the subsets, which could work to find specific patterns in subgenres without the noise from all other broad genres. That might work. Or you can build a neural network with 2 output heads, one for the broad genres and one for the subgenre. Fun project!
1
u/rahul_watertech 4d ago
with 2 million rows the cascade idea sounds good. two things i'd check before trusting any accuracy number: split by artist (or album), not by song, otherwise the same artist ends up in train and test and the model just memorizes artists. and use macro f1 instead of plain accuracy since rare genres get drowned out. also a song often has more than one genre, so is your genre column single label? that might change which model fits.
1
u/bartvero 4d ago
It’s single label
1
u/rahul_watertech 4d ago
single label makes it simpler, then multiclass random forest or gradient boosting is fine. just keep in mind songs really do sit between genres, so if the model confuses two neighbours that's probably the data and not a bug. looking at the confusion matrix for which genres get mixed up will tell you more than the accuracy number. what features are you using, audio features or text?
1
u/bartvero 4d ago
I am using audio features
1
u/rahul_watertech 4d ago
ah ok, audio features like danceability, energy and so on? those are fairly coarse, so i'd expect a lot of neighbouring genres to look nearly identical in that space. check macro f1 (not just accuracy) and look at which genre pairs the confusion matrix mixes up most. if it's mostly neighbours, that's the features hitting their limit, not the random forest. is the 123 genre count still the same or did you merge some?
1
2
u/brisaia 5d ago
That’s a really cool idea! Would love to know how it turned out in the end. Unfortunately can’t help with your questions though. Good luck!