01 / 29
AI for Materials Science  ·  Lecture 03 (Complete Beginner-to-Research Edition)

Unsupervised Learning for Molecular & Materials Discovery:
Dimensionality Reduction, Clustering & Catalyst Discovery

Zesheng Liu
Laboratory of Organic Electronics, Linköping University
Modules 03a–03c  |  AqSolDB (N = 9,482), LKB-P Phosphine Ligands (N = 348) & Science 2021 Case Study
Linköping University Laboratory of Organic Electronics

Lecture 03 roadmap: three progressive pillars

From visualizing high-dimensional chemical space to discovering real Pd(I) catalysts across Notebooks 03a–03c
PART 1 · MODULE 03a

Dimensionality Reduction

Linear PCA geometric intuition, why StandardScaler is mandatory, interpreting loadings chemically, 17D Applicability Domain checks, and nonlinear t-SNE manifolds on 2,048-bit Morgan fingerprints.

PART 2 · MODULE 03b

Clustering & Strict Splits

K-means Assign–Update loop from scratch, local optima & k-means++, Elbow & Silhouette, DBSCAN for non-convex shapes, Taylor–Butina sphere exclusion, and GroupKFold Cluster Splits.

PART 3 · MODULE 03c

Science 2021 Catalyst Case

Reproducing Hueffel et al. (Science 2021): finding new dinuclear Pd(I) catalysts from 348 phosphine ligands with only 4 known positives using 1,000-run Consensus K-means & dimer DFT descriptors.

Every method answers a concrete materials question: map chemical space (03a), group families & test extrapolation (03b), or find rare hits (03c).
Linköping University Laboratory of Organic Electronics

From Supervised to Unsupervised: learning from X alone

When experimental labels y are missing, expensive, or too scarce for regression/classification
LECTURE 02 · SUPERVISED

Input: (X, y) → Output: f(X) ≈ y

  • Requires hundreds to thousands of labeled experiments (e.g., 9,482 AqSolDB log S values).
  • Evaluated against ground-truth test labels (RMSE, R2, ROC-AUC).
  • Blind spot: cannot tell you if a new molecule lies far outside training chemistry without an explicit AD check.
LECTURE 03 · UNSUPERVISED

Input: X only → Output: Structure

  • Chemical-space mapping: compress 17–2,048 features into 2D maps (PCA, t-SNE) to spot trends & outliers.
  • Family discovery: partition libraries into structural families (K-means, DBSCAN, Taylor–Butina).
  • Honest validation: build GroupKFold cluster splits so homologs never leak across train/test.
  • Ultra-low-data discovery: find analogs around 3–5 known hits (Consensus Clustering).
Unsupervised learning reveals hidden structure in X—grouping similar molecules, flagging outliers, and guiding where to measure y next.
Linköping University Laboratory of Organic Electronics

Two philosophies of dimensionality reduction

Compressing high-dimensional molecular representations (17D descriptors or 2,048D fingerprints) into 2D
GLOBAL & LINEAR · PCA

Principal Component Analysis

  • Rotates axes onto orthogonal directions of maximum global variance.
  • Deterministic & fast: exact linear algebra (SVD); same result every run.
  • Transformable: pca.transform(X_new) projects new molecules onto the exact same map.
  • Interpretable: loadings tell you what each axis means chemically.
LOCAL & NONLINEAR · t-SNE / UMAP

Manifold & Neighbor Embedding

  • Preserves local pairwise similarities (who is whose nearest neighbor in high-D).
  • Breaks linear bottlenecks on sparse 2,048-bit Morgan fingerprints.
  • Caveat: stochastic, non-parametric (t-SNE has no .transform()), and global distances between islands are distorted!
Use PCA for continuous, collinear descriptors when you need interpretable axes; use t-SNE/UMAP for sparse fingerprints to reveal local chemical islands.
Linköping University Laboratory of Organic Electronics

PCA geometric intuition: rotating axes onto maximum variance

Redundant descriptors (MolWt vs. HeavyAtomCount) collapse onto a single principal axis (PC1)
PCA geometric intuition: rotating axes onto maximum variance
PCA finds orthogonal axes (PC1, PC2) that decorrelate collinear descriptors—capturing >97% of 2D information along a single size axis.
Linköping University Laboratory of Organic Electronics

Why StandardScaler is mandatory before PCA

Without standardization, MolWt (50–2,000 g/mol) has 104× larger variance than NumAromaticRings (0–10)
Why StandardScaler is mandatory before PCA
Always run StandardScaler() before PCA on mixed-unit descriptors—otherwise unit scale masquerades as physical importance.
Linköping University Laboratory of Organic Electronics

Explained variance on AqSolDB (17 descriptors)

How many independent degrees of freedom actually exist in our 17-descriptor table (N = 9,482)?
Explained variance on AqSolDB (17 descriptors)
Collinearity discovered in Lecture 01 means just 5 principal components capture >90% of all variance across 17 descriptors.
Linköping University Laboratory of Organic Electronics

Interpreting PCA loadings: chemical meaning of PC1 & PC2

Loadings pca.components_ reveal which physical descriptors drive each principal axis
Interpreting PCA loadings: chemical meaning of PC1 & PC2
Without ever seeing solubility labels, PCA discovers the two fundamental axes of molecular physics: Size (PC1) and Lipophilicity vs. Polarity (PC2).
Linköping University Laboratory of Organic Electronics

2D PCA chemical space map colored by solubility

PCA never saw Solubility, yet PC2 aligns with the Yalkowsky hydrophobicity axis (r = −0.49)
2D PCA chemical space map colored by solubility
Unsupervised PCA recovers chemically meaningful gradients—and flags extreme outliers at the edges of PC1/PC2 for data auditing.
Linköping University Laboratory of Organic Electronics

Projecting organic semiconductors & 17D Applicability Domain

2D PCA projection can hide out-of-plane distance—always verify nearest-neighbor distance in full 17D space!
Projecting organic semiconductors & 17D Applicability Domain
C8-BTBT (1.85) and rubrene (2.19) far exceed the 95th-percentile 17D distance (1.34), whereas pentacene (0.18) sits near dibenzanthracene isomers.
Linköping University Laboratory of Organic Electronics

Why linear PCA fails on 2,048-bit Morgan fingerprints

Sparse binary vectors are nearly orthogonal in 2,048D—50 PCs capture only ~30% of variance
Why linear PCA fails on 2,048-bit Morgan fingerprints
Linear hyperplanes cannot unfold sparse binary fingerprint spaces; nonlinear manifold methods (t-SNE / UMAP) are required.
Linköping University Laboratory of Organic Electronics

t-SNE: preserving local neighborhoods on a nonlinear manifold

Standard pipeline: PCA(50) denoising → TSNE(perplexity=30, init='pca')
t-SNE: preserving local neighborhoods on a nonlinear manifold
t-SNE converts the featureless PCA blob into distinct chemical islands grouped by functional scaffolds and local solubility regimes.
Linköping University Laboratory of Organic Electronics

Inside a t-SNE island: similarity meets Activity Cliffs

Structurally similar neighbors in fingerprint space can still exhibit sharp jumps in solubility (log S)
Inside a t-SNE island: similarity meets Activity Cliffs
Local islands reveal both smooth homologous series and 'Activity Cliffs' where minor substitutions (or long alkyl chains) drastically alter properties.
Linköping University Laboratory of Organic Electronics

Four rules for reading t-SNE plots (plus UMAP & TMAP)

Avoiding the most common misinterpretations of nonlinear 2D chemical-space embeddings
RULE 1

Cluster size ≠ chemical diversity

t-SNE expands dense regions and compresses sparse ones—a huge island on screen does not mean wider chemical variance.

RULE 2

Distances between islands are meaningless

Two islands on opposite sides of the plot are not necessarily less similar than two adjacent islands.

RULE 3

perplexity sets the zoom level

Low perplexity (5–10) fragments data into tiny micro-clusters; moderate (30–50) balances local neighborhoods.

RULE 4

Use init="pca" + fixed random_state

Random initialization varies across runs; UMAP is faster and supports .transform() for new molecules.

Treat t-SNE as a local magnifying glass, not a metric map—never measure inter-island distances or cluster sizes literally.
Linköping University Laboratory of Organic Electronics

K-means from scratch: the 2-step Assign–Update loop

Alternating between assigning points to nearest centroids and recomputing cluster means until convergence
K-means from scratch: the 2-step Assign–Update loop
K-means minimizes within-cluster squared distance (Inertia) via a simple 2-step EM-style loop—requiring only 10 lines of NumPy.
Linköping University Laboratory of Organic Electronics

Local optima trap & why k-means++ + n_init=10 matter

A poor random starting position traps K-means in a suboptimal partition with higher Inertia
Local optima trap & why <code>k-means++</code> + <code>n_init=10</code> matter
Never trust a single random initialization—always use init='k-means++' and n_init=10 (or higher) to escape local minima.
Linköping University Laboratory of Organic Electronics

Choosing the number of clusters k: Elbow vs. Silhouette

Inertia always decreases as k grows; Silhouette Score balances intra-cluster cohesion against inter-cluster separation
Choosing the number of clusters <i>k</i>: Elbow vs. Silhouette
Combine the Inertia Elbow with the Silhouette Score peak (range −1 to +1) to select k—and expect softer curves on real molecules.
Linköping University Laboratory of Organic Electronics

When K-means fails: non-convex shapes & DBSCAN

K-means assumes spherical, equal-variance Voronoi cells; DBSCAN traces arbitrary density-connected manifolds
When K-means fails: non-convex shapes & DBSCAN
DBSCAN requires no k in advance and naturally isolates outlier molecules as Noise (-1), though it is sensitive to eps.
Linköping University Laboratory of Organic Electronics

High-D fingerprint distances & Hierarchical Clustering

Most random molecule pairs have Tanimoto distance > 0.80; Ward linkage builds a multi-scale family tree
High-D fingerprint distances & Hierarchical Clustering
In 2,048D fingerprint space, Euclidean K-means struggles—chemoinformatics relies on Tanimoto distance and hierarchical/sphere-exclusion trees.
Linköping University Laboratory of Organic Electronics

Cheminformatics standard: Taylor–Butina clustering

Greedy sphere-exclusion algorithm on Tanimoto distances—no need to guess k beforehand
1
Compute pairwise Tanimoto distances
Lower-triangular distance vector d = 1 - TanimotoSim across all molecule pairs.
2
Count neighbors within cutoff (e.g., 0.35)
Rank molecules from highest neighbor count (densest core) to lowest; pick top molecule as cluster centroid.
3
Claim sphere & remove from pool
Assign all unclaimed neighbors within cutoff to that centroid, then repeat until only singletons remain.
WHY CHEMISTS LOVE BUTINA

Key Practical Advantages

  • Guaranteed similarity radius: every molecule in a cluster is ≥ (1 − cutoff) similar to the cluster representative.
  • No forced merging: unique scaffolds stay as singletons rather than corrupting other families.
  • Representative picking: selecting 1 molecule per Butina cluster yields a maximally diverse screening subset.
Taylor–Butina guarantees every cluster member is within a chosen Tanimoto cutoff of its centroid—ideal for diverse library selection.
Linköping University Laboratory of Organic Electronics

Strict validation: Cluster Split (GroupKFold) vs. Random CV

Holding out entire structural families prevents homologous analogs from leaking between train and test
Strict validation: Cluster Split (<code>GroupKFold</code>) vs. Random CV
Random Forest RMSE worsens from ~1.14 (Random 5-Fold) to ~1.27 (Cluster GroupKFold)—exposing the true cost of cross-family extrapolation.
Linköping University Laboratory of Organic Electronics

Case study: discovering dinuclear Pd(I) catalysts (Science 2021)

Hueffel et al., Science 374, 1134 (2021) — when both DFT thermodynamics and supervised ML fail
THE DOUBLE BOTTLENECK

Why Standard Tools Failed

  • DFT failure: computing ΔG of dimerization fails to separate active dimers from inactive monomers/species.
  • Supervised ML failure: only 4 known positives exist among 348 phosphine ligands in the LKB-P database—impossible to train a classifier!
  • Data gotcha: LKB_P.csv uses semicolon delimiters (sep=";").
THE UNSUPERVISED STRATEGY

Guilt-by-Association in DFT Space

  • Represent all 348 ligands by 28 quantum-chemical DFT descriptors (sterics, electronics, Tolman angle, HOMO/LUMO).
  • Find which ligands consistently co-cluster with the 4 known Pd(I)-forming ligands across 1,000 clustering runs.
  • Refine the shortlist with 36 dimer-specific DFT descriptors before stepping into the wet lab.
With only 4 known positive ligands out of 348 in LKB-P, supervised classification collapses—unsupervised similarity search is the only way forward.
Linköping University Laboratory of Organic Electronics

Why 2D PCA on 28 DFT descriptors is not enough

The 4 known Pd(I) dimer ligands (IDs 16, 94, 152, 232) look scattered in a 2D projection
Why 2D PCA on 28 DFT descriptors is not enough
2D PCA discards >40% of the 28D quantum-chemical variance—cluster proximity must be measured in full 28D space.
Linköping University Laboratory of Organic Electronics

Round 1: 1,000-run Consensus K-means in 28D LKB-P space

Turning K-means initialization randomness into a probabilistic co-clustering score
Round 1: 1,000-run Consensus K-means in 28D LKB-P space
Any single K-means run fluctuates wildly; averaging 1,000 random runs yields a stable consensus score that narrows 348 ligands to ~66 candidates.
Linköping University Laboratory of Organic Electronics

Round 2: 36D Dimer-DFT descriptors → 21 finalists → 8 new catalysts

Computing dimer-specific DFT descriptors for the 66 Round-1 candidates and re-running 1,000-run consensus clustering
Round 2: 36D Dimer-DFT descriptors → 21 finalists → 8 new catalysts
Round 2 converges to 21 finalists; 8 of 10 experimentally synthesized ligands formed active Pd(I) dimers—an 80% wet-lab hit rate!
Linköping University Laboratory of Organic Electronics

Four materials informatics lessons from the Science case study

Why thoughtful domain engineering beats blind black-box modeling in real laboratory discovery
LESSON 1 · DOMAIN DESCRIPTORS

Monomer → Dimer DFT Funnel

Cheap monomer descriptors (LKB-P, N = 348) filtered the library first; expensive dimer-specific DFT descriptors (N = 66) resolved the true catalytic physics.

LESSON 2 · ENSEMBLE STABILITY

Consensus Over Single-Run Luck

Running K-means 1,000 times converted stochastic cluster boundaries into a continuous, reproducible ranking score.

LESSON 3 · EXTREME SMALL DATA

4 Positives Is Enough to Start

You do not need 1,000 labeled rows to apply ML—unsupervised neighborhood discovery works with just 3–5 known hits.

LESSON 4 · WET-LAB VALIDATION

Human-in-the-Loop Synthesis

Chemist intuition filtered 21 finalists down to 10 synthesizable ligands, achieving 8 experimentally confirmed Pd(I) dimer catalysts.

Unsupervised ML shines brightest when paired with physics-informed descriptors, stability checks, and experimental feedback.
Linköping University Laboratory of Organic Electronics

Practical cheat-sheet: which unsupervised method should I choose?

Matching representation type, scaling needs, and scientific goal across all Lecture 03 algorithms
Method Input Type StandardScaler? Needs k? Best Materials Science Use Case
PCA Continuous descriptors Mandatory! No (choose % var) Remove collinearity, interpret chemical axes (loadings), project new molecules
t-SNE / UMAP Morgan FP (via PCA 50) No (binary FP) No (perplexity) Visualize local chemical islands & Activity Cliffs in large libraries
K-means Continuous / PCA-FP Mandatory! Yes (Elbow/Silh.) Fast spherical partitioning; GroupKFold cluster splits on PCA-reduced FPs
DBSCAN Low-D continuous Mandatory! No (eps, min_samples) Non-convex manifolds & automatic outlier / noise flagging (label -1)
Taylor–Butina Tanimoto distance (FP) No No (cutoff) Cheminformatics family clustering & diverse library subset selection
Consensus K-means DFT descriptors Mandatory! Yes (1,000× runs) Target-focused analog discovery from 3–5 known hits (Science 2021 Pd(I) case)
Match the algorithm to the geometry of your features: continuous descriptors (PCA/K-means) vs. sparse fingerprints (t-SNE/Taylor–Butina).
Linköping University Laboratory of Organic Electronics

Summary (Take home notes)

  • Standardize before linear/distance methods: PCA, K-means, and DBSCAN are unit-sensitive—always apply StandardScaler on mixed-unit descriptors.
  • Read PCA loadings & check full-D AD: On AqSolDB, 5 PCs capture >90% variance and PC2 recovers hydrophobicity without labels, while 17D nearest-neighbor distance catches out-of-domain semiconductors.
  • Use t-SNE for local islands, never global distances: Linear PCA fails on sparse 2,048-bit Morgan fingerprints; PCA(50) → t-SNE reveals chemical islands and Activity Cliffs.
  • Validate out-of-family with Cluster Splits: Taylor–Butina and K-means + GroupKFold prevent homologous leakage and reveal true cross-family generalization error.
  • Up next (Lecture 04): Moving from passive exploration to active experimental design—using Gaussian Processes and Bayesian Optimization to choose the next best experiment.
Linköping University Laboratory of Organic Electronics

Thanks for your listening

Zesheng Liu  ·  zesheng.liu@liu.se
AI for Materials Science  ·  Lecture 03  |  Next: Hands-on Practice in 03d_exercises.ipynb
Linköping University Laboratory of Organic Electronics