Get Started

Visualize snake plot

Good work! You will now use the melted dataset to build the snake plot. The melted data is loaded as datamart_melt.

The seaborn library is loaded as sns and matplotlib.pyplot is available as plt.

You can use the console to explore the melted dataset.

This is a part of the course

“Customer Segmentation in Python”

View Course

Exercise instructions

  • Add the plot title.
  • Add the X-axis label "Metric".
  • Add the Y-axis label "Value".
  • Plot a line for each value of the Cluster in datamart_melt.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Add the plot title
plt.____('Snake plot of normalized variables')

# Add the x axis label
plt.____('____')

# Add the y axis label
plt.____('____')

# Plot a line for each value of the cluster variable
sns.____(____=____, x='____', y='____', hue='____')
plt.show()
Edit and Run Code

This exercise is part of the course

Customer Segmentation in Python

IntermediateSkill Level
4.7+
7 reviews

Learn how to segment customers in Python.

In this final chapter, you will use the data you pre-processed in Chapter 3 to identify customer clusters based on their recency, frequency, and monetary value.

Exercise 1: Practical implementation of k-means clusteringExercise 2: Run k-meansExercise 3: Assign labels to raw dataExercise 4: Choosing the number of clustersExercise 5: Calculate sum of squared errorsExercise 6: Plot sum of squared errorsExercise 7: Profile and interpret segmentsExercise 8: Prepare data for the snake plotExercise 9: Visualize snake plot
Exercise 10: Calculate relative importance of each attributeExercise 11: Plot relative importance heatmapExercise 12: End-to-end segmentation solutionExercise 13: Pre-process dataExercise 14: Calculate and plot sum of squared errorsExercise 15: Build 4-cluster solutionExercise 16: Analyze the segmentsExercise 17: Final thoughts

What is DataCamp?

Learn the data skills you need online at your own pace—from non-coding essentials to data science and machine learning.

Start Learning for Free