from sklearn import preprocessing
from sklearn.cluster import KMeans
import numpy as np
import matplotlib.pyplot as plt


def elbow_method(x_normalized):
    distortions = []
    for i in range(1, 15):
        km = KMeans(n_clusters=i, init='k-means++', n_init=10, max_iter=300,
            random_state=0)
        km.fit(x_normalized)
        distortions.append(km.inertia_)
    plt.plot(range(1, 15), distortions, marker='o')
    plt.xlabel('Number of clusters')
    plt.ylabel('Distortion')
    plt.tight_layout()
    plt.show()

44e6e9f1d48ce4c1e5e954b309db6e7cb6030da1
<mask token>

<mask token>


def elbow_method(x_normalized):
    distortions = []
    for i in range(1, 15):
        km = KMeans(n_clusters=i, init='k-means++', n_init=10, max_iter=300,
            random_state=0)
        km.fit(x_normalized)
        distortions.append(km.inertia_)
    plt.plot(range(1, 15), distortions, marker='o')
    plt.xlabel('Number of clusters')
    plt.ylabel('Distortion')
    plt.tight_layout()
    plt.show()

from sklearn import preprocessing
from sklearn.cluster import KMeans
import numpy as np
import matplotlib.pyplot as plt


def elbow_method(x_normalized):
    distortions = []
    for i in range(1, 15):
        km = KMeans(n_clusters=i, init='k-means++', n_init=10, max_iter=300,
            random_state=0)
        km.fit(x_normalized)
        distortions.append(km.inertia_)
    plt.plot(range(1, 15), distortions, marker='o')
    plt.xlabel('Number of clusters')
    plt.ylabel('Distortion')
    plt.tight_layout()
    plt.show()
