Markov analysis of harmonic progressions and cluster analysis of song-level harmonic profiles in the McGill Billboard dataset.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


This repository contains Python and R code to transform and analyze harmonic progressions in the McGill Billboard dataset (BB), including:

  • assembleClusterResultsTable.R takes the output of each cluster solution and merges them with individual song metadata, producing a single table containing song metadata and the cluster assignment from each solution (1-15 clusters) in song_metadata_and_clusters.csv.
  • billboard-2.0-index.csv is an index of all songs in the corpus.
  • chord_by_chord.csv contains a tidy table of all chords in the corpus, in order within each song, with original chord data from BB and key-oriented harmonic function notation from
  • contains a list of markdown-formatted tables of normalized average transitional probability values for each cluster (output of
  • clusters_to_tables.R takes the transition probability analysis for each song in a cluster (from /cluster_tables/) and creates a table of average probabilities for each cluster in each solution (in /cluster_summaries/).
  • performs a K-means cluster analysis on that output, for cardinalities of 1 to 15. Script contains a seed value so you can reproduce our results exactly. Remove seed value to obtain slightly different (random) results.
  • normalizes transitional probability averages for each cluster summary so that rows sum to 1, then writes tables in markdown format to
  • parses BB and transforms the absolute chord notation into key-oriented, functional notation (Roman numerals, identifying the chord root in relation to the tonic pitch of the key, with chord quality removed).
  • defines file reading and parsing functions used by
  • merges song transition probability data with cluster analysis results, and outputs a table for each cluster containing transitional probability data for each song in that cluster to /cluster_tables/.
  • song_metadata_and_clusters.csv is a table containing song metadata and cluster assignments for each solution (1-15 clusters).
  • song_metadata_and_cluster_names.csv is a table containing song metadata and cluster names ("authentic", "plagal", "doo-wop", "blues", etc.) for each solution (1-15 clusters).
  • song_metadata.csv contains metadata for each song, extracted from BB source files.
  • songbysongtransprob.csv contains transitional probability analyses for each song in the corpus.
  • calculates the probability of occurrence of chord-to-chord transitions in each song and outputs a table with results for each song in BB.
  • visualizations.R loads cluster-average transitional probability data for each cluster from /cluster_summaries/ and generates a visualization of that table in /plots/.

BB data can be downloaded from the McGill Billboard dataset website directly. Outputs of all parsing, machine learning, and analysis scripts are already contained in this repository.

To run these scripts yourself, download BB, place the data in the same root folder as these scripts, and move billboard-2.0-index.csv to the BB data folder. Then run the scripts in the following order:

  • to parse and transform the data into key-oriented chord information
  • to analyze the chord-to-chord transitional probabilities for each song
  • to run the cluster analysis algorithm
  • assembleClusterResultsTable.R to create a list of songs, metadata, and cluster assignments for each test
  • to assemble a table of song data for each cluster in each solution
  • clusters_to_tables.R to generate cluster-wide average probability tables for each cluster in each solution
  • to normalize tables and write to markdown
  • visualizations.R to generate visualizations

Articles and blog posts associated with this repository

6 Cluster Analysis

15 Cluster Analysis