Spotify Track Popularity Analysis

Pythonpolarsscikit-learnaltairmarimouv

Analysis of ~170K Spotify tracks to understand what audio features predict popularity. Uses clustering to discover track archetypes, classification to predict popularity tier, and regression to estimate raw popularity scores.

What’s inside

  • Clustering — KMeans and DBSCAN on audio features (danceability, energy, valence, tempo, etc.) to find natural track groupings
  • Classification — RandomForest, GradientBoosting, LogisticRegression to predict high/mid/low popularity tier
  • Regression — Ridge, RandomForestRegressor, GradientBoostingRegressor to estimate popularity score (0–100)
  • EDA — Correlation analysis, PCA, class distributions, feature importance

A look at the data

No single audio feature correlates strongly with popularity — that’s the finding that motivates the ensemble models. Danceability, energy, and valence correlate with each other far more than with the target:

Correlation heatmap of audio features vs popularity

KMeans on the standardized features does find structure — the first principal component (energy/acousticness axis) splits acoustic tracks cleanly from the rest:

KMeans clusters in PCA projection

Stack

Python · polars · scikit-learn · altair · marimo · uv

Run

uv sync
uv run marimo edit notebook.py --watch