Commit 1140c091 authored by Leigh Smith's avatar Leigh Smith

Cleaned up remainder of lab1a

parent 16610ca7
{
"metadata": {
"name": "",
"signature": "sha256:7ed94cc2b18891285f61c97615ead2cb2f265d2e6a8d305e44280affbff5a673"
"signature": "sha256:87d9daf99e5dd04a4e931b27d00a174351903b19f38f0fc69d0190f437b45b74"
},
"nbformat": 3,
"nbformat_minor": 0,
......@@ -26,9 +26,11 @@
"cell_type": "code",
"collapsed": false,
"input": [
"import numpy as np\n",
"\n",
"labels = np.empty(20, np.int32)\n",
"labels[0:9] = 1 # First 10 are the first sample type, e.g. kick\n",
"labels[10:19] = 2 # Second 10 are the second sample type, e.g snare\n",
"labels[0:9] = 1 # First 10 are the first sample type, e.g. snare\n",
"labels[10:20] = 2 # Second 10 are the second sample type, e.g kick\n",
"\n",
"model_snare = KNeighborsClassifier(n_neighbors = 1)\n",
"model.fit(scaledTrainingFeatures, labels.take(train_index, 0))\n",
......@@ -36,7 +38,19 @@
],
"language": "python",
"metadata": {},
"outputs": []
"outputs": [
{
"ename": "NameError",
"evalue": "name 'KNeighborsClassifier' is not defined",
"output_type": "pyerr",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-3-914682621b17>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mlabels\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m10\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;36m20\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m2\u001b[0m \u001b[0;31m# Second 10 are the second sample type, e.g kick\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 7\u001b[0;31m \u001b[0mmodel_snare\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mKNeighborsClassifier\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mn_neighbors\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 8\u001b[0m \u001b[0mmodel\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfit\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mscaledTrainingFeatures\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlabels\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtake\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtrain_index\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0mmodel_output\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmodel_snare\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpredict\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mscaledTestingFeatures\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mNameError\u001b[0m: name 'KNeighborsClassifier' is not defined"
]
}
],
"prompt_number": 3
},
{
"cell_type": "markdown",
......
This diff is collapsed.
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