Skip to content


Switch branches/tags


Failed to load latest commit information.
Latest commit message
Commit time

JazzML: Computational Jazz Improvisation

Originally inspired by Gillick et al. (2010): "Machine Learning of Jazz Grammars"

UPDATE: See branch "research" for the latest working demo of the project. When executed correctly (download all files, run "$ python"), assuming all libraries are installed, it will generate guitar improvisation and play it against the prerecorded accompaniment.

Computer jazz improvisation powered by machine learning, specifically trigram modeling, K-Means clustering, and chord inference with SVMs.

Needs to be better modularized.


  • NumPy
  • SciPy
  • Pandas
  • Scikit-Learn
  • Matplotlib

In addition, you'll need a couple of specialized music libraries for Python:

If you just want to read about my work (without running any code), please use the nbviewer for iPython notebooks 6a and 6b, which document the full process (except for parsing the raw MIDI data). Here are the links to my work:

Go into the directory:

In that directory, take a look at:
Notebook 1, getting the notes and generating the n-grams: 6a. The N-Gram Pipeline Part I.
Notebook 2, all the advanced clustering/classification for the ngrams: 6b. The N-Gram Pipeline, Part II.
Notebook 3, creating and training the SVM needed for (6b): 7. Predictive Chord Modeling with Bitwise Note Vectors.

For viewing those notebooks, if you get a 400 error on the nbviewer, refresh the page once or twice. Working on this error.

Check out the subdirectory "./presentationfiles" if you'd like to see some pictures of generated vs. original music.

I worked mainly in the subdirectory "./oscar/oscar2", so all of my main code is over there (although it's in iPython files, so you'll have to either get iPython or view the ipython files with

If you're new here: Included is a sample MIDI file (Oscar-Peterson-2.mid) for analysis and generation. For a quick demo, go to the subdirectory "./oscar/oscar2" and run things in this order (assuming you have the dependencies):

First, run the script as:

$ python > oscar2chords.txt (or $ python > oscar2notes.txt based on stdin)

This should give you two data files which represent the chords and the notes encoded in the original MIDI file: oscar2chords.txt, and oscar2notes.txt.

Next, to generate new notes with the N-Gram model, run iPython notebook 6a: The N-Gram Pipeline, Part I which writes out the n-grams to the file oscar2ngrams.txt.

Next, to generate the chord classifier (SVM) with chord notes, first run iPython notebook 5: Extract Chords to process the raw data in oscar2chords.txt, clean it up, and write it out to oscar2chords_extract.txt. Then run iPython notebook 7: Predictive Chord Modeling with Bitwise Note Vectors, which reads in that just-created file, trains an SVM to return those chords based on consonant pentatonic notes (semirandomly generated), and cPickles that SVM to disk.

Finally, for chord accompaniment and dynamic playback, run notebook 6b: The N-Gram Pipeline, Part II.


A (very incomplete) project that combines machine learning with music.






No releases published


No packages published