Skip to content
Farhan OsmaniMenu
Farhan OsmaniClose
Get in touch
CH 02 · RESEARCH · M.S. THESIS · ELMHURST UNIVERSITY · 2022

MARS: one recommender to compare them all

Every streaming service runs its own black-box recommender. For my master’s thesis I built MARS, a Music Analysis Recommendation System designed to work across services and act as a neutral benchmark between them.

PROGRAM
M.S. Data Science and Analytics, Elmhurst University
SCOPE
Spotify first; Apple Music, Tidal and others next
TOOLS
Python, Spotipy, PyCaret, LightGBM, scikit-learn
600K+tracks in the library, standing in for a streaming service
700+of my own favorited Spotify tracks, used to train and test
21audio and metadata features
0.93AUC, favorited vs. non-favorited (LightGBM)

01Problem

Spotify, Apple Music, Tidal and the rest each recommend music their own way, and none of them show their work. That makes it hard to judge which service actually recommends better.

MARS is a standard recommender that could run on any service and give listeners an objective way to compare them.

02Data

  • Pulled through the Spotify API with Spotipy
  • Joined track and artist data on their IDs
  • Binned release year; rescaled popularity from 1–100 to 1–10
  • Dropped fields that were highly correlated or didn’t matter for recommendations
Correlation heatmap of the training features. Energy and loudness are positively correlated; instrumentalness is negatively correlated with popularity.
PEARSON CORRELATION, TRAINING SET · THESIS FIGURE 5

03Step 1 · Can a model tell what I’ll like?

I ran PyCaret AutoML to compare classifiers on favorited vs. non-favorited tracks. Extra Trees and LightGBM led; I chose LightGBM, which reached an AUC of 0.93.

MODEL RESULTS FROM THE THESIS (FIGURES 10–11)
MODELACCURACYAUCRECALLPRECISIONF1
Extra Trees · compare0.86330.91960.90610.86160.8817
LightGBM · compare0.86330.92610.89090.87090.8799
LightGBM · final0.88250.93320.90640.89320.8998

The thesis notes some possible overfitting, which is part of the next round of work.

04Step 2 · Recommend from the whole library

  1. Weight genres with TF-IDF, so rare genres count for more than common ones.
  2. Summarize the whole playlist into a single vector, as if it were one song.
  3. Score every library track by cosine similarity to that vector. Smaller angle, closer match.
θYOUR PLAYLIST · ONE VECTORLIBRARY TRACKSMALLER θ = CLOSER MATCH21 FEATURES, DRAWN IN 2D FOR CLARITY
COSINE SIMILARITY, REDRAWN. METHOD AFTER THAKER (2021), CITED IN THE THESIS.

05Result

MARS, the classifier and Spotify’s own recommendations surfaced similar songs.

That means the approach holds up as a baseline. Next: connect more services through their APIs, deploy it as a web app, and A/B test which recommendations people actually pick.

06What I learned

MARS pulled together everything from my data science training and two things I love: data and music.

It taught me how to put third-party ML libraries and tools to work, pull data from a live production API, and fit a model into code that runs against a real service.