Segment wholesale customers
You're now ready to use hierarchical clustering to perform market segmentation (i.e. use consumer characteristics to group them into subgroups).
In this exercise you are provided with the amount spent by 45 different clients of a wholesale distributor for the food categories of Milk, Grocery & Frozen. This is stored in the data frame customers_spend
. Assign these clients into meaningful clusters.
Note: For this exercise you can assume that because the data is all of the same type (amount spent) and you will not need to scale it.
Cet exercice fait partie du cours
Cluster Analysis in R
Instructions
- Calculate the Euclidean distance between the customers and store this in
dist_customers
. - Run hierarchical clustering using complete linkage and store in
hc_customers
. - Plot the dendrogram.
- Create a cluster assignment vector using a height of 15,000 and store it as
clust_customers
. - Generate a new data frame
segment_customers
by appending the cluster assignment as the columncluster
to the originalcustomers_spend
data frame.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Calculate Euclidean distance between customers
dist_customers <- ___
# Generate a complete linkage analysis
hc_customers <- ___
# Plot the dendrogram
# Create a cluster assignment vector at h = 15000
clust_customers <- ___
# Generate the segmented customers data frame
segment_customers <- mutate(___, cluster = ___)