Classification

Can a Machine Hear the Difference?

The central question of this portfolio is whether Brazilian and Russian Phonk are statistically distinguishable, not just by ear, but computationally, using the same audio features available through the Spotify API. To answer this, a supervised machine learning classifier was trained on the corpus.


Methodology

Why Random Forest?

A Random Forest algorithm was chosen because it works well with small datasets (N = 114). Some algorithms risk memorising the training data too closely and then failing on new tracks. Random Forest avoids this by using bagging: it trains many separate decision trees on random subsets of the data and then combines their votes. This makes the results more reliable.

Validation: A 10-fold cross-validation was used. The data was split into 10 subsets, and the model was trained and tested 10 times, each time holding out a different subset. This gives a more honest picture of how the model would perform on new data.

Three-Stage Model Development

Stage Strategy Accuracy Kappa
1. Baseline 9 original Spotify features 86.5% 0.73
2. Refined Feature selection (removing noisy features) 90.0% 0.80
3. Final Feature engineering (Aggression = Energy x Tempo) 86.8% 0.74

The Kappa statistic adjusts for the possibility that the model got lucky by chance. A Kappa of 0.80 is considered excellent. The slight drop from Stage 2 to Stage 3 is a known issue called over-parameterisation: adding extra variables to a small dataset can introduce noise, even if those variables are musically meaningful.


Feature Importance and Cluster Structure

What the Model Used

Tempo is the most important feature, which directly confirms what the tempo distribution showed: Brazilian Phonk clusters so tightly at 130 BPM that the model can almost use it as a rule on its own.

Loudness ranks second, fitting with Brazilian Phonk’s heavily compressed production style.

The engineered Aggression feature (Energy x Tempo) also ranks highly, supporting the idea that Brazilian Phonk is defined by the combination of high speed and high energy together.

Independent Check: PCA

PCA reduces all audio features to two dimensions so we can see the corpus visually, without telling the algorithm which tracks belong to which genre.

The Brazilian Phonk cluster is tight and clearly separated, reflecting how consistent and formula-driven that subgenre is. The Russian Phonk cluster is more spread out, with some tracks drifting toward the Brazilian cluster in the middle.

This overlap explains the higher misclassification rate for Russian tracks. Some Russian producers borrow sonic elements from Brazilian Phonk, pushing those tracks into the grey area between clusters.


Class-Specific Performance

Genre Correct Errors Accuracy
🇧🇷 Brazilian Phonk 50 7 87.7%
🇷🇺 Russian Drift Phonk 47 10 82.5%

Brazilian Phonk is easier to classify because its production style is so consistent. Russian Phonk is harder because it is a more experimental subgenre with no fixed rules, and some tracks end up sounding closer to the Brazilian style than to the Russian average.

Together, the classifier and the PCA tell the same story: the two subgenres are computationally distinct, but Russian Drift Phonk is the more varied and open of the two.