A multiclass classification study using 50,000 tracks across 10 genres
Project Detail | Data Link | Report Link |
Spotify | Link | Report Link |
Quick Overview
Genre is easy to recognize until you try to define it with data.
In this project, I tested how well Spotify-style audio features and basic track metadata could distinguish between ten genres without using raw audio, lyrics, or listener behavior. The dataset contained approximately 50,000 tracks, balanced across Alternative, Anime, Blues, Classical, Country, Electronic, Hip-Hop, Jazz, Rap, and Rock.
I compared several ways of representing the data, visualized where genres overlapped, and trained seven classification models. The strongest model reached 57.2% accuracy, a macro F1 score of 56.9%, and a macro one-vs-rest AUC of 0.929.
The gap between those metrics became the most interesting part of the project.
The Question
Spotify provides features such as danceability, energy, acousticness, instrumentalness, speechiness, loudness, and valence. These variables describe useful characteristics of a track, but they are not the music itself.
I wanted to understand two things:
- How much genre information is captured by these structured features?
- Where does that representation stop being sufficient?
This made the project less about finding one winning model and more about testing the limits of the available data.
Approach
I prepared a balanced dataset of roughly 5,000 tracks per genre and used a stratified 90/10 train-test split. Missing duration and tempo values were filled using median values, while the remaining incomplete rows were removed. Feature scaling was fitted only on the training set to avoid leaking information from the test data.
Before classification, I examined the feature distributions and used PCA, t-SNE, UMAP, and LDA to see whether genres formed meaningful regions in the feature space. I also ran K-Means clustering as a label-free baseline.
I then compared:
- Logistic Regression
- Decision Tree
- Random Forest
- Support Vector Machine
- K-Nearest Neighbors
- XGBoost
- Neural Network
This allowed me to compare linear, distance-based, tree-based, kernel, and neural approaches under the same evaluation setup.
What I Found
Some genres were easier to identify than others.
Classical music was relatively distinct because of its higher acousticness and instrumentalness and lower energy. Hip-Hop and Rap overlapped heavily, which was expected given their shared production and vocal characteristics. Rock and Electronic also occupied broad regions rather than forming clean, isolated clusters.
The tuned neural network produced the strongest overall result:
- Accuracy: 57.2%
- Macro F1: 56.9%
- Macro one-vs-rest AUC: 0.929
At first, the high AUC appeared inconsistent with the much lower accuracy. In practice, they describe different parts of the problem.
The model was often good at assigning a higher score to the correct genre than to an unrelated genre. However, it still struggled to select one exact label when several neighboring genres were plausible. This is particularly important for music because genre boundaries are not mutually exclusive in the real world.
A track can share characteristics with Rock, Alternative, and Electronic at the same time, even when the dataset requires it to have only one correct label.
What the Model Was Actually Learning
The project showed that structured audio features contain substantial genre information, but not enough to reproduce how people assign genre labels.
The model could learn that:
- acoustic and instrumental tracks are more likely to be Classical or Jazz
- tracks with high speechiness are more likely to belong to Rap or Hip-Hop
- high-energy, low-acousticness tracks are more common in Electronic music
What it could not observe were many of the signals people use when describing music:
- vocal style
- instrumentation
- harmony and arrangement
- lyrics
- production history
- artist identity
- scene and cultural context
This is why I would describe the system as a useful baseline for genre classification, rather than a model that “understands” music.
Limitations and Next Steps
The dataset was balanced across genres, which made model comparison easier but did not reflect how music is distributed on a real streaming platform.
Genre labels were also treated as single ground-truth categories. A multilabel formulation would likely fit the problem better, especially for closely related genres.
If I continued the project, I would:
- evaluate the models with repeated or nested cross-validation
- test multilabel classification
- add embeddings derived from raw audio
- incorporate lyrics and artist metadata
- evaluate calibration and confusion between related genre families
- test the model on a naturally imbalanced dataset
The biggest improvement would probably come from changing the representation of the music, not simply increasing model complexity.
Tools
Python, Pandas, NumPy, scikit-learn, XGBoost, UMAP, Matplotlib, Seaborn, Jupyter Notebook
Links
- Add your report or data link here

