text_html_output_1.png
from sklearn import manifold

from sklearn.cluster import KMeans

import matplotlib.pyplot as plt

import pandas as pd

df = pd.read_csv('../input/whisky.csv')

dist = []
for i in range(2, 20):
    km = KMeans(n_clusters=i, n_init=10, max_iter=500, random_state=0)
    km.fit(df.iloc[:, 2:-3])
    dist.append(km.inertia_)

km = KMeans(n_clusters=5, n_init=10, max_iter=300, random_state=0)
df['class'] = km.fit_predict(df.iloc[:, 2:-3])
df['class'].values

mds = manifold.MDS(n_components=2, dissimilarity='euclidean', random_state=0)
pos = mds.fit_transform(df.iloc[:, 2:-4])
col = ['orange', 'green', 'blue', 'purple', 'red']
chars = '^<>vo+d'
c_flag = 0
labels = df['Distillery']
plt.rcParams['font.size'] = 15
for label, x, y, c in zip(labels, pos[:, 0], pos[:, 1], df['class']):
    if c == c_flag:
        c_flag = c_flag + 1
    plt.annotate(label, xy=(x, y))

df.query('Distillery == "GlenSpey" or Distillery == "Miltonduff"')