changeset 0:7d69c0d6f4c9

Initial
author DaveM
date Mon, 16 Jan 2017 17:34:29 +0000
parents
children 995546d09284
files .hgignore code/Hierarchical Clustering.ipynb data.zip
diffstat 3 files changed, 96 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore	Mon Jan 16 17:34:29 2017 +0000
@@ -0,0 +1,5 @@
+syntax: glob
+._*
+.DS_Store
+*/.ipynb_checkpoints/*
+data/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/code/Hierarchical Clustering.ipynb	Mon Jan 16 17:34:29 2017 +0000
@@ -0,0 +1,91 @@
+{
+ "cells": [
+  {
+   "cell_type": "code",
+   "execution_count": 1,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [],
+   "source": [
+    "from matplotlib import pyplot as plt\n",
+    "from scipy.cluster.hierarchy import dendrogram, linkage, cophenet\n",
+    "from scipy.spatial.distance import pdist\n",
+    "import numpy as np\n",
+    "import csv\n",
+    "\n",
+    "dataFolder = '../data/'\n",
+    "keyFile = 'AdobeNormalised'\n",
+    "datapath = dataFolder + keyFile"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 2,
+   "metadata": {
+    "collapsed": true
+   },
+   "outputs": [],
+   "source": [
+    "X = np.genfromtxt(datapath+'.csv', delimiter = ',', skip_header = 1)\n",
+    "filenames = np.loadtxt(datapath+'_filenames.csv', dtype = str)\n",
+    "labels = np.loadtxt(datapath+'_labels.csv', dtype = str)\n",
+    "features = np.loadtxt(datapath+'_features.csv', dtype = str)\n"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [],
+   "source": [
+    "print X.shape\n",
+    "print filenames.shape\n",
+    "print features.shape"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [],
+   "source": [
+    "Z = linkage(X)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {
+    "collapsed": true
+   },
+   "outputs": [],
+   "source": []
+  }
+ ],
+ "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.10"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
Binary file data.zip has changed