K-Means Clustering with two variables
Customer Segmentation with K-Means Clustering
1. Import libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from sklearn.cluster import KMeans2. Import dataset
dataset = pd.read_csv('Mall_Customers.csv')
3. Choose variables to use in K-Means Clustering
4. Find the optimal number of clusters using the elbow method

5. Train the K-Means model on the dataset

6. Visualize the clusters

Last updated