lab <- read.csv("data/kmeans-lab-toy.csv")
x_raw <- as.matrix(lab[, c("demand_score", "complexity_score")])
plot(x_raw, pch = 19, xlab = "demand", ylab = "complexity")
Closed-book. Type MCQ letters and short answers as plain text. Put code in the chunks. Do not open other chapters.
Mark guide (matches the lecturers’ split): Clustering 50 · DR 50. Clustering theory ≈ 30 (about two-thirds hierarchical) · clustering code ≈ 20 (10 k-means + 10 hierarchical). DR theory ≈ 25–30 · DR code ≈ 20–25.
About two-thirds of these are hierarchical. For MCQs, write only the letter.
Which statement best describes the main aim of k-means clustering?
A. Find K representative observations that minimise total dissimilarity to the other observations assigned to their clusters.
B. Find assignments and centroids that minimise the within-cluster sum of squares.
C. Find K representatives that minimise the largest distance from any observation to its representative.
D. Merge the closest pair of clusters repeatedly until exactly K clusters remain.
Answer:
What happens in the assignment step of Lloyd’s k-means algorithm?
A. Each observation is allocated to its nearest current centroid.
B. Each observation is allocated to the cluster whose current members have the smallest average dissimilarity to it.
C. Each centroid is replaced by the coordinate-wise mean of its currently assigned observations.
D. The cluster with the largest WCSS is given a new randomly chosen centroid.
Answer:
An observation has a negative silhouette value. What does this most directly indicate?
A. Its own cluster is closer on average than the nearest alternative cluster, but only by a small amount.
B. Its assigned cluster has a larger average WCSS than the other fitted clusters.
C. Its nearest alternative cluster is closer on average than its assigned cluster.
D. Its squared distance to its centroid is above the average squared distance in its cluster.
Answer:
Which statement best describes agglomerative hierarchical clustering?
A. Start with one cluster and repeatedly split the cluster with largest WCSS until K clusters remain.
B. Start with each observation alone and repeatedly merge the closest pair of clusters until one cluster remains.
C. Alternate assignment and centroid update until assignments stop changing.
D. Assign each observation to the nearest of K randomly chosen medoids.
Answer:
For clusters G and H, how is single-linkage dissimilarity defined?
A. The maximum pairwise dissimilarity between a point in G and a point in H.
B. The minimum pairwise dissimilarity between a point in G and a point in H.
C. The average of all pairwise dissimilarities within G and within H.
D. The dissimilarity between the two cluster centroids.
Answer:
A property of agglomerative hierarchical clustering is that
A. merges can be undone if a better split is found later.
B. the dendrogram height has the same units as the original data matrix.
C. once two clusters are merged, they never separate at higher levels.
D. it always reproduces the k-means partition when cut at K.
Answer:
GPS tracks form elongated routes; a few isolated GPS errors may remain. Which assessment of single linkage is best?
A. Prefer single linkage because it always maximises average silhouette.
B. Single linkage is attractive for elongated shapes but is sensitive to bridge points and noise; average or complete may be safer for compact programmes.
C. Single linkage is immune to outliers because it uses the maximum cross distance.
D. Single and complete linkage always give the same dendrogram on Euclidean distances.
Answer:
Why is a visible bend in an elbow plot not proof that the data contain natural clusters?
A. The elbow is always at K=2.
B. A bend becomes formal evidence only after averaging WCSS over enough random starts.
C. WCSS falls mechanically as K grows, and even structureless data can produce a bend.
D. The elbow requires the true number of clusters as input.
Answer:
Six observations, K=2. Start with centroids \boldsymbol{\mu}_1=(1,1) and \boldsymbol{\mu}_2=(7,7).
| Obs | x_1 | x_2 |
|---|---|---|
| A | 1 | 1 |
| B | 1 | 2 |
| C | 2 | 1 |
| D | 7 | 7 |
| E | 8 | 7 |
| F | 7 | 8 |
Answer:
For one observation, a(i)=1.20 and b(i)=1.50.
Answer:
Dissimilarities: d(A,B)=2, d(A,C)=6, d(A,D)=10, d(B,C)=5, d(B,D)=9, d(C,D)=4. Use complete linkage.
Answer:
A team wants multivariate handling profiles for shipment routes. Single linkage at K=2 has average silhouette 0.54 but mainly separates one salinity extreme. Average linkage at K=3 has silhouette 0.43 and three distinct operational profiles.
Give a verdict: recommend / revise / reject. Support with purpose, fit or stability, usefulness, and one limitation.
Answer:
lab <- read.csv("data/kmeans-lab-toy.csv")
x_raw <- as.matrix(lab[, c("demand_score", "complexity_score")])
plot(x_raw, pch = 19, xlab = "demand", ylab = "complexity")
nstart = 25 and a fixed seed. Report tot.withinss and cluster sizes.dist and cluster::silhouette, compute the mean silhouette for K=2,3,4,5. State which K you prefer and why (one or two sentences).# Your clustering codeInterpretation:
routes <- read.csv("data/hierarchical-clustering-lab-toy.csv")
num <- routes[sapply(routes, is.numeric)]
plot(num[, 1:2], pch = 19)
dist object.table(). Comment in one sentence.# Your clustering codeInterpretation:
# If a chunk fails in the real exam: set eval: false or hand in the source.
# That recovers rendering — it does not replace the answer.
stop("example failure")You have performed PCA on a dataset with 50 features. The first 5 principal components explain 99% of the cumulative variance. What is the most plausible conclusion?
A. The original data likely contained a high degree of multicollinearity.
B. The original 50 features were all standardized to have a mean of 0.
C. The data lies almost entirely on a 5-dimensional linear subspace within the original 50-dimensional space.
D. The PCA analysis was run incorrectly, as this result is statistically impossible.
Answer:
In non-metric MDS, “stress” primarily measures:
A. The total variance in the original high-dimensional data.
B. The degree to which the rank-order of distances in the low-dimensional plot is preserved compared to the original dissimilarities.
C. The sum of squared errors between the original data points and their projections.
D. The correlation between the original variables and the MDS dimensions.
Answer:
The ISOMAP algorithm fundamentally differs from PCA by:
A. Using a different optimization criterion for eigenvalue decomposition.
B. Approximating geodesic distances along the data manifold rather than Euclidean distances.
C. Employing a neural network architecture for non-linear projections.
D. Requiring categorical variables to be one-hot encoded.
Answer:
During SOM training, the primary purpose of the neighbourhood function is:
A. To determine the initial random weights of the output nodes.
B. To define the learning rate schedule for the entire network.
C. To update not only the BMU but also its topological neighbours, preserving topology.
D. To calculate the quantization error of the final map.
Answer:
When comparing PCA to linear autoencoders with squared error loss under optimal training:
A. The autoencoder bottleneck learns different components than PCA.
B. The autoencoder learns non-orthogonal components while PCA learns orthogonal ones.
C. The autoencoder bottleneck learns the same subspace as PCA but may rotate it.
D. Autoencoders cannot learn linear projections comparable to PCA.
Answer:
Why must a PCA loading vector be restricted to unit length? Is unit length special compared with any other fixed length?
Answer:
Calculate the principal component score for centred standardised \mathbf{x}=(2,-1,3)' and \mathbf{a}_1=\bigl(\frac13,\frac23,\frac23\bigr)'.
Answer:
Contrast \delta_{ij}, d_{ij} and \hat{d}_{ij} in MDS notation.
Answer:
Discuss the effect on the k-nearest-neighbour graph and the ISOMAP embedding of setting k=1 and k=n-1. What is a reasonable middle ground?
Answer:
Answer:
Answer:
SOM update: \alpha_t=0.5, \mathbf{x}_i-\mathbf{m}_j=(0.4,-0.1)', \boldsymbol{\ell}_{b_i}=(1,2)', \boldsymbol{\ell}_j=(5,5)', h=\exp(-\|\boldsymbol{\ell}_{b_i}-\boldsymbol{\ell}_j\|^2/(2\sigma^2)). Find \sigma^2 so that \Delta\mathbf{m}_j=(0.1,-0.025)'.
Answer:
Data already in memory:
X <- scale(USArrests)prcomp on USArrests with centring and scaling.# Your codeInterpretation:
X.cmdscale.# Your codeInterpretation:
Use the Swiss-roll style point cloud below (already generated). Fit ISOMAP for k=5, k=15, and k=30 (either vegan::isomap or Rdimtools::do.isomap). Plot the embeddings. Which k unfolds best, and why does PCA fail here?
set.seed(5077)
n <- 400
t <- runif(n, 0, 3 * pi)
h <- runif(n, 0, 20)
swiss <- cbind(x = t * cos(t), y = h, z = t * sin(t))# Your codeInterpretation:
On scaled iris[, 1:4] (species unused in training):
keras3 or h2o).# Your codeInterpretation: