This project predicts Hip-Hop track popularity using two complementary datasets:
- Spotify: Metadata-based prediction (13 features)
- FMA: Rich audio features (524 features) + CNN on spectrograms Target: 3-class popularity classification (Low / Medium / High)
- Source: Kaggle - Spotify Tracks Dataset
- License: CC0: Public Domain
- Size: 232+ tracks
- Features: 18 attributes including:
popularity: Target variable (0-100)danceability: How suitable for dancing (0.0-1.0)energy: Intensity measure (0.0-1.0)acousticness: Acoustic vs electric (0.0-1.0)valence: Musical positivity (0.0-1.0)tempo: Beats per minute (BPM)- ....
- Example:
Artist: Drake
Track: God's Plan
Danceability: 0.754 | Energy: 0.449 | Valence: 0.357
Duration: 3:18 | Tempo: 77 BPM
Artist Tracks: 156 | Avg Popularity: 84.2
Artist: Unknown Underground
Track: Late Night Session
Danceability: 0.623 | Energy: 0.512 | Valence: 0.441
Duration: 2:47 | Tempo: 92 BPM
Artist Tracks: 1 | Avg Popularity: 0.0
- Source: FMA Dataset on GitHub FMA GitHub
- License: Creative Commons Attribution 4.0 International (CC BY 4.0)
- Subset: Hip-Hop tracks (8,389 tracks)
- Features: After preprocessed 525 features (518 audio + 7 metadata)
- Example:
Artist: Doomtree Album: No Kings Track: The Grand Experiment Duration: 258s | Bit Rate: 320 kbps Comments: Album: 10, Artist: 20, Track: 10 .....
Clone the repository
git clone <repo-url> cd <repo-folder>Install dependencies and run the full pipeline The project includes a Makefile that automates:
make allView Available Commands Type
make helpThis will:
- Install Python dependencies
- Download Spotify dataset from Kaggle
- Preprocess Spotify data (filter Hip-Hop, engineer features, split, scale)
- Download FMA metadata and audio
- Preprocess FMA metadata (extract 525 features)
- Convert MP3 files → spectrograms for CNN
Optiona: Train Models (Pre-trained models available) make train # Train all models (asks for consent) make train_spotify # Train Spotify models only make train_fma # Train FMA models only make train_cnn # Train CNN (takes 0.5-1+ hours)
Optional: Evaluate Models make evaluate # Evaluate all models (asks for consent) make eval_spotify # Evaluate Spotify models make eval_fma # Evaluate FMA models make eval_cnn # Evaluate CNN
The entire data preparation workflow is fully automated using the project’s Makefile.Running the command below downloads datasets, preprocesses them, and generates consistent outputs for all team members. The project includes a Makefile that automates:
make allView Available Commands Type
make helpThis will:
- Install Python dependencies
- Download Spotify dataset from Kaggle
- Preprocess Spotify data (filter Hip-Hop, engineer features, split, scale)
- Download FMA metadata and audio
- Preprocess FMA metadata (extract 525 features)
- Convert MP3 files → spectrograms for CNN
Optiona: Train Models (Pre-trained models available) make train # Train all models (asks for consent) make train_spotify # Train Spotify models only make train_fma # Train FMA models only make train_cnn # Train CNN (takes 0.5-1+ hours)
Optional: Evaluate Models make evaluate # Evaluate all models (asks for consent) make eval_spotify # Evaluate Spotify models make eval_fma # Evaluate FMA models make eval_cnn # Evaluate CNN
FMA has two preprocessing modes:
-
Full Mode (default) - 8,389 tracks
make fma_metadata_full
- Uses all Hip-Hop tracks
- For baseline ML model training
- Output:
X_train.csv,y_train.csv, etc.
-
Fair Mode - 997 tracks (CNN comparison)
make fma_metadata_fair
- Only tracks with spectrograms
- For fair CNN vs ML comparison
- Output:
X_train_fair.csv,y_train_fair.csv,spectrogram_labels.csv
Evaluation Spotify Baseline models Results Summary:
Model Data Type CV Accuracy CV Accuracy Std CV F1 CV F1 Std Test Accuracy Test Precision Test Recall Test F1
RandomForest raw 0.555272 0.010682 0.534611 0.010692 0.572889 0.560561 0.560372 0.550824
Logistic Regression scaled 0.560787 0.008327 0.544361 0.008297 0.580958 0.564873 0.570945 0.561667
KNN scaled 0.484667 0.015347 0.463354 0.016885 0.485207 0.469237 0.475988 0.466237
GaussianNB raw 0.522728 0.007008 0.494348 0.005311 0.532544 0.508015 0.518863 0.504699
Evaluation FMA baseline models Results Summary:
Model Data Type CV Accuracy CV Accuracy Std CV F1 CV F1 Std Test Accuracy Test Precision Test Recall Test F1
RandomForest raw 0.416903 0.030448 0.416804 0.030714 0.32 0.304762 0.305271 0.304974
GaussianNB raw 0.416977 0.014716 0.404621 0.016415 0.26 0.213238 0.246752 0.203595
KNN scaled 0.364538 0.033346 0.348658 0.033960 0.38 0.397974 0.396068 0.363698
Logistic Regression scaled 0.396903 0.024682 0.396516 0.024589 0.36 0.363585 0.367464 0.357262
======================================================================
CNN MODEL EVALUATION - TEST SET RESULTS
======================================================================
Model: cnn_fma_production
Test samples: 100
Metric Value
-------------------------------------
Accuracy 0.3800
Precision (macro) 0.2608
Precision (weighted) 0.2931
Recall (macro) 0.3333
Recall (weighted) 0.3800
F1-Score (macro) 0.2832
F1-Score (weighted) 0.3204
PER-CLASS PERFORMANCE ANALYSIS
======================================================================
Low:
True samples: 39
Predicted as Low: 68
Correctly predicted: 26
Precision: 0.3824
Recall: 0.6667
F1-Score: 0.4860
Medium:
True samples: 36
Predicted as Medium: 30
Correctly predicted: 12
Precision: 0.4000
Recall: 0.3333
F1-Score: 0.3636
High:
True samples: 25
Predicted as High: 2
Correctly predicted: 0
Precision: 0.0000
Recall: 0.0000
F1-Score: 0.0000
======================================================================
PERFORMANCE COMPARISON: CNN vs Baseline Models (FMA - 997 tracks)
======================================================================
Model Accuracy Precision Recall F1-Score
k-NN 0.40 0.397596 0.40 0.364405
CNN (Spectrogram) 0.38 0.293118 0.38 0.320442
Random Forest 0.32 0.319143 0.32 0.319524
Logistic Regression 0.38 0.151224 0.38 0.216350
Naive Bayes 0.26 0.215033 0.26 0.210764
======================================================================