Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Customer Segmentation with Clustering | Advanced Analytics for Marketers
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Python for Marketers

bookCustomer Segmentation with Clustering

Clustering is a powerful technique in marketing analytics that helps you discover natural groupings within your customer base. Instead of relying on predefined categories, clustering uses data to reveal segments of customers who share similar behaviors or demographic features. This approach is especially valuable when you want to identify distinct customer segments for more personalized marketing strategies.

12345678910111213141516171819202122
import pandas as pd from sklearn.cluster import KMeans # Sample customer data with features: Age, Annual Income (k$), Spending Score (1-100) data = { "CustomerID": [1, 2, 3, 4, 5, 6], "Age": [23, 45, 31, 35, 52, 40], "AnnualIncome": [15, 40, 25, 60, 80, 55], "SpendingScore": [39, 81, 6, 77, 40, 76] } df = pd.DataFrame(data) # Select features for clustering X = df[["Age", "AnnualIncome", "SpendingScore"]] # Create and fit KMeans model kmeans = KMeans(n_clusters=2, random_state=42) kmeans.fit(X) # Output cluster centers print("Cluster Centers:") print(kmeans.cluster_centers_)
copy

Clusters are formed when the algorithm groups customers based on the similarity of their features, such as age, income, and spending score. Each cluster represents a segment of customers who behave in similar ways or share similar characteristics. As a marketer, you can use these segments to tailor your campaigns, personalize offers, and allocate your budget more effectively, ensuring your message resonates with the right audience.

1234567
# Assign cluster labels to each customer df["Segment"] = kmeans.labels_ # Summarize each segment segment_summary = df.groupby("Segment").mean(numeric_only=True) print("Segment Summary:") print(segment_summary)
copy

1. What is the main goal of clustering in marketing analytics?

2. Which scikit-learn class is used for KMeans clustering?

3. Fill in the blank: Clustering helps marketers find groups of customers with ______ characteristics.

question mark

What is the main goal of clustering in marketing analytics?

Select the correct answer

question mark

Which scikit-learn class is used for KMeans clustering?

Select the correct answer

question-icon

Fill in the blank: Clustering helps marketers find groups of customers with ______ characteristics.

characteristics.

Click or drag`n`drop items and fill in the blanks

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 3. Kapittel 4

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

bookCustomer Segmentation with Clustering

Sveip for å vise menyen

Clustering is a powerful technique in marketing analytics that helps you discover natural groupings within your customer base. Instead of relying on predefined categories, clustering uses data to reveal segments of customers who share similar behaviors or demographic features. This approach is especially valuable when you want to identify distinct customer segments for more personalized marketing strategies.

12345678910111213141516171819202122
import pandas as pd from sklearn.cluster import KMeans # Sample customer data with features: Age, Annual Income (k$), Spending Score (1-100) data = { "CustomerID": [1, 2, 3, 4, 5, 6], "Age": [23, 45, 31, 35, 52, 40], "AnnualIncome": [15, 40, 25, 60, 80, 55], "SpendingScore": [39, 81, 6, 77, 40, 76] } df = pd.DataFrame(data) # Select features for clustering X = df[["Age", "AnnualIncome", "SpendingScore"]] # Create and fit KMeans model kmeans = KMeans(n_clusters=2, random_state=42) kmeans.fit(X) # Output cluster centers print("Cluster Centers:") print(kmeans.cluster_centers_)
copy

Clusters are formed when the algorithm groups customers based on the similarity of their features, such as age, income, and spending score. Each cluster represents a segment of customers who behave in similar ways or share similar characteristics. As a marketer, you can use these segments to tailor your campaigns, personalize offers, and allocate your budget more effectively, ensuring your message resonates with the right audience.

1234567
# Assign cluster labels to each customer df["Segment"] = kmeans.labels_ # Summarize each segment segment_summary = df.groupby("Segment").mean(numeric_only=True) print("Segment Summary:") print(segment_summary)
copy

1. What is the main goal of clustering in marketing analytics?

2. Which scikit-learn class is used for KMeans clustering?

3. Fill in the blank: Clustering helps marketers find groups of customers with ______ characteristics.

question mark

What is the main goal of clustering in marketing analytics?

Select the correct answer

question mark

Which scikit-learn class is used for KMeans clustering?

Select the correct answer

question-icon

Fill in the blank: Clustering helps marketers find groups of customers with ______ characteristics.

characteristics.

Click or drag`n`drop items and fill in the blanks

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 3. Kapittel 4
some-alt