
DS-GA 3001 - Fall 2026
NYU Center for Data Science
2026-10-13
Etienne Bernard: “… the goal of clustering is to separate a set of examples into groups called clusters”
Bernard, E. (2021). Introduction to Machine Learning, ch. Clustering. Wolfram Media.
# Code source: Gaël Varoquaux
# Modified for documentation by Jaques Grobler
# License: BSD 3 clause
#
import matplotlib.pyplot as plt
from sklearn import datasets
iris = datasets.load_iris()
_, ax = plt.subplots()
scatter = ax.scatter(iris.data[:, 2], iris.data[:, 1])
ax.set(xlabel=iris.feature_names[2], ylabel=iris.feature_names[1])
_ = ax.legend(
scatter.legend_elements()[0], iris.target_names, loc="lower right", title="Classes"
)

Objective: minimize within-cluster sum of squares \(\;\sum_{c=1}^{k} \sum_{x \in C_c} \lVert x - \mu_c \rVert^2\)
Built-in assumptions: k is known · clusters are convex and roughly spherical · similar sizes · feature scale is meaningful

Right number of clusters, wrong definition of a cluster.




The elbow says 3, the silhouette says 2, the botanist says 3.

One tree, every k: the cut height is the choice.
Required: Bernard, Introduction to Machine Learning — Clustering (Wolfram)
Cluster analysis (Wikipedia)
k-means clustering (Wikipedia)
DBSCAN (Wikipedia)
Input data may have thousands or millions of dimensions!
Dimensionality Reduction represents data with fewer dimensions
Assumption: data lies on a lower dimensional space
Slides based on material from Prof. Yi Zhang
What operations did we perform? What’s the intrinsic dimensionality?
Here the underlying manifold is non-linear
Bishop, C. M. (2006). Pattern Recognition and Machine Learning, §12.1. Springer.
array([[ 0., 0., 5., 13., 9., 1., 0., 0.],
[ 0., 0., 13., 15., 10., 15., 5., 0.],
[ 0., 3., 15., 2., 0., 11., 8., 0.],
[ 0., 4., 12., 0., 0., 8., 8., 0.],
[ 0., 5., 8., 0., 0., 9., 8., 0.],
[ 0., 4., 11., 0., 1., 12., 7., 0.],
[ 0., 2., 14., 5., 10., 12., 0., 0.],
[ 0., 0., 6., 13., 10., 0., 0., 0.]])
array([[ 0., 0., 0., 12., 13., 5., 0., 0.],
[ 0., 0., 0., 11., 16., 9., 0., 0.],
[ 0., 0., 3., 15., 16., 6., 0., 0.],
[ 0., 7., 15., 16., 16., 2., 0., 0.],
[ 0., 0., 1., 16., 16., 3., 0., 0.],
[ 0., 0., 1., 16., 16., 6., 0., 0.],
[ 0., 0., 1., 16., 16., 6., 0., 0.],
[ 0., 0., 0., 11., 16., 10., 0., 0.]])
from sklearn.datasets import load_digits
digits = load_digits(n_class=6)
X, y = digits.data, digits.target
n_samples, n_features = X.shape
n_neighbors = 30
import matplotlib.pyplot as plt
fig, axs = plt.subplots(nrows=10, ncols=10, figsize=(8, 8))
for idx, ax in enumerate(axs.ravel()):
ax.imshow(X[idx].reshape((8, 8)), cmap=plt.cm.binary)
ax.axis("off")
_ = fig.suptitle("A selection from the 64-dimensional digits dataset", fontsize=16)


Slides based on material from Prof. Luis Gustavo Nonato
Given a \(d \times d\) matrix \(A\), a pair \((\lambda, u)\) that satisfies
\(A u = \lambda u\)
is called eigenvalue \(\lambda\) and corresponding eigenvector \(u\) of \(A\).



Any matrix, \(M = U \Sigma V^{*}\) — rotate, scale, rotate (Wikipedia)
Roweis, S. T. & Saul, L. K. (2000). Nonlinear dimensionality reduction by locally linear embedding. Science 290(5500).
Roweis, S. T. & Saul, L. K. (2000). Nonlinear dimensionality reduction by locally linear embedding. Science 290(5500).

Roweis, S. T. & Saul, L. K. (2000). Nonlinear dimensionality reduction by locally linear embedding. Science 290(5500), Fig. 3.
Deep dive into t-SNE
UMAP in detail
Interactive dimensionality reduction
Also: Topomap (topology-preserving layouts) and projection quality metrics
Required reading: Wattenberg, Viégas & Johnson, How to Use t-SNE Effectively (Distill, 2016)
Due Tue Oct 20: project proposal (4 pages)