# -*- coding: utf-8 -*- """ Created on Fri Oct 23 14:45:21 2015 @author: Camil Staps, s4498062 This is Python 2 code. """ import sys sys.path.insert(0, './packages') import scipy.io as sciio import scipy.cluster.hierarchy as hier from clusterPlot import clusterPlot import matplotlib.pyplot as plt # 4.2.1 for method in ['single', 'complete', 'average']: fig = plt.figure(figsize=(16,18)) for n in range(1,5): synth = sciio.loadmat('./data/synth' + str(n) + '.mat') X = synth['X'] y = synth['y'] Z = hier.linkage(X, method=method, metric='euclidean') cls = hier.fcluster(Z, criterion='maxclust', t=4) plt.subplot(4, 2, n * 2 - 1) clusterPlot(X, cls, y=y) plt.subplot(4, 2, n * 2) hier.dendrogram(Z) plt.tick_params(axis='x', which='both', bottom='off', top='off', labelbottom='off') plt.show()