text_plain_output_2.png application_vnd.jupyter.stderr_output_1.png image_output_1.png
from sklearn.cluster import KMeans

import pandas as pd

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import pandas as pd
from sklearn.preprocessing import StandardScaler
df = pd.read_csv('../input/tabular-playground-series-jul-2022/data.csv')
df

from sklearn.cluster import KMeans
km = KMeans(init='random', random_state=0)
y_km = km.fit_predict(df)

km = KMeans(max_iter=300, n_init=10)
elbow_k = kelbow_visualizer(km, df, k=(2, 15))

kmeans = KMeans(n_clusters=5, n_init=10, max_iter=300)
label_pred = kmeans.fit_predict(df)
print('The best number of cluster is: ', elbow_k.elbow_value_)