Customer Segmentation using K-Means Clustering
By DarchumsTech
Overview
This machine learning project segments mall customers based on their income and spending score using K-Means clustering. It's useful for understanding customer groups for targeted marketing.
Python Code
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.cluster import KMeans
from sklearn.preprocessing import StandardScaler
df = pd.read_csv("Mall_Customers.csv")
X = df[['Annual Income (k$)', 'Spending Score (1-100)']]
X_scaled = StandardScaler().fit_transform(X)
kmeans = KMeans(n_clusters=5, random_state=42)
df['Cluster'] = kmeans.fit_predict(X_scaled)
Cluster Visualization
The image above illustrates how different customer clusters can be visualized and understood in a business context.
Comments
Post a Comment