comparison code/Hierarchical Clustering.ipynb @ 0:7d69c0d6f4c9

Initial
author DaveM
date Mon, 16 Jan 2017 17:34:29 +0000
parents
children 995546d09284
comparison
equal deleted inserted replaced
-1:000000000000 0:7d69c0d6f4c9
1 {
2 "cells": [
3 {
4 "cell_type": "code",
5 "execution_count": 1,
6 "metadata": {
7 "collapsed": false
8 },
9 "outputs": [],
10 "source": [
11 "from matplotlib import pyplot as plt\n",
12 "from scipy.cluster.hierarchy import dendrogram, linkage, cophenet\n",
13 "from scipy.spatial.distance import pdist\n",
14 "import numpy as np\n",
15 "import csv\n",
16 "\n",
17 "dataFolder = '../data/'\n",
18 "keyFile = 'AdobeNormalised'\n",
19 "datapath = dataFolder + keyFile"
20 ]
21 },
22 {
23 "cell_type": "code",
24 "execution_count": 2,
25 "metadata": {
26 "collapsed": true
27 },
28 "outputs": [],
29 "source": [
30 "X = np.genfromtxt(datapath+'.csv', delimiter = ',', skip_header = 1)\n",
31 "filenames = np.loadtxt(datapath+'_filenames.csv', dtype = str)\n",
32 "labels = np.loadtxt(datapath+'_labels.csv', dtype = str)\n",
33 "features = np.loadtxt(datapath+'_features.csv', dtype = str)\n"
34 ]
35 },
36 {
37 "cell_type": "code",
38 "execution_count": null,
39 "metadata": {
40 "collapsed": false
41 },
42 "outputs": [],
43 "source": [
44 "print X.shape\n",
45 "print filenames.shape\n",
46 "print features.shape"
47 ]
48 },
49 {
50 "cell_type": "code",
51 "execution_count": null,
52 "metadata": {
53 "collapsed": false
54 },
55 "outputs": [],
56 "source": [
57 "Z = linkage(X)"
58 ]
59 },
60 {
61 "cell_type": "code",
62 "execution_count": null,
63 "metadata": {
64 "collapsed": true
65 },
66 "outputs": [],
67 "source": []
68 }
69 ],
70 "metadata": {
71 "kernelspec": {
72 "display_name": "Python 2",
73 "language": "python",
74 "name": "python2"
75 },
76 "language_info": {
77 "codemirror_mode": {
78 "name": "ipython",
79 "version": 2
80 },
81 "file_extension": ".py",
82 "mimetype": "text/x-python",
83 "name": "python",
84 "nbconvert_exporter": "python",
85 "pygments_lexer": "ipython2",
86 "version": "2.7.10"
87 }
88 },
89 "nbformat": 4,
90 "nbformat_minor": 0
91 }