text_plain_output_1.png image_output_1.png
from sklearn.cluster import KMeans

import numpy as np

import numpy as np # linear algebra

import pandas as pd

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

import seaborn as sns

df = pd.read_csv('/kaggle/input/customer-segmentation-tutorial-in-python/Mall_Customers.csv')

x_k = df['Annual Income (k$)'].values
y_k = df['Spending Score (1-100)'].values

x_k2 = list(zip(x_k, y_k))
x_k2 = np.array(x_k2)
x_k2

model = KMeans(n_clusters=5)
model.fit(x_k2)
y_kmeans = model.predict(x_k2)
y_kmeans