Problem
Given a track, find other tracks a listener is likely to enjoy when no listening history exists. The only signal is a set of Spotify audio features for 43,998 tracks: danceability, energy, loudness, valence, tempo and five more.
The Django app turns that into three lists for any track you search for: the nearest tracks overall, the nearest tracks within its mood, and more from the same artist. The trained artifacts are committed to the repository and loaded once per process, so a request is a lookup and a matrix-vector product, not a training run.
Approach
Cleaning drops rows with missing features and duplicate track IDs, and keeps only the most popular copy of a song that was re-released on several albums. The ten audio features are standardised.
Similar songs come from exact cosine k-NN. Rows are scaled to unit length once, so scoring the whole catalogue is one matrix-vector product plus a partial sort, and nothing is refit per request. That is also why the demo above runs in your browser, on an exported sample of the catalogue.
Moods come from K-Means with six clusters on the same features, each labelled from the sign of its centre’s valence and energy. “Same mood” recommendations are the nearest neighbours inside the query’s cluster.
For 2,000 random queries the evaluation scores the top ten against two baselines: ten random tracks, and the ten most popular. It reports how often the results share the query’s artist, how often they match its language, and how different the ten results are from one another. Silhouette and Davies-Bouldin scores for every k from 2 to 12 check the clusters.
The evaluation is offline and uses proxies. The top ten share the query’s artist more than half the time, against 16.5% for random picks.