Brief
A song described by ten audio features is a point in ten-dimensional space. You can't look at that. In this project you build a 2D map of it, so that similar songs sit near each other and you can see the structure by eye. The same code works for any table of numbers: songs, words, images of digits.
The data is the "Spotify Tracks Dataset" on Kaggle. It has over 100,000 tracks across more than a hundred genres, with audio features such as danceability, energy, loudness, acousticness, valence and tempo. Pick five or six genres that sound different so the map has something to show. Exact t-SNE compares every pair of points, so work with a sample of about 3,000 tracks.
PCA is the linear method. It finds the directions of greatest variance. These are the eigenvectors of the covariance matrix, and you get them from the SVD of the centred data, . The top components are the first columns of , and the map is . Component explains a share of the total variance.
t-SNE is non-linear. It turns distances into neighbour probabilities in the original space, with a Gaussian around each point. On the map it uses a heavier-tailed Student-t kernel, , and moves the points to make match by minimising the KL divergence . Its gradient is
DATA · a public music-features dataset
Objectives
Read-only. Log in to update progress.
VICTORY CONDITIONS
- Your PCA coordinates match sklearn PCA to within 1e-6 (after aligning signs), and your t-SNE trustworthiness is within 0.02 of sklearn TSNE on the same 3,000 tracks. Record the trustworthiness with `python tools/mlarena.py record BL-07 "<your trustworthiness>"`.
- The KL divergence falls over the run, and the README shows the PCA map and the t-SNE map side by side, coloured by genre.
- The README says in a few sentences which genres separate, which overlap, and whether the two maps agree.
Side quests
Terms in plain words
- Dimensionality reduction
- Squeezing data with many columns into a few, while keeping as much of its structure as possible.
- PCA
- Principal component analysis. It finds the directions along which the data varies most and projects onto the top few.
- t-SNE
- A method that places points in 2D so that points which were near neighbours in the original space stay near each other.
- Perplexity
- The t-SNE setting for roughly how many neighbours each point pays attention to. Typical values are 5 to 50.
- Trustworthiness
- A score from 0 to 1 for how many of a point's neighbours on the map were also its neighbours in the original data.