MACHINE LEARNING

106403
Back to MACHINE LEARNING

Module 4: Clustering, K-means, K-medoids, Density-based Hierarchical, Spectral .

  1. Q1b. (b) A Machine Learning technique that helps in detecting the outliers in data is called as: - (i) Clustering . (ii) Classification (iii) Anomaly Detection (iv) All of the above20232m

    Module 4: Clustering, K-means, K-medoids, Density-based Hierarchical, Spectral .

    (b) A Machine Learning technique that helps in detecting the outliers in data is called as:

    • (i) Clustering .
      (ii) Classification
      (iii) Anomaly Detection
      (iv) All of the above
    View this question on its own page →
    Worked Solution

    Answer: (iii) Anomaly Detection

    Explanation:

    • Anomaly Detection (also called outlier detection) is the ML technique explicitly designed to identify rare items, events or observations which raise suspicions by differing significantly from the majority of the data.
    • Clustering groups similar data points; outliers may be found as points not belonging to any cluster, but it is not its primary purpose.
    • Classification assigns data to predefined classes; it needs labeled outlier examples which are rarely available.
    • Techniques used for Anomaly Detection: Statistical (Z-score, Gaussian), Density-based (LOF, DBSCAN), Distance-based, Isolation Forest, One-Class SVM, Autoencoders.

    Hence the most specific answer is (iii) Anomaly Detection. Option (iv) All of the above is not best choice because clustering/classification are not primarily outlier detectors.

  2. Q1i. What is the minimum number of variables/features required to perform clustering? (i) 0 (ii) 1 (iii) 2 (iv) 320222m

    Module 4: Clustering, K-means, K-medoids, Density-based Hierarchical, Spectral .

    What is the minimum number of variables/features required to perform clustering?
    (i) 0
    (ii) 1
    (iii) 2
    (iv) 3

    View this question on its own page →
    Worked Solution

    Answer: (ii) 1

    Explanation:

    • Clustering (K-means, hierarchical, DBSCAN) groups data points by similarity in feature space.
    • Requires at least 1 feature/variable to compute distance/similarity. With 0 features there is no data to cluster.
    • With 1 feature, 1D clustering is valid (e.g., points on a line clustered by value: {1,2,10} → clusters {1,2} and {10} via 1D K-means).
    • While typically we use ≥2\ge 2 features for visualization, minimum mathematically is 1.

    Therefore (ii) 1 is correct.

  3. Q1i. A hypothesis which defines the population distribution is called .... (i) Null Hypothesis . (ii) Positive Hypothesis (iii) Negative Hypothesis (iv) Alternative Hypothesis20232m

    Module 4: Clustering, K-means, K-medoids, Density-based Hierarchical, Spectral .

    A hypothesis which defines the population distribution is called ....
    (i) Null Hypothesis .
    (ii) Positive Hypothesis
    (iii) Negative Hypothesis
    (iv) Alternative Hypothesis

    View this question on its own page →
    Worked Solution

    Answer: (i) Null Hypothesis

    Explanation:

    • Null Hypothesis (H0H_0): A hypothesis which defines the population distribution / assumes no effect, no difference. It is a statement to be tested and possibly rejected. Example: μ=μ0\mu = \mu_0, distribution is Normal N(μ,σ2)N(\mu,\sigma^2).
    • Alternative Hypothesis (H1H_1 / HaH_a): Complements H0H_0, indicates existence of effect/difference.
    • The term statistical hypothesis which completely specifies the population distribution (parameters) is called simple hypothesis; if H0H_0 does that it defines the distribution. In MCQ context, expected answer is Null Hypothesis.

    Positive/Negative hypotheses are not standard statistical terms. Hence (i) Null Hypothesis is correct. If question meant simple hypothesis, null hypothesis is the standard example taught as defining population distribution under assumption.

  4. Q8a. What is the difference between K-means and K-medoid algorithm? Explain density-based hierarchical clustering.20227m

    Module 4: Clustering, K-means, K-medoids, Density-based Hierarchical, Spectral .

    What is the difference between K-means and K-medoid algorithm? Explain density-based hierarchical clustering.

    View this question on its own page →
    Worked Solution

    K-means vs K-medoid:

    Aspect K-means (Lloyd) K-medoid (PAM)
    Center Centroid = mean μj=1∣Cj∣∑x\mu_j=\frac1{|C_j|}\sum x (not necessarily data point, continuous) Medoid = actual data point minimizing sum distance to cluster members
    Distance Euclidean (minimizes SSE) Any metric (Manhattan, arbitrary dissimilarity)
    Robustness Sensitive to outliers (mean shifts) Robust (medoid not affected by extreme outlier)
    Cost function J=∑∑∣∣x−μ∣∣2J=\sum\sum||x-\mu||^2 E=∑∑d(x,mj)E=\sum\sum d(x,m_j)
    Complexity O(nkdi)O(nkdi) fast O(k(n−k)2)O(k(n-k)^2) per iteration (PAM) much slower, CLARA/CLARANSCLARA/CLARANS for large data
    When to use Continuous, spherical clusters, fast Categorical/mixed, need representatives from dataset, noisy data

    Density-Based Hierarchical Clustering:

    Combines density and hierarchy. Unlike flat K-means, builds tree (dendrogram) where clustering reflects density connectivity at different thresholds.

    • Core idea: Clusters are dense regions separated by sparse regions. Define ϵ\epsilon-neighborhood and minPtsminPts. Point types: core (≥minPtsminPts in ϵ\epsilon), border, noise. Hierarchical variant (e.g., HDBSCAN, OPTICS, DENCLUE hierarchical) varies ϵ\epsilon/density threshold to create hierarchy.

    • OPTICS: Ordering Points To Identify Clustering Structure — computes reachability distance, produces reachability plot, extracts hierarchy without fixing single ϵ\epsilon.

    • HDBSCAN: Converts DBSCAN to hierarchical, builds minimum spanning tree of mutual reachability, condenses, selects stable clusters via persistence λ=1/distance\lambda=1/distance.

    • Hierarchical density dendrogram: Bottom leaves = core points merge at lowest density threshold as ϵ\epsilon increases.

    Advantages: Finds arbitrary shapes, handles noise, no need to preset kk, hierarchy reveals clusters at multiple densities.

    Steps generic: Estimate density (kernel), build graph where edges if density > threshold, connected components = clusters, vary threshold → hierarchy, prune unstable branches.

  5. Q8b. What is the difference between K-NN and K-means clustering algorithms?20237m

    Module 4: Clustering, K-means, K-medoids, Density-based Hierarchical, Spectral .

    What is the difference between K-NN and K-means clustering algorithms?

    View this question on its own page →
    Worked Solution

    K-NN vs K-means:

    Aspect K-NN (K-Nearest Neighbors) K-means (Clustering)
    Type Supervised, instance-based, lazy classifier/regressor Unsupervised clustering
    Purpose Predict label yy for query using labeled neighbors Group unlabeled data into kk clusters minimizing SSE
    Input Labeled training (xi,yi)(x_i,y_i) Unlabeled xix_i only, need kk preset
    Working For query xqx_q, find kk nearest labeled points by distance, majority vote / average: y^=arg⁡max⁡c∑I(yi=c)\hat y = \arg\max_c \sum \mathbb{I}(y_i=c) Iteratively assign points to nearest centroid μj\mu_j, recompute μj=\mu_j= mean, repeat until convergence
    Training No model building, stores data Builds model (centroids)
    Prediction cost O(nd)O(n d) per query (slow) O(kd)O(k d) after training (fast assign)
    Output Single label per query Cluster id for all points
    Choosing kk kk = neighborhood size via CV (bias-variance) kk = number clusters via elbow/silhouette
    Example Classify email as spam using 5 nearest labeled emails Segment customers into 3 groups without labels

    Common confusion: Both use distance and kk, but meanings completely different: kk in K-NN = neighbors to vote, kk in K-means = clusters. K-NN needs labels, K-means does not. K-NN predicts new point, K-means discovers structure.

    When to use: Labels available + need classification → K-NN. No labels + need grouping → K-means.