Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

Cluster Analysis in R

Cursus bekijken

Oefeninstructies

  • 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 column cluster to the original customers_spend data frame.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# 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 = ___)
Code bewerken en uitvoeren