MulaiMulai sekarang secara gratis

K-means segmentation averages

In this exercise, you will explore the average column values for a 3-segment solution with K-means. As part of the test & learn exploration process, visually inspecting the segmentation solutions is critical to identify the most business relevant option.

The seaborn as sns, and matplotlib.pyplot as plt. Also, we have run a 3-segment solution with K-means and loaded the dataset with assigned segment labels as wholesale_kmeans3 DataFrame.

Latihan ini adalah bagian dari kursus

Machine Learning for Marketing in Python

Lihat Kursus

Petunjuk latihan

  • Group by the segment label and calculate average column values.
  • Print the average column values per each segment.
  • Create a heatmap on the average column values per each segment.
  • Display the chart.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Group by the segment label and calculate average column values
kmeans3_averages = wholesale_kmeans3.___(['___']).___().round(0)

# Print the average column values per each segment
print(___)

# Create a heatmap on the average column values per each segment
sns.___(___.T, cmap='YlGnBu')

# Display the chart
plt.___()
Edit dan Jalankan Kode