Bird
0
0

Examine this code snippet:

medium📝 Debug Q6 of 15
SciPy - Clustering and Distance
Examine this code snippet:
from scipy.cluster.hierarchy import dendrogram, linkage
import numpy as np
X = np.random.rand(6, 2)
Z = linkage(X, method='average')
dn = dendrogram(Z, orientation='diagonal')

What is the issue here?
AIncorrect method name in linkage function
BMissing import for matplotlib.pyplot
CInvalid value for the 'orientation' parameter
DInput data X is not a NumPy array
Step-by-Step Solution
Solution:
  1. Step 1: Check 'orientation' parameter

    The valid values for orientation in dendrogram are 'top', 'bottom', 'left', or 'right'.
  2. Step 2: Identify invalid value

    The value 'diagonal' is not supported and will cause an error.
  3. Final Answer:

    Invalid value for the 'orientation' parameter -> Option C
  4. Quick Check:

    Verify allowed parameter values in documentation [OK]
Quick Trick: Orientation must be one of top, bottom, left, right [OK]
Common Mistakes:
  • Using unsupported orientation values
  • Assuming linkage method names are case-insensitive
  • Passing non-NumPy arrays without conversion

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes