MLCrack

    CLASSICAL ML ยท INTERVIEW QUESTION

    How do you determine the optimal number of clusters?

    ๐ŸŸก intermediate ยท Unsupervised Learning

    Hint: Think about the elbow method, silhouette scores, and information criteria.

    Answer

    Methods:

    1. Elbow method: plot within-cluster sum of squares (WCSS) vs K, look for the 'elbow' where improvement slows. Subjective but popular.

    2. Silhouette analysis: measures how similar a point is to its own cluster vs other clusters. Score range [-1,1], higher is better. Average silhouette guides K selection.

    3. Gap statistic: compares WCSS to null reference distribution.

    4. Information criteria: BIC/AIC for Gaussian Mixture Models โ€” principled model selection.

    5. Stability: run clustering multiple times, pick K with most consistent results.

    6. Domain knowledge: often the most important factor.

    Practical tips: try multiple K values, visualize with t-SNE/UMAP, validate clusters make business sense. DBSCAN and hierarchical clustering don't require K upfront.