เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

สำรวจกลุ่มลูกค้าขายส่ง

ต่อจากงานที่ทำกับชุดข้อมูลขายส่ง ตอนนี้ถึงเวลาวิเคราะห์ลักษณะเฉพาะของแต่ละกลุ่มแล้ว

เนื่องจากข้อมูลมีมากกว่า 2 มิติ การแสดง scatter plot ของกลุ่มต่างๆ จึงทำได้ยาก แต่สามารถใช้สถิติสรุปเพื่อสำรวจกลุ่มเหล่านี้แทนได้ ในแบบฝึกหัดนี้จะวิเคราะห์ค่าเฉลี่ยของยอดใช้จ่ายในแต่ละกลุ่มสำหรับทั้ง 3 หมวดหมู่

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

การวิเคราะห์กลุ่มข้อมูลใน R

ดูคอร์ส

คำแนะนำการฝึกหัด

  • คำนวณขนาดของแต่ละกลุ่มโดยใช้ count()
  • กำหนดสีและพล็อต dendrogram โดยใช้ความสูงที่ 15,000
  • คำนวณค่าเฉลี่ยการใช้จ่ายของแต่ละหมวดหมู่ภายในแต่ละกลุ่มโดยใช้ฟังก์ชัน summarise_all()

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

dist_customers <- dist(customers_spend)
hc_customers <- hclust(dist_customers)
clust_customers <- cutree(hc_customers, h = 15000)
segment_customers <- mutate(customers_spend, cluster = clust_customers)

# Count the number of customers that fall into each cluster
count(___, ___)

# Color the dendrogram based on the height cutoff
dend_customers <- as.dendrogram(hc_customers)
dend_colored <- color_branches(___, ___)

# Plot the colored dendrogram


# Calculate the mean for each category
segment_customers %>% 
  group_by(cluster) %>% 
  summarise_all(list(mean))
แก้ไขและรันโค้ด