Level 2 — RecallUnsupervised Learning

Unsupervised Learning

30 minutes50 marksprintable — key stays hidden on paper

Level: 2 (Recall — definitions, standard problems, short derivations) Time limit: 30 minutes Total marks: 50


Q1. Define unsupervised learning and state one key difference from supervised learning. (3 marks)

Q2. State the two alternating steps of the K-Means algorithm and write the objective function (within-cluster sum of squares) it minimizes. (5 marks)

Q3. Given the 1-D points {2,4,10,12}\{2, 4, 10, 12\} with initial centroids c1=3c_1 = 3 and c2=11c_2 = 11, perform one iteration of K-Means (one assignment step + one update step). State the new centroids. (6 marks)

Q4. Briefly explain the elbow method and the silhouette score for choosing KK. Write the silhouette coefficient formula for a single point. (6 marks)

Q5. State the core idea of K-Means++ initialization and explain why it is preferred over random initialization. (4 marks)

Q6. Distinguish agglomerative from divisive hierarchical clustering. List and briefly describe three linkage methods. (6 marks)

Q7. For DBSCAN, define the parameters ε\varepsilon (eps) and minPts, and define a core point, a border point, and a noise point. (6 marks)

Q8. The covariance matrix of a 2-D centered dataset is Σ=(4001).\Sigma = \begin{pmatrix} 4 & 0 \\ 0 & 1 \end{pmatrix}. Find the eigenvalues, the first principal component direction, and the proportion of variance explained by PC1. (6 marks)

Q9. State two differences between PCA and t-SNE with respect to their goals and properties. (4 marks)

Q10. Name two anomaly detection methods and, for each, give one sentence on how it flags an anomaly. (4 marks)

Answer keyMark scheme & solutions

Q1. (3 marks)

  • Unsupervised learning: learning patterns/structure from unlabeled data (no target output). (2)
  • Difference: supervised learning uses labeled input–output pairs to predict targets; unsupervised has no labels and seeks structure (clusters, low-dim representations). (1)

Q2. (5 marks)

  • Assignment step: assign each point to nearest centroid. (1.5)
  • Update step: recompute each centroid as the mean of its assigned points. (1.5)
  • Objective (WCSS): (2) J=k=1KxiCkxiμk2J = \sum_{k=1}^{K}\sum_{x_i \in C_k} \lVert x_i - \mu_k \rVert^2

Q3. (6 marks)

  • Assignment with c1=3,c2=11c_1=3, c_2=11: (3)
    • 2 → c1c_1 (|2−3|=1 < |2−11|=9)
    • 4 → c1c_1 (|4−3|=1 < |4−11|=7)
    • 10 → c2c_2 (|10−11|=1 < |10−3|=7)
    • 12 → c2c_2 (|12−11|=1 < |12−3|=9)
    • Cluster 1 = {2,4}, Cluster 2 = {10,12}
  • Update: (3)
    • c1=(2+4)/2=3c_1 = (2+4)/2 = 3
    • c2=(10+12)/2=11c_2 = (10+12)/2 = 11
  • New centroids: c1=3c_1 = 3, c2=11c_2 = 11 (already converged). (state result)

Q4. (6 marks)

  • Elbow method: plot WCSS vs KK; choose KK at the "elbow" where the rate of decrease sharply slows (diminishing returns). (2)
  • Silhouette score: measures how well a point fits its cluster vs the nearest other cluster; average over all points, higher (max 1) is better. (2)
  • Formula for point ii: (2) s(i)=b(i)a(i)max{a(i),b(i)}s(i) = \frac{b(i) - a(i)}{\max\{a(i), b(i)\}} where a(i)a(i) = mean intra-cluster distance, b(i)b(i) = mean distance to nearest other cluster.

Q5. (4 marks)

  • Idea: choose the first centroid randomly, then choose each subsequent centroid with probability proportional to squared distance D(x)2D(x)^2 from the nearest already-chosen centroid. (2)
  • Preferred because it spreads initial centroids apart → faster convergence, better/more consistent solutions, avoids poor local minima from random init. (2)

Q6. (6 marks)

  • Agglomerative: bottom-up; start with each point as its own cluster and merge closest pairs iteratively. (1.5)
  • Divisive: top-down; start with one cluster containing all points and recursively split. (1.5)
  • Linkage methods (any three, 1 mark each): (3)
    • Single linkage: distance = minimum pairwise distance between clusters.
    • Complete linkage: distance = maximum pairwise distance.
    • Average linkage: distance = mean of all pairwise distances.
    • (Ward: merges to minimize increase in total within-cluster variance.)

Q7. (6 marks)

  • ε\varepsilon (eps): radius of neighborhood around a point. (1)
  • minPts: minimum number of points required within ε\varepsilon to form a dense region. (1)
  • Core point: has ≥ minPts points (including itself) within ε\varepsilon. (1.5)
  • Border point: within ε\varepsilon of a core point but not itself core (fewer than minPts neighbors). (1.5)
  • Noise point: neither core nor border (not reachable from any core point). (1)

Q8. (6 marks)

  • Σ\Sigma is diagonal → eigenvalues are λ1=4\lambda_1 = 4, λ2=1\lambda_2 = 1. (2)
  • First PC = eigenvector of largest eigenvalue = (1,0)T(1,0)^T (the x-axis direction). (2)
  • Proportion of variance explained by PC1: (2) λ1λ1+λ2=44+1=0.8=80%\frac{\lambda_1}{\lambda_1+\lambda_2} = \frac{4}{4+1} = 0.8 = 80\%

Q9. (4 marks) (any two, 2 marks each)

  • PCA is linear and preserves global structure/variance; t-SNE is nonlinear and preserves local neighborhood structure.
  • PCA gives a deterministic projection usable for new data; t-SNE is stochastic, mainly for visualization, and doesn't easily embed new points.
  • PCA distances/variances are meaningful; t-SNE cluster sizes and inter-cluster distances are not reliably interpretable.

Q10. (4 marks) (any two, 2 marks each)

  • Statistical / z-score: flag points beyond a threshold (e.g. z>3|z| > 3) from the mean.
  • Isolation Forest: anomalies are isolated in fewer random splits → shorter path length flags them.
  • One-Class SVM: learns a boundary around normal data; points outside are anomalies.
  • LOF (Local Outlier Factor): compares a point's local density to neighbors' densities; much lower density flags it.
  • DBSCAN: points labeled as noise are treated as anomalies.

[
  {"claim": "Q3 new centroids are 3 and 11", "code": "c1=(2+4)/2; c2=(10+12)/2; result = (c1==3 and c2==11)"},
  {"claim": "Q8 eigenvalues of diag(4,1) are 4 and 1", "code": "M=Matrix([[4,0],[0,1]]); ev=sorted(M.eigenvals().keys()); result = (ev==[1,4])"},
  {"claim": "Q8 PC1 explained variance is 0.8", "code": "result = Rational(4,4+1)==Rational(4,5) and float(Rational(4,5))==0.8"},
  {"claim": "Q3 assignment: 2,4 to c1 and 10,12 to c2 given c1=3,c2=11", "code": "pts=[2,4,10,12]; assign=[1 if abs(p-3)<abs(p-11) else 2 for p in pts]; result = (assign==[1,1,2,2])"}
]