Machine Learning Python

Music Genre Classification

OVERVIEW

A Machine Learning project that classifies music tracks into 10 distinct genres (e.g., Pop, Classical, Hip-Hop) based on acoustic features such as danceability, energy, and acousticness. The project explores dimensionality reduction techniques and utilizes a Neural Network to achieve robust classification performance.

LANGUAGE
Python
DATA PROCESSING
Pandas NumPy Scikit-learn (Preprocessing, PCA, t-SNE)
MODEL
Feedforward Neural Network (Torch)
VISUALIZATION
Matplotlib

METHODOLOGY

01

Data Preprocessing & Visualization

I started by cleaning the raw dataset, removing non-predictive features (e.g., artist_name, track_name) and handling missing values to ensure consistency. I also visualized the acoustic feature distributions to identify non-normal patterns, which informed the choice of using Neural Networks over linear models.

Data Preprocessing Visualization
02

Dimensionality Reduction

To handle high-dimensional audio data, I experimented with PCA, t-SNE, and UMAP algorithms.
- For Modeling: Used PCA to extract the top 4 principal components, capturing variance while reducing input noise.
- For Analysis: Used t-SNE for visualization, revealing distinct clusters for genres like Classical and Hip-Hop that linear methods failed to capture.

t-SNE Projection
03

Neural Network Architecture

I designed a Feedforward Neural Network tailored for the processed PCA inputs. The architecture is optimized to prevent overfitting on the clean dataset:
- Input Layer: 4 features (Principal Components)
- Hidden Layer: 32 units with ReLU activation to handle non-linearity.
- Output Layer: 10 units (Softmax probability distribution).

Result and Evaluation

The final test accuracy was 37.72%, and the AUC score was 0.8372. This means that the model was able to rank predictions well. Since this is a 10-class classification problem, random guessing would only give 10% accuracy, so 38% is much better.

The ROC curve shows that the model performs well on some classes. For example, Classical (class 3), Hip-Hop (class 6), and Rap (class 8) are easy to identify. However, Alternative (class 0) and Electronic (class 5) are harder to separate from others. This may be because some genres have more unique audio features, while others are more similar.

Data Preprocessing Visualization