Commit d97dd891 authored by Steve Tjoa's avatar Steve Tjoa

pca; hpss; pitch transcription

parent 082d13d0
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import numpy, scipy, matplotlib.pyplot as plt, sklearn, stanford_mir\n",
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[← Back to Index](index.html)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Cross Validation"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<a href=\"https://en.wikipedia.org/wiki/Cross-validation_(statistics)\">K-fold cross validation</a> is a method for evaluating the correctness of a classifier.\n",
"\n",
"For example, with 10-fold cross validation:\n",
"\n",
"1. Divide the data set into 10 random partitions.\n",
"2. Choose one of the partitions as the test set. Train on the other nine partitions.\n",
"3. Repeat for the partitions."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Load some features from ten kick drums and ten snare drums:"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"ename": "IOError",
"evalue": "[Errno socket error] [Errno 8] nodename nor servname provided, or not known",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mIOError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-4-a7910ded3ac4>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mtraining_features\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtraining_labels\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mscaler\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mstanford_mir\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_features\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;32m/Users/steve/stanford-mir/stanford_mir/core.pyc\u001b[0m in \u001b[0;36mget_features\u001b[0;34m(collection, features, scaler)\u001b[0m\n\u001b[1;32m 20\u001b[0m scaler=None):\n\u001b[1;32m 21\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mcollection\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;34m'drum_samples_train'\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 22\u001b[0;31m \u001b[0mkick_filepaths\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msnare_filepaths\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdownload_samples\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'drum_samples_train'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 23\u001b[0m kick_signals = [\n\u001b[1;32m 24\u001b[0m \u001b[0mlibrosa\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mload\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mp\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mp\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mkick_filepaths\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/Users/steve/stanford-mir/stanford_mir/core.pyc\u001b[0m in \u001b[0;36mdownload_samples\u001b[0;34m(collection)\u001b[0m\n\u001b[1;32m 86\u001b[0m \u001b[0mfilename\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m'%s_%02d.wav'\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mdrum_type\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mi\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 87\u001b[0m urllib.urlretrieve('http://audio.musicinformationretrieval.com/drum_samples/%s' % filename,\n\u001b[0;32m---> 88\u001b[0;31m filename=os.path.join(collection, filename))\n\u001b[0m\u001b[1;32m 89\u001b[0m \u001b[0mkick_filepaths\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpath\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mjoin\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcollection\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'kick_%02d.wav'\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0mi\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m11\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 90\u001b[0m \u001b[0msnare_filepaths\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpath\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mjoin\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcollection\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'snare_%02d.wav'\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0mi\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m11\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/usr/local/Cellar/python/2.7.6_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.pyc\u001b[0m in \u001b[0;36murlretrieve\u001b[0;34m(url, filename, reporthook, data)\u001b[0m\n\u001b[1;32m 92\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0m_urlopener\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 93\u001b[0m \u001b[0m_urlopener\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mFancyURLopener\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 94\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0m_urlopener\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mretrieve\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0murl\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfilename\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mreporthook\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 95\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0murlcleanup\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 96\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0m_urlopener\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/usr/local/Cellar/python/2.7.6_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.pyc\u001b[0m in \u001b[0;36mretrieve\u001b[0;34m(self, url, filename, reporthook, data)\u001b[0m\n\u001b[1;32m 238\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mIOError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 239\u001b[0m \u001b[0;32mpass\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 240\u001b[0;31m \u001b[0mfp\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0murl\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 241\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 242\u001b[0m \u001b[0mheaders\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0minfo\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/usr/local/Cellar/python/2.7.6_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.pyc\u001b[0m in \u001b[0;36mopen\u001b[0;34m(self, fullurl, data)\u001b[0m\n\u001b[1;32m 206\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 207\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mdata\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 208\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mgetattr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0murl\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 209\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 210\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mgetattr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0murl\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/usr/local/Cellar/python/2.7.6_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.pyc\u001b[0m in \u001b[0;36mopen_http\u001b[0;34m(self, url, data)\u001b[0m\n\u001b[1;32m 343\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mrealhost\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mh\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mputheader\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'Host'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mrealhost\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 344\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0margs\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0maddheaders\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mh\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mputheader\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 345\u001b[0;31m \u001b[0mh\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mendheaders\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 346\u001b[0m \u001b[0merrcode\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0merrmsg\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mheaders\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mh\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgetreply\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 347\u001b[0m \u001b[0mfp\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mh\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgetfile\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/usr/local/Cellar/python/2.7.6_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.pyc\u001b[0m in \u001b[0;36mendheaders\u001b[0;34m(self, message_body)\u001b[0m\n\u001b[1;32m 967\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 968\u001b[0m \u001b[0;32mraise\u001b[0m \u001b[0mCannotSendHeader\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 969\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_send_output\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmessage_body\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 970\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 971\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mrequest\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmethod\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0murl\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mbody\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mheaders\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m{\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/usr/local/Cellar/python/2.7.6_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.pyc\u001b[0m in \u001b[0;36m_send_output\u001b[0;34m(self, message_body)\u001b[0m\n\u001b[1;32m 827\u001b[0m \u001b[0mmsg\u001b[0m \u001b[0;34m+=\u001b[0m \u001b[0mmessage_body\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 828\u001b[0m \u001b[0mmessage_body\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mNone\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 829\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmsg\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 830\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mmessage_body\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 831\u001b[0m \u001b[0;31m#message_body was not a string (i.e. it is a file) and\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/usr/local/Cellar/python/2.7.6_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.pyc\u001b[0m in \u001b[0;36msend\u001b[0;34m(self, data)\u001b[0m\n\u001b[1;32m 789\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msock\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 790\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mauto_open\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 791\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mconnect\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 792\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 793\u001b[0m \u001b[0;32mraise\u001b[0m \u001b[0mNotConnected\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/usr/local/Cellar/python/2.7.6_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.pyc\u001b[0m in \u001b[0;36mconnect\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 770\u001b[0m \u001b[0;34m\"\"\"Connect to the host and port specified in __init__.\"\"\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 771\u001b[0m self.sock = socket.create_connection((self.host,self.port),\n\u001b[0;32m--> 772\u001b[0;31m self.timeout, self.source_address)\n\u001b[0m\u001b[1;32m 773\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 774\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_tunnel_host\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/usr/local/Cellar/python/2.7.6_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.pyc\u001b[0m in \u001b[0;36mcreate_connection\u001b[0;34m(address, timeout, source_address)\u001b[0m\n\u001b[1;32m 551\u001b[0m \u001b[0mhost\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mport\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0maddress\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 552\u001b[0m \u001b[0merr\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mNone\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 553\u001b[0;31m \u001b[0;32mfor\u001b[0m \u001b[0mres\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mgetaddrinfo\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mhost\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mport\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mSOCK_STREAM\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 554\u001b[0m \u001b[0maf\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msocktype\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mproto\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcanonname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msa\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mres\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 555\u001b[0m \u001b[0msock\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mNone\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mIOError\u001b[0m: [Errno socket error] [Errno 8] nodename nor servname provided, or not known"
]
}
],
"source": [
"training_features, training_labels, scaler = stanford_mir.get_features()"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[ 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 1. 1. 1. 1. 1. 1. 1. 1.\n",
" 1. 1.]\n"
]
}
],
"source": [
"print training_labels"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Plot their features:"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'training_features' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-2-f00bdfd12558>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mplt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mscatter\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtraining_features\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtraining_features\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mNameError\u001b[0m: name 'training_features' is not defined"
]
}
],
"source": [
"plt.scatter(training_features[:,0], training_features[:,1])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Initialize the classifier:"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"model = sklearn.neighbors.KNeighborsClassifier(n_neighbors=3)\n",
"model = sklearn.linear_model.LogisticRegression()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Perform 5-fold cross validation:"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"acc = sklearn.cross_validation.cross_val_score(model, random_features, training_labels, cv=5)"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.5\n"
]
}
],
"source": [
"print acc.mean()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"k"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[&larr; Back to Index](index.html)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -271,6 +271,7 @@ div#notebook {
<li><a href="zcr.html">Zero Crossing Rate</a> (<a href="zcr.ipynb">ipynb</a>)</li>
<li><a href="spectral_features.html">Spectral Features</a> (<a href="spectral_features.ipynb">ipynb</a>)</li>
<li><a href="mfcc.html">Mel-Frequency Cepstral Coefficients</a> (<a href="mfcc.ipynb">ipynb</a>)</li>
<li><a href="pitch_transcription_exercise.html">Pitch Transcription Exercise</a> (<a href="pitch_transcription_exercise.ipynb">ipynb</a>)</li>
</ol>
</div>
......@@ -293,9 +294,11 @@ div#notebook {
<ol>
<li><a href="basic_supervised_classification.html">Basic Supervised Classification</a> (<a href="basic_supervised_classification.ipynb">ipynb</a>)</li>
<li><a href="knn.html">K-Nearest Neighbor Classification</a> (<a href="knn.ipynb">ipynb</a>)</li>
<li><a href="cross_validation.html">Cross Validation</a> (<a href="cross_validation.ipynb">ipynb</a>)</li>
<li><a href="knn_instrument_classification.html">Exercise: K-Nearest Neighbor Instrument Classification</a> (<a href="knn_instrument_classification.ipynb">ipynb</a>)</li>
<li><a href="kmeans.html">K-Means Clustering</a> (<a href="kmeans.ipynb">ipynb</a>)</li>
<li><a href="kmeans_instrument_classification.html">Exercise: Unsupervised Instrument Classification using K-Means</a> (<a href="kmeans_instrument_classification.ipynb">ipynb</a>)</li>
<li><a href="notebooks/evaluation.ipynb">Evaluation</a></li>
</ol>
</div>
......@@ -306,7 +309,7 @@ div#notebook {
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Chapter-4:-Matrix-Factorization-and-Evaluation">Chapter 4: Matrix Factorization and Evaluation<a class="anchor-link" href="#Chapter-4:-Matrix-Factorization-and-Evaluation">&#182;</a></h2>
<h2 id="Chapter-4:-Matrix-Factorization">Chapter 4: Matrix Factorization<a class="anchor-link" href="#Chapter-4:-Matrix-Factorization">&#182;</a></h2>
</div>
</div>
</div>
......@@ -316,11 +319,11 @@ div#notebook {
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<ol>
<li><a href="pca.html">Principal Component Analysis</a> (<a href="pca.ipynb">ipynb</a>)</li>
<li><a href="nmf.html">Nonnegative Matrix Factorization</a> (<a href="nmf.ipynb">ipynb</a>)</li>
<li><a href="hpss.html">Harmonic-Percussive Source Separation</a> (<a href="hpss.ipynb">ipynb</a>)</li>
<li><a href="nmf_source_separation.html">Exercise: Source Separation using NMF</a> (<a href="nmf_source_separation.ipynb">ipynb</a>)</li>
<li><a href="notebooks/classify_separated_signals.ipynb">Classification of Separated Signals</a></li>
<li><a href="notebooks/cross_validation.ipynb">Cross Validation</a></li>
<li><a href="notebooks/evaluation.ipynb">Evaluation</a></li>
</ol>
</div>
......
......@@ -66,7 +66,8 @@
"1. [Basic Feature Extraction](basic_feature_extraction.html) ([ipynb](basic_feature_extraction.ipynb))\n",
"1. [Zero Crossing Rate](zcr.html) ([ipynb](zcr.ipynb))\n",
"1. [Spectral Features](spectral_features.html) ([ipynb](spectral_features.ipynb))\n",
"1. [Mel-Frequency Cepstral Coefficients](mfcc.html) ([ipynb](mfcc.ipynb))"
"1. [Mel-Frequency Cepstral Coefficients](mfcc.html) ([ipynb](mfcc.ipynb))\n",
"1. [Pitch Transcription Exercise](pitch_transcription_exercise.html) ([ipynb](pitch_transcription_exercise.ipynb))"
]
},
{
......@@ -82,27 +83,29 @@
"source": [
"1. [Basic Supervised Classification](basic_supervised_classification.html) ([ipynb](basic_supervised_classification.ipynb))\n",
"1. [K-Nearest Neighbor Classification](knn.html) ([ipynb](knn.ipynb))\n",
"1. [Cross Validation](cross_validation.html) ([ipynb](cross_validation.ipynb))\n",
"1. [Exercise: K-Nearest Neighbor Instrument Classification](knn_instrument_classification.html) ([ipynb](knn_instrument_classification.ipynb))\n",
"1. [K-Means Clustering](kmeans.html) ([ipynb](kmeans.ipynb))\n",
"1. [Exercise: Unsupervised Instrument Classification using K-Means](kmeans_instrument_classification.html) ([ipynb](kmeans_instrument_classification.ipynb))"
"1. [Exercise: Unsupervised Instrument Classification using K-Means](kmeans_instrument_classification.html) ([ipynb](kmeans_instrument_classification.ipynb))\n",
"1. [Evaluation](notebooks/evaluation.ipynb)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Chapter 4: Matrix Factorization and Evaluation"
"## Chapter 4: Matrix Factorization"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"1. [Principal Component Analysis](pca.html) ([ipynb](pca.ipynb))\n",
"1. [Nonnegative Matrix Factorization](nmf.html) ([ipynb](nmf.ipynb))\n",
"1. [Harmonic-Percussive Source Separation](hpss.html) ([ipynb](hpss.ipynb))\n",
"1. [Exercise: Source Separation using NMF](nmf_source_separation.html) ([ipynb](nmf_source_separation.ipynb))\n",
"1. [Classification of Separated Signals](notebooks/classify_separated_signals.ipynb)\n",
"1. [Cross Validation](notebooks/cross_validation.ipynb)\n",
"1. [Evaluation](notebooks/evaluation.ipynb)"
"1. [Classification of Separated Signals](notebooks/classify_separated_signals.ipynb)\n"
]
},
{
......
{
"metadata": {
"name": "",
"signature": "sha256:b3f4da5b401fc3911a6fa14e446f660b141ede1e9c80ecd1b470edfb58fc648f"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"CROSS VALIDATION\n",
"----------------\n",
"\n",
"You'll need some of this code and information to calculate your accuracy rate on your classifiers.\n",
"\n",
"EXAMPLE\n",
"\n",
"Let's say we have 10-fold cross validation...\n",
"\n",
"1. Divide test set into 10 random subsets.\n",
"2. 1 test set is tested using the classifier trained on the remaining 9.\n",
"3. We then do test/train on all of the other sets and average the percentages. \n",
"\n",
"To achieve the first step (divide our training set into k disjoint subsets), use the function [Kfold](http://scikit-learn.org/stable/modules/generated/sklearn.cross_validation.KFold.html) in the scikit.learn cross_validation package:\n",
"\n",
" K-Folds cross validation iterator.\n",
" Provides train/test indices to split data in train test sets. Split dataset into k consecutive folds (without shuffling).\n",
"\n",
" You can visit the scikit.learn documentation to look at all the other options."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import numpy as np\n",
"from sklearn import cross_validation\n",
"from sklearn.neighbors import KNeighborsClassifier\n",
"from sklearn import preprocessing\n",
"from essentia.standard import MonoLoader\n",
"from essentia.standard import ZeroCrossingRate, CentralMoments, Spectrum, Windowing, Centroid, DistributionShape\n",
"import urllib2\n",
"import urllib\n",
"\n",
"def process_corpus(corpus_URL):\n",
" \"\"\"Read a list of files to process from the text file at corpusURL. Return a list of URLs\"\"\" \n",
" # Open and read each line\n",
" url_list_text_data = urllib2.urlopen(corpus_URL) # it's a file like object and works just like a file\n",
" for file_URL in url_list_text_data: # files are iterable\n",
" yield file_URL.rstrip()\n",
" \n",
"def spectral_features(filelist):\n",
" \"\"\"\n",
" Given a list of files, retrieve them, analyse the first 100mS of each file and return\n",
" a feature table.\n",
" \"\"\"\n",
" number_of_files = len(filelist)\n",
" number_of_features = 5\n",
" features = np.zeros([number_of_files, number_of_features])\n",
" sample_rate = 44100\n",
"\n",
" for file_index, url in enumerate(filelist):\n",
" print url\n",
" urllib.urlretrieve(url, filename='/tmp/localfile.wav')\n",
" audio = MonoLoader(filename = '/tmp/localfile.wav', sampleRate = sample_rate)()\n",
" zcr = ZeroCrossingRate()\n",
" hamming_window = Windowing(type = 'hamming') # we need to window the frame to avoid FFT artifacts.\n",
" spectrum = Spectrum()\n",
" central_moments = CentralMoments()\n",
" distributionshape = DistributionShape()\n",
" spectral_centroid = Centroid()\n",
"\n",
" frame_size = int(round(0.100 * sample_rate)) # 100ms\n",
" # Only do the first frame for now.\n",
" # TODO we should generate values for the entire file, probably by averaging the features.\n",
" current_frame = audio[0 : frame_size]\n",
" features[file_index, 0] = zcr(current_frame)\n",
" spectral_magnitude = spectrum(hamming_window(current_frame))\n",
" centroid = spectral_centroid(spectral_magnitude)\n",
" spectral_moments = distributionshape(central_moments(spectral_magnitude))\n",
" features[file_index, 1] = centroid\n",
" features[file_index, 2:5] = spectral_moments\n",
" return features\n",
"\n",
"def crossValidateKNN(features, labels):\n",
" \"\"\"\n",
" This code is provided as a template for your cross-validation\n",
" computation. Pass into the variables \"features\", \"labels\" your own data. \n",
"\n",
" As well, you can replace the code in the \"BUILD\" and \"EVALUATE\" sections\n",
" to be useful with other types of Classifiers.\n",
" \"\"\"\n",
" #\n",
" # CROSS VALIDATION \n",
" # The features array is arranged as rows of instances, columns of features in our training set.\n",
" numInstances, numFeatures = features.shape\n",
" numFolds = min(10, numInstances) # how many cross-validation folds do you want - (default=10)\n",
" # divide test set into 10 random subsets\n",
" indices = cross_validation.KFold(numInstances, n_folds = numFolds)\n",
"\n",
" errors = np.empty(numFolds)\n",
" for foldIndex, (train_index, test_index) in enumerate(indices):\n",
" # SEGMENT DATA INTO FOLDS\n",
" print('Fold: %d' % foldIndex) \n",
" print(\"TRAIN: %s\" % train_index)\n",
" print(\"TEST: %s\" % test_index)\n",
" \n",
" # SCALE\n",
" scaler = preprocessing.MinMaxScaler(feature_range = (-1, 1))\n",
" training_features = scaler.fit_transform(features.take(train_index, 0))\n",
" # BUILD NEW MODEL - ADD YOUR MODEL BUILDING CODE HERE...\n",
" model = KNeighborsClassifier(n_neighbors = 3)\n",
" model.fit(training_features, labels.take(train_index, 0))\n",
" # RESCALE TEST DATA TO TRAINING SCALE SPACE\n",
" testing_features = scaler.transform(features.take(test_index, 0))\n",
" # EVALUATE WITH TEST DATA - ADD YOUR MODEL EVALUATION CODE HERE\n",
" model_output = model.predict(testing_features)\n",
" print(\"KNN prediction %s\" % model_output) # Debugging.\n",
" # CONVERT labels(test,:) LABELS TO SAME FORMAT TO COMPUTE ERROR \n",
" labels_test = labels.take(test_index, 0)\n",
" # COUNT ERRORS. matches is a boolean array, taking the mean does the right thing.\n",
" matches = model_output != labels_test\n",
" errors[foldIndex] = matches.mean()\n",
" print('cross validation error: %f' % errors.mean())\n",
" print('cross validation accuracy: %f' % (1.0 - errors.mean()))"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 6
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"snares_URL = \"https://ccrma.stanford.edu/workshops/mir2014/SnareCorpus.txt\"\n",
"snare_file_list = [audio_file_URL for audio_file_URL in process_corpus(snares_URL)]\n",
"kicks_URL = \"https://ccrma.stanford.edu/workshops/mir2014/KickCorpus.txt\"\n",
"kick_file_list = [audio_file_URL for audio_file_URL in process_corpus(kicks_URL)]\n",
"all_files = snare_file_list + kick_file_list\n",
"\n",
"drum_labels = np.empty(len(all_files), np.int32)\n",
"num_of_snares = len(snare_file_list)\n",
"drum_labels[0:num_of_snares] = 1 # set labels to the first sample type, e.g. snare\n",
"drum_labels[num_of_snares: num_of_snares + len(kick_file_list)] = 2 # Set next set to the second sample type, e.g kick\n",
"print drum_labels\n",
"\n",
"drum_features = spectral_features(all_files)\n",
"print drum_features\n",
"\n",
"print crossValidateKNN(drum_features, drum_labels)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"[1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2]\n",
"https://ccrma.stanford.edu/workshops/mir2014/audio/drum%20samples/snares/SNARE_01_01.WAV\n",
"https://ccrma.stanford.edu/workshops/mir2014/audio/drum%20samples/snares/SNARE_02_01.WAV"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\n",
"https://ccrma.stanford.edu/workshops/mir2014/audio/drum%20samples/snares/SNARE_04_01.WAV\n",
"https://ccrma.stanford.edu/workshops/mir2014/audio/drum%20samples/snares/SNARE_05_01.WAV"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\n",
"https://ccrma.stanford.edu/workshops/mir2014/audio/drum%20samples/snares/SNARE_06_01.WAV\n",
"https://ccrma.stanford.edu/workshops/mir2014/audio/drum%20samples/snares/SNARE_07_01.WAV"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\n",
"https://ccrma.stanford.edu/workshops/mir2014/audio/drum%20samples/snares/SNARE_08_01.WAV\n",
"https://ccrma.stanford.edu/workshops/mir2014/audio/drum%20samples/snares/SNARE_09_01.WAV"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\n",
"https://ccrma.stanford.edu/workshops/mir2014/audio/drum%20samples/snares/SNARE_10_01.WAV\n",
"https://ccrma.stanford.edu/workshops/mir2014/audio/drum%20samples/snares/snare_mono.wav"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\n",
"https://ccrma.stanford.edu/workshops/mir2014/audio/drum%20samples/kicks/Bass_Drum_01_V01.WAV\n",
"https://ccrma.stanford.edu/workshops/mir2014/audio/drum%20samples/kicks/Bass_Drum_02_V01.WAV"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\n",
"https://ccrma.stanford.edu/workshops/mir2014/audio/drum%20samples/kicks/Bass_Drum_03_V01.WAV"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\n",
"https://ccrma.stanford.edu/workshops/mir2014/audio/drum%20samples/kicks/Bass_Drum_04_V01.WAV"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\n",
"https://ccrma.stanford.edu/workshops/mir2014/audio/drum%20samples/kicks/Bass_Drum_05_V01.WAV"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\n",
"https://ccrma.stanford.edu/workshops/mir2014/audio/drum%20samples/kicks/Bass_Drum_06_V01.WAV"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\n",
"https://ccrma.stanford.edu/workshops/mir2014/audio/drum%20samples/kicks/Bass_Drum_07_V01.WAV"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\n",
"https://ccrma.stanford.edu/workshops/mir2014/audio/drum%20samples/kicks/Bass_Drum_08_V01.WAV"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\n",
"https://ccrma.stanford.edu/workshops/mir2014/audio/drum%20samples/kicks/Bass_Drum_09_V01.WAV"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\n",
"https://ccrma.stanford.edu/workshops/mir2014/audio/drum%20samples/kicks/Bass_Drum_10_V01.WAV"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\n",
"[[ 1.29251704e-01 2.20017299e-01 4.07947935e-02 8.77821267e-01\n",
" -8.77261162e-03]\n",
" [ 1.06349207e-01 2.09325567e-01 3.52719985e-02 7.70348966e-01\n",
" -3.22882414e-01]\n",
" [ 1.14965983e-01 1.98087305e-01 3.39526162e-02 8.53771806e-01\n",
" -1.91451073e-01]\n",
" [ 1.09977327e-01 1.89880371e-01 3.07796430e-02 9.61023569e-01\n",
" 2.17356920e-01]\n",
" [ 1.37641728e-01 2.61134952e-01 4.25882451e-02 6.05063379e-01\n",
" -4.61072683e-01]\n",
" [ 1.12925172e-01 2.12166250e-01 3.77560928e-02 9.84243870e-01\n",
" 2.55144835e-01]\n",
" [ 1.43990934e-01 2.32887402e-01 4.25517298e-02 8.88096571e-01\n",
" -2.55122185e-02]\n",
" [ 1.24036282e-01 2.34317511e-01 4.48079035e-02 8.41823637e-01\n",
" -9.77532864e-02]\n",
" [ 1.33560091e-01 2.40808740e-01 3.97951268e-02 7.26550639e-01\n",
" -2.08487749e-01]\n",
" [ 1.14058957e-01 2.19529420e-01 3.08201890e-02 9.37722743e-01\n",
" 6.40640974e-01]\n",
" [ 9.97732393e-03 4.34924886e-02 1.27002802e-02 3.57807994e+00\n",
" 1.42459507e+01]\n",
" [ 7.02947844e-03 2.78101377e-02 6.62755780e-03 4.85479450e+00\n",
" 2.90792427e+01]\n",
" [ 5.66893443e-03 1.62475649e-02 2.56283046e-03 7.87885380e+00\n",
" 8.96873932e+01]\n",
" [ 5.66893443e-03 3.63209695e-02 9.78391711e-03 3.97197366e+00\n",
" 1.83651676e+01]\n",
" [ 8.61677993e-03 2.82980110e-02 8.20268691e-03 5.25167370e+00\n",
" 3.25443840e+01]\n",
" [ 7.93650839e-03 2.40181480e-02 5.99115109e-03 5.35486269e+00\n",
" 3.59657173e+01]\n",
" [ 7.70975044e-03 2.50173863e-02 6.07906608e-03 5.63076735e+00\n",
" 3.99530830e+01]\n",
" [ 5.66893443e-03 3.24563682e-02 9.35256947e-03 4.67505932e+00\n",
" 2.59624958e+01]\n",
" [ 8.84353742e-03 3.49452570e-02 8.03499669e-03 4.01454067e+00\n",
" 2.00484810e+01]\n",
" [ 8.61677993e-03 2.26410441e-02 6.27955049e-03 5.77101851e+00\n",
" 3.90028992e+01]]"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\n",
"Fold: 0\n",
"TRAIN: [ 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19]\n",
"TEST: [0 1]\n",
"KNN prediction [1 1]\n",
"Fold: 1\n",
"TRAIN: [ 0 1 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19]\n",
"TEST: [2 3]\n",
"KNN prediction [1 1]\n",
"Fold: 2\n",
"TRAIN: [ 0 1 2 3 6 7 8 9 10 11 12 13 14 15 16 17 18 19]\n",
"TEST: [4 5]\n",
"KNN prediction [1 1]\n",
"Fold: 3\n",
"TRAIN: [ 0 1 2 3 4 5 8 9 10 11 12 13 14 15 16 17 18 19]\n",
"TEST: [6 7]\n",
"KNN prediction [1 1]\n",
"Fold: 4\n",
"TRAIN: [ 0 1 2 3 4 5 6 7 10 11 12 13 14 15 16 17 18 19]\n",
"TEST: [8 9]\n",
"KNN prediction [1 1]\n",
"Fold: 5\n",
"TRAIN: [ 0 1 2 3 4 5 6 7 8 9 12 13 14 15 16 17 18 19]\n",
"TEST: [10 11]\n",
"KNN prediction [2 2]\n",
"Fold: 6\n",
"TRAIN: [ 0 1 2 3 4 5 6 7 8 9 10 11 14 15 16 17 18 19]\n",
"TEST: [12 13]\n",
"KNN prediction [2 2]\n",
"Fold: 7\n",
"TRAIN: [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 16 17 18 19]\n",
"TEST: [14 15]\n",
"KNN prediction [2 2]\n",
"Fold: 8\n",
"TRAIN: [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 18 19]\n",
"TEST: [16 17]\n",
"KNN prediction [2 2]\n",
"Fold: 9\n",
"TRAIN: [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17]\n",
"TEST: [18 19]\n",
"KNN prediction [2 2]\n",
"cross validation error: 0.000000\n",
"cross validation accuracy: 1.000000\n",
"None\n"
]
}
],
"prompt_number": 7
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This code is also posted as a template in `sources/crossValidationTemplate.py` "
]
}
],
"metadata": {}
}
]
}
\ No newline at end of file
{
"metadata": {
"name": "",
"signature": "sha256:3a3278f7c6fb206a34581be477af529e901600f877d2eeeb0456448031912235"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"Pitch Transcription Exercise"
]
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Load an audio file."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import essentia.standard as ess\n",
"loader = ess.MonoLoader(filename='../test/test.wav', sampleRate=44100)\n",
"signal_in = loader()"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from IPython.display import Audio\n",
"#Audio(data=signal_in, rate=44100)"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 2
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Find each note and its pitch."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"def get_onsets(signal_in):\n",
" onset_times, onset_rate = ess.OnsetRate()(signal_in)\n",
" return onset_times"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 3
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"yin = ess.PitchYinFFT()\n",
"spectrum = ess.Spectrum()\n",
"\n",
"def get_pitch(segment):\n",
" if len(segment) < 4096:\n",
" N = len(segment) if len(segment) % 2 == 0 else len(segment) - 1\n",
" else:\n",
" N = 4096\n",
" pitch, pitch_conf = yin(spectrum(segment[:N]))\n",
" return pitch"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 4
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"def generate_sine(pitch, n_duration):\n",
" #print midi, f0\n",
" n = arange(n_duration)\n",
" return 0.2*sin(2*pi*pitch*n/44100.0)"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 5
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"def transcribe_pitch(signal_in):\n",
" \n",
" signal_out = zeros(len(signal_in))\n",
" \n",
" # get onsets\n",
" onsets = get_onsets(signal_in)\n",
" \n",
" # get pitches\n",
" for i in range(len(onsets)-1):\n",
" n0 = int(onsets[i]*44100)\n",
" n1 = int(onsets[i+1]*44100)\n",
" pitch = get_pitch(signal_in[n0:n1])\n",
" \n",
" signal_out[n0:n1] = generate_sine(pitch, n1-n0)\n",
" \n",
" return signal_out\n",
" "
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 6
},
{
"cell_type": "code",
"collapsed": true,
"input": [
"signal_out = transcribe_pitch(signal_in)"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 7
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Play the synthesized transcription."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import essentia\n",
"#Audio(data=signal_out, rate=44100)\n",
"signal_out = sum([signal_out, signal_in], axis=0)\n",
"ess.MonoWriter(filename='../test/out.wav')(essentia.array(signal_out))"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 8
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 8
}
],
"metadata": {}
}
]
}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import numpy, scipy, matplotlib.pyplot as plt, sklearn, stanford_mir\n",
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[&larr; Back to Index](index.html)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Principal Component Analysis "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Load a file:"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"x, fs = librosa.load('prelude_cmaj_10s.wav')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Compute its chromagram:"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"X = librosa.feature.chromagram(x, sr=fs)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(12, 431)\n"
]
}
],
"source": [
"print X.shape"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Display the chromagram:"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.image.AxesImage at 0x111078790>"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXkAAADtCAYAAABagwXcAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XecZFWZ8PHfuaFuxc49PbknMZc0giBBEUTAiIiKyiLG\nldV19111k+67r6u+676ucRXUdcW4ZkxrwowgZpA4pEsaBoZhQs9Mp4r3nnPeP25VTfdMd08D0wOW\nz/fz4TPT1V33nnPq1jOX6uc5j7LWIoQQojM5j/UAhBBCLBwJ8kII0cEkyAshRAeTIC+EEB1MgrwQ\nQnQwCfJCCNHBvMd6APu671vftfnFvSSVGkm1gZfLYGKNtRa/kMUv5SmtD1GOi3IUJm6kT7QWawzK\nSf/dUq6Hk8m2j6uU0/wxQ2XrZkytjkkSHM/DxDFJuYpyHJTn0nPUBtxMrv3cpF4BwDRqoBzi8T3k\nhlbguB4mibEmQTfqVB64D12tc9n7ruC552+g98hV6HodjAXXAWtRrouby9K15oj95m6NAWD87tuo\n7x6lPjIOjsJqg+O56c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BAitdAf15wLXBFF\n0T0AURQZ4JXMmUEthBDiYFnoj2uWAJumPhBFUXmBzymEEKJJtaskF0AYhhcAx0VR9I9THlsNLI+i\n6JczPeeu6F57WLhmwcYkhBCdqDqyldzAUrXv4wsd5EvAb4Bzoyi6NwxDH/ga8OMoimYs+t8wfJoF\nOHV4rm0NXoOTCeAA2xo4s2xr8Mt//9oBtjX4Otm+ISDd1qC+a9u0bQ0m7t7M4FOejOtnZ9zW4GXv\nmWM/g6Yb7/4p7ixl/T9/26XptgbMva1BdvEy3EzwiLY1OP6o5wNzb2vg5Yo4roduVGfZ1uAI3CA3\n+7YGc7gh+gFetjjj/O/8/Dd58Ts+Ahx4W4NrrvvqrNsaBAOLcPzMPtsaGKyx6Ook8eTEnNsa+N3d\nuEEWL5+OM54c5wtv/FxzW4MBlhy7nEVPPTXdhsAakso4ulqhvPkBnGyG3JIlj2hbA2sMRsccu+4Z\nAHNua3DRu8894LYGuaGls25roOs13Eww67YGTpAFa8n0DqCU4sEf/5yvffY6AF73/hdTHD6svVWB\njmvTtjXoXlqa17YG+74PWlsYfOLl7+Ul/3DGnNsaVHZV5rWtgVcq7betgdWapDx5wG0Ngt5e3FwO\nr9hNPDHKnhtvbW9rsPK5p5Dp6sXxgmnbGuy+8UZsosktXTTrtga6NvO2BlN9+28u4aTzjsbLZ2fd\n1mDP3TtZd/5ZmCSeMcgv6GfyURRNAK8CPhmG4ZXAb4EbZgvwQgghDq4FT6GMouh64MyFPo8QQoj9\nSTGUEEJ0MAnyQgjRwSTICyFEB5MgL4QQHUyCvBBCdLAFzZMXQgjx2JI7eSGE6GAS5IUQooNJkBdC\niA4mQV4IITqYBHkhhOhgEuSFEKKD/X8SHYZnhPOd5gAAAABJRU5ErkJggg==\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x10dd3ab10>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"librosa.display.specshow(X, sr=fs, y_axis='chroma')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Display a single chroma vector:"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<Container object of 3 artists>"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXYAAAECCAYAAADq7fyyAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAEDRJREFUeJzt3X9s3Pddx/Hn2Wm3NHa7oXrGWccKbHszCTkTLbRLlv7Q\nlo1Ni+iGJaigY0Fl0K0IsUmlLaIgfkgTVVpGp25dutLOICE1aieqQalgBaee1I0Jkk2wd9XCkAqB\nmaokWUi7Jnf8cef06iR3vvh85+/Hz8df973v3X3eH5/9uo+/n+/3c7VGo4EkqRwjwy5AktRfBrsk\nFcZgl6TCGOySVBiDXZIKY7BLUmGWFewRcVlEPH6a+3dGxFcj4isRcX3/y5Mk9aprsEfETcAe4FVL\n7j8HuAPYAVwJfCQiXrcaRUqSlm85I/angQ8CtSX3vxV4OjMPZeZLwBPAFX2uT5LUo67BnpkPAcdP\ns+t84FDb9hHggj7VJUk6SyuZPD0EjLdtjwPPr6wcSdJKbVjBc78FvDkiXgscpXkY5vZOT6jVOLkw\nzetfD88+u4LWJWn9WHoovKNegr0BEBHXAmOZuSciPg78Nc2R/+cz8+ByXmhqqs4DDxxjYaHeS61r\n3sTEOAsLR4Zdxqqxf9VWcv9K7hs0+9eL2iBXd6zVaExN1dm//+jA2hyk9fDLZf+qq+T+ldw3gImJ\n8Z5G7AO9QGl0FGZnjw2ySUladwYa7BddBNPTZR1+kaS1xiUFJKkwBrskFcZgl6TCGOySVBiDXZIK\nY7BLUmEMdkkqjMEuSYUx2CWpMAa7JBXGYJekwhjsklQYg12SCmOwS1JhDHZJKozBLkmFMdglqTAG\nuyQVxmCXpMIY7JJUGINdkgpjsEtSYQx2SSqMwS5JhTHYJakwBrskFcZgl6TCGOySVBiD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M2L7mZoXlD4Z8Mtp+/mgVfTvFL8HuCu4ZbTH5n5EK8cQLX/Xn6XCq9btbRvmflfABGxFfgY\ncGe31xhUuHZac6YIEfEG4MvAFzLzz4ddTx/tAnZExOPA24AHImJyyDX10/8Aj2Xm8dbcwQsRceGw\ni+qjm4D5zAxefv/OHXJNq6E9T8aB/x1WIashIn6G5n/N78vM57o9flDBPg+8D+A0a85UXivoHgNu\nysz7h1xOX2XmlZl5Vev43j/RnLj572HX1UdP0JwXISI2A5uArn84FbKJl/9bfp7mv/KnftVR9f1j\nRFzZuv1eYK7Tg6skIn6e5kj9qsz89nKeM5CzYoCHaY765lvbuwbU7qDcSvNfv9siYvFY+3sz84Uh\n1qRlyMwvRcQVEfFVmgOdj1b5bIrTuB34k4jYRzPUb8nMktbTXXyvPgHsaf038s/A3uGV1DeN1iHr\nTwH/DjwUEQB/n5m/0+mJrhUjSYUpZgJTktRksEtSYQx2SSqMwS5JhTHYJakwBrskFcZgl6TCGOyS\nVJj/B3AF/eu/gWOrAAAAAElFTkSuQmCC\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x111078c50>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.stem(X[:,0])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Create a PCA model object."
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"model = sklearn.decomposition.PCA(n_components=11, whiten=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Apply PCA to the chromagram:"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"Y = model.fit_transform(X)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(12, 11)\n"
]
}
],
"source": [
"print Y.shape"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Display all of the principal components:"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.image.AxesImage at 0x111dda2d0>"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAOsAAAD9CAYAAABdhYBTAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAEDtJREFUeJzt3W2MlFWaxvF/gw0iIAEUccQgxngkoTdkFEExLTLAoAFZ\nO5oYJRttGWUZRBOyLAKijpIlIn5Ad4dRgkgCs0Zth5FRQ1xwcIgiMYAYMvf4gmRM5J0J8ia61H6o\nageXos5TVacp7vH6JST9cnXVHeDqU111+jx1uVwOETnztav1ACKSjcoq4oTKKuKEyirihMoq4oTK\nKuLEWW19B4sWLYq+NtTU1ERLS0v0tnr37p1kpi5dukQzgwYNYsOGDdHcSy+9lGIkxo8fH80MHDiQ\nTZs2RXMNDQ0pRgLg8OHD0UzPnj3Zu3dvyczmzZtTjUSWlxuHDh3KunXrormzzz47xUisXbs2mpk4\ncSILFy6M5mbPnl1X7ONnxMrao0ePWo9wks6dO9d6hJOciTMB1NfX13qEk3Tt2rXWI5ykV69eVX39\nGVFWEYlTWUWcUFlFnFBZRZxQWUWcUFlFnFBZRZxQWUWcUFlFnFBZRZxQWUWcUFlFnFBZRZxQWUWc\nUFlFnFBZRZxo85Mi9u3blyyX6kDyIUOGZMr17NkzmmlsbKx2HAC++OKLaGbo0KGZcllOd8hq48aN\n0cy0adNYunRpyUynTp1SjUT//v0z5c46K/7fe9SoUdWOA8C7776bKffzn/+84vvQyirihMoq4oTK\nKuKEyirihMoq4kT06bIQwmBgrpndEEK4DFgCHAc+Bn5pZrpmpMhpUHJlDSFMA54HOhY+9DQww8wa\ngTpgXNuOJyKtYg+DPwWayBcT4Kdm1nr0+JvAiLYaTER+qGRZzawF+O6ED514rP9BoFtbDCUiJ6uL\n7QoKIVwC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\n/EZ/4r/ZQfLfTMpS67IeALqe8H47Mzteq2FahRAuBlYDS83sv2s9D/nTOEaGENYAA4EXQwgX1Him\nPcAqM/uu8PPz0RDCeTWeaRqwzswCf/976lDjmVqd+P+6K/C3cm+g1mVdB9wEkOU8p9OhUIJVwDQz\nW1LjcQAws+vNbJiZ3QBsAv7FzOKHMbWtP5H/mZ4Qwk+AzsDemk6Un6H1kdp+8k98pTlkqXobQwjX\nF96+EVhbKlxMTZ8N5sw8z2kG+Ycos0MIrT+73mhmR2s40xnHzP4QQmgMIXxA/pv+pHKf3WwD84AX\nQgjvki/qQ2Z2pMYztf6dTAWeL6z0W4FXyr0h/daNiBO1fhgsIhmprCJOqKwiTqisIk6orCJOqKwi\nTqisIk6orCJO/B/DiC0ysWZ0AAAAAABJRU5ErkJggg==\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x10bdbf150>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.imshow(Y, interpolation='nearest', origin='lower')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Plot one of the principal components:"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<Container object of 3 artists>"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXsAAAECCAYAAAAfE3cCAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFUVJREFUeJzt3X+Q3Hd93/Hn7fkH4rxWoF3EGZh02pj3mJmcgsQE6t8J\n2AkETw1zNKXErT02pk6awYIZ13Eaps0A6YwHO1YpTEcWMRaJMrFqOv4xdR2waskq4YfHtewpvBnR\nwSNSlV6KLQlZgOTb/rG78fok3em+u7d7u5/nY0aj3e/3u9/v+7Pfu9d+7vP97vc70Ww2kSSNt9qw\nC5AkrTzDXpIKYNhLUgEMe0kqgGEvSQUw7CWpAGdUeV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GDYhayAK4FnIuI/Aw8CDwy5nn47CqyN\niAlgLfCzIdfTD/uA99MKdoANmbmr/fi/AO8aSlX9s7B9/yQz97Yfn3CdsoWGHfbnAt2XPn6p/efl\nyMvMI5n544io0wr+3x92Tf0UEdfS+svl0fakiUUWH0UNWldznQX+BfCnwy2n7/YArwK+Q+uvs38/\n3HJ6l5n388pOVffP5I9pfaiNrIXty8z/AxARFwK/Q+silac07GA9ROu6+B21zJwfVjH9FhFvAh4D\n7s3MPx92PX12HXBFROwEfgn4Yvsqp+Pib4BHM/N4+1jETyLi7w67qD66BdiTmcHL+++sIdfUb91Z\nUgdeGFYhKyUifpPWX9fvycz/t9iyww77PcB7ACLiHcDexRcfHe3gexS4JTPvGXI5fZeZl2Xm5e3x\nwv9B6+DQD4ddVx89QetYCxFxHjAFLPrLNGKmePmv6udpDQNMDq+cFfFURFzWfvxuYNdiC4+aiPgt\nWj36yzPz+0stP9SzcYAv0+od7mk/v26YxfTZbbT+bPxERHTG7t/duRqoVrfMfDgiLo2Ib9DqFP32\nqJ/JscDtwJ9ExG5aQf97mbnomO8I6eynj9O6r8ZZwP8EdgyvpL5qtoe77wKeA+5vX6fs8cz8N6d6\nkdfGkaQCDHsYR5I0AIa9JBXAsJekAhj2klQAw16SCmDYS1IBDHtJKoBhL0kF+P9ImMhEqMlCugAA\nAABJRU5ErkJggg==\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x10bde5b90>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.stem(Y[:,5])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[&larr; Back to Index](index.html)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment