Case Study

Music & Machine Learning Pipeline

End-to-end ML pipeline to study how far audio and lyrical content alone can predict music popularity.

Machine LearningNLPData PipelinePython
Scroll to explore

Key Metrics

At a Glance

Dataset

1,550 tracks

Multi-source, deduplicated

Embeddings

384 -> 213 dims

PCA (95% variance)

Best Model

Gradient Boosting

Isolation Forest outliers

Test Performance

RMSE ~ 19.7

R² ~ 0.20

Summary

TL;DR

Built a multi-source ingestion and validation pipeline spanning charts, Spotify metadata, and multilingual lyrics, producing a 1,550-track dataset. Engineered emotional and embedding-based features, evaluated multiple regression models with strict cross-validation, and quantified the limits of content-only prediction.

Background

Context

The project investigates whether intrinsic musical content -- audio features and lyrical sentiment -- can meaningfully predict popularity, independent of external effects like marketing or platform exposure. Emphasis on building a pipeline that is reproducible, auditable, and bias-aware.

Architecture

Pipeline Overview

End-to-End Pipeline

Data Sources

Billboard

Apple Music

Spotify

Validation Pipeline

Normalize

Deduplicate

Join

Sentiment

1,550 Tracks

Clean dataset

Feature Eng.

Embeddings

Emotion scores

Models

Lasso

Ridge

GB

Predictions

Popularity score

Data

Dataset Construction & Validation

Combined multiple chart sources (Billboard, Apple Music, Spotify charts, curated playlists). The pipeline applied four validation passes: normalization of artist/title strings, cross-chart deduplication, Spotify feature joins, and multilingual lyric sentiment integration. Result: a clean master dataset of 1,550 tracks.

DALAS ML pipeline architecture diagram showing data flow from ingestion through validation, feature engineering, and model evaluation

Features

Feature Engineering

01

Emotional Features

Happiness, arousal, and catharsis scores derived from lyrics. High-arousal negativity (catharsis) proved particularly informative for popularity prediction.
02

Lyrics Processing

Lyrics fetched via the Genius API and scored with a multilingual BERT-based sentiment model (nlptown/bert-base-multilingual-uncased-sentiment). Text chunked and aggregated to produce song-level sentiment distributions.
03

Embedding & PCA

SentenceTransformer (all-MiniLM-L6-v2) produced 384-dimensional embeddings per track. PCA reduced these to 213 dimensions, preserving 95% of variance while cutting storage and training cost.

Visualization

PCA Dimensionality Reduction

Dimensionality Reduction

384-D

Embeddings

PCA

213-D

PCA reduced

95% variance preserved

Analysis

Exploratory Analysis & Insights

Popularity increases slightly with arousal, while happiness alone is a poor predictor -- aligning with prior research linking chart success to high-arousal emotional content rather than positive sentiment alone.

Key finding

Models

Modeling & Evaluation

Evaluated multiple regression models under different outlier-handling strategies. Performance measured using cross-validation and held-out test sets, revealing a consistent generalization gap and highlighting the importance of outlier treatment.

ModelOutlier StrategyTest RMSETest R²
LassoNone~20.5~0.14
RidgeNone~20.8~0.11
Gradient BoostingIsolation Forest~19.7~0.20
Metric
lower is better
Lasso20.5
Ridge20.8
Gradient BoostingBEST19.7

Limitations

Bias & Limitations

Known Biases

  • Western and English-language overrepresentation in chart data and lyric availability
  • Platform bias from Spotify and Billboard reflecting algorithmic curation rather than pure listener preference
  • Demographic skew toward younger, high-income users in streaming platforms

These factors explain a significant portion of the remaining prediction error and motivate the inclusion of exposure-based signals in future work.

Contribution

Role

Co-authored the project. Designed and implemented the ingestion and validation pipeline, lyric sentiment extraction, embedding and PCA workflow, model evaluation, and bias analysis.

Future Work

What I'd Do Next

Incorporate exposure-based signals (artist history, playlist placement, release timing) to test how much of the unexplained variance is attributable to external rather than intrinsic factors.