Chapter 4 · Section 6 practice

Hierarchical Clustering: One Customer Story

Optional practice — Section 4.6 is not covered in the final exam.

Work from question 1 to 10. Edit your Python box, click Run Code, review the result, then click Submit attempt. Reference answers unlock after all ten attempts are submitted. This records completion, not correctness. Each box runs independently. Progress is saved in this browser.

Submitted: 0 / 10

1. Count merge rows

Warm-up. Print Z.shape.

Write your answer, then run it.

2. Read the first height

Warm-up. Print the first merge height.

Write your answer, then run it.

3. Read the final height

Warm-up. Print the last merge height.

Write your answer, then run it.

4. Read the final count

Build your skills. Print the final customer count.

Write your answer, then run it.

5. Cut before any merge

Build your skills. At height1, print the number of groups.

Write your answer, then run it.

6. Make three groups

Build your skills. At height4, print one group label per customer.

Write your answer, then run it.

7. Make two groups

Build your skills. At height6, print one group label per customer.

Write your answer, then run it.

8. Join everyone

Challenge. At height11, print the number of groups.

Write your answer, then run it.

9. Compare the three rules

Challenge. For {A,B} versus C, print single, complete and average linkage using gaps6and5.

Write your answer, then run it.

10. Read a group merge

Challenge. Print the third row of Z and explain it.

Write your answer, then run it.

Reference answers are locked until all 10 attempts are submitted.