This repo contains a complete music genre classification pipeline using the GTZAN music genre dataset. It is the final piece of coursework for the course "Introduction to Audio Machine Learning" at the University of Edinburgh. My report achieved a grade of 70 - a first class.
The project compares classical machine learning models with neural networks for predicting genres from audio features and vector embeddings, and is accompanied by a full written report.
- Load and preprocess GTZAN audio into feature representations (e.g. MFCCs and related descriptors).
- Train and evaluate several models, including k‑Nearest Neighbours and a feedforward neural network (MLP).
- Analyse model performance with accuracy and macro F1‑score, with detailed discussion in the report.
- Dataset: GTZAN music genre dataset, with 10 balanced genres and 100 audio clips per genre.
- Split strategy: Fixed train/test split as described in the report, ensuring balanced classes across splits.
- Preprocessing: Audio clips are converted to feature vectors (e.g. MFCCs, spectral features), normalised before training.
You can find the full description of the dataset, preprocessing pipeline, and experimental protocol in the PDF report in this repository.
The project evaluates multiple classifiers:
- **k‑Nearest Neighbours (k‑NN)
- Multilayer Perceptron (MLP)
- Naive Bayes
- Logistic Regression
- Additional hyperparameter choices are documented in the report.
- The best model, an MLP, achieves around 80%+ test accuracy and strong macro F1‑score on GTZAN.
- The report includes confusion matrices and notes common misclassifications between similar genres (e.g. rock vs metal), highlighting where the model struggles.
See Music Genre Classification Report.pdf for:
- Full metric tables (accuracy, macro F1).
- Confusion matrices and per‑genre discussion.
Code/– Jupyter notebooks and Python scripts for:- Data loading and feature extraction
- Model training, hyperparameter tuning, and evaluation
- Visualisations and result analysis
Music Genre Classification Report.pdf– Written report describing methods, experiments, and results.
Create a virtual environment with python version 3.13.7.
Run pip install -r requirements.txt
- Clone the repository:
git clone https://github.com/Kaiwen-W/music-genre-classification-ml.git cd music-genre-classification-ml/Code - Create, activate and install dependencies in a virtual environment as above
- Run Jupyter Notebooks