Bird
0
0

You have a dataset with 6 samples and want to perform hierarchical clustering using the 'ward' method. After computing linkage, how do you extract cluster labels for 2 clusters?

hard📝 Application Q8 of 15
SciPy - Clustering and Distance
You have a dataset with 6 samples and want to perform hierarchical clustering using the 'ward' method. After computing linkage, how do you extract cluster labels for 2 clusters?
AUse <code>fcluster(Z, 2, criterion='maxclust')</code> where Z is linkage output
BUse <code>linkage(Z, t=2)</code> to get labels
CUse <code>fcluster(Z, 2, criterion='distance')</code>
DUse <code>linkage(X, method='ward', clusters=2)</code>
Step-by-Step Solution
Solution:
  1. Step 1: Understand linkage vs clustering labels

    linkage returns cluster merges; labels require fcluster function.
  2. Step 2: Use fcluster with maxclust criterion

    fcluster(Z, 2, criterion='maxclust') extracts 2 clusters labels.
  3. Final Answer:

    Use fcluster(Z, 2, criterion='maxclust') where Z is linkage output -> Option A
  4. Quick Check:

    fcluster with maxclust extracts cluster labels [OK]
Quick Trick: Use fcluster with maxclust to get cluster labels [OK]
Common Mistakes:
  • Trying to get labels directly from linkage
  • Using wrong criterion in fcluster
  • Passing clusters parameter to linkage

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes