Mercurial > hg > sfx-subgrouping
view code/Hierarchical Clustering.ipynb @ 0:7d69c0d6f4c9
Initial
author | DaveM |
---|---|
date | Mon, 16 Jan 2017 17:34:29 +0000 |
parents | |
children | 995546d09284 |
line wrap: on
line source
{ "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 }