Project Overview

A machine learning project to classify songs as Rock or Not Rock based on their Spotify audio features.

Dataset

  • Source: Spotify
  • Records: 1,000 songs
  • Input features: 11
  • Target: Music genre

Technologies

  • Python
  • Pandas
  • Scikit-learn
  • Matplotlib
  • Seaborn
  • Jupyter Notebook

Methodology

  • Exploratory data analysis
  • Data preparation
  • K-Nearest Neighbours (KNN) classification
  • Hyperparameter optimisation using GridSearchCV
  • Five-fold cross-validation
  • Model performance evaluation

Model Performance

Metric Result
Optimal number of neighbours 9
Distance metric Cosine
Cross-validation accuracy 80.86%
Training accuracy 86.14%
Test accuracy 84.67%

The optimised model correctly classified 254 out of 300 unseen songs.

Confusion Matrix

Confusion Matrix

Confusion matrix for the optimised KNN classifier on the test dataset.

GitHub Repository

View Project on GitHub