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

Supervised Learning for Molecular & Materials Discovery:
Intuition, Algorithms, Physical Priors & Validation Pitfalls

Zesheng Liu
Laboratory of Organic Electronics, Linköping University
Modules 020 & 02a–02e  |  Step-by-Step Foundations + AqSolDB (N = 9,480) & Organic Semiconductors
Linköping University Laboratory of Organic Electronics

Lecture 02 roadmap: six progressive building blocks

From zero machine learning background to leak-free laboratory deployment across Notebooks 020 and 02a–02e
PART 1 · MODULE 020

Panorama & Mindset

What are AI, ML & DL? How do SMILES strings become matrices X and targets y? Why is materials data fundamentally different from internet big data?

PART 2 · MODULE 02a

Linear Models & Regularization

Train/test split, 3-line scikit-learn API, Ordinary Least Squares, Gradient Descent, polynomial overfitting, and Ridge (L2) vs. Lasso (L1).

PART 3 · MODULE 02b

Distance & Margin Models

k-Nearest Neighbors (chemical analogy), why unscaled features ruin Euclidean distance, Support Vector Machines, RBF kernels, and ε-tubes.

PART 4 · MODULE 02c

Decision Trees & Ensembles

CART “20 questions” splits, Bagging (Random Forest) vs. Boosting (XGBoost), descriptors vs. fingerprints, and the Acene extrapolation trap.

PART 5 · MODULE 02d

Classification & Attribution

Perceptron to Sigmoid probabilities, escaping the Accuracy trap, ROC-AUC, lab-cost thresholds, C8-BTBT solvent priors & Yalkowsky’s equation.

PART 6 · MODULE 02e

Validation & Applicability Domain

5-Fold Cross-Validation, Pipeline against data leakage, Learning Curves, Murcko Scaffold Splits, and Tanimoto Applicability Domain checks.

Every algorithm is unpacked twice: first through geometric intuition (no black boxes), then on real molecular data.
Linköping University Laboratory of Organic Electronics

Why materials science needs machine learning

Combinatorial explosion in organic semiconductors: D–π–A backbones × side chains × film processing conditions
Why materials science needs machine learning
Machine learning acts as the 4th scientific paradigm—filtering 105–107 candidates 104–106× faster before DFT or synthesis.
Linköping University Laboratory of Organic Electronics

What is machine learning? AI ⊃ ML ⊃ DL and the core paradigm flip

Replacing hand-coded physical equations with statistical mappings learned directly from experimental examples
Artificial Intelligence (AI) — Includes hand-written if-else expert rules Machine Learning (ML) — Learns patterns from data (Linear, kNN, RF, XGB) Deep Learning (DL) Multi-layer Neural Nets (CNN, GNN, Transformer)
Traditional / DFT:  Input X + Known Equation f  →  Compute Output y
Machine Learning:  Input X + Measured Labels y  →  Learn Mapping f̂(X)
ML ParadigmData NeededTypical Materials QuestionCourse
1. SupervisedLabeled (X, y)Predict solubility logS, bandgap Eg, or soluble vs. insolubleMod 02
2. UnsupervisedX only (no y)Map chemical space (PCA/t-SNE), cluster ligands & catalystsMod 03
3. Active / BOSmall (X, y)Pick the next best experiment under tight budget (GPR + EI)Mod 04
4. GenerativeStructures XInverse-design new molecules or super-resolve SEM imagesMod 08–09
5. End-to-End DLGraphs / 3DLearn directly from molecular graphs or crystal unit cellsMod 07, 10
Choose classical ML (Module 02) first on tabular datasets (N = 10²–10⁴); deep learning is neither required nor optimal for small tables.
Linköping University Laboratory of Organic Electronics

How molecules become numbers: from SMILES to (X, y)

Algorithms cannot multiply text strings—RDKit translates chemical graphs into numerical feature matrix X and target vector y
1. Molecular Structure SMILES: "c1ccc2ccccc2c1" (Naphthalene text string) RDKit 2. Feature Matrix X (Shape: 9,480 rows × 17 columns) 17 Physicochemical Descriptors (MolWt, MolLogP, TPSA, H-donors, Rings…) Alternative: 2048-dim Morgan Fingerprint (local atomic fragments) f̂(X) 3. Target Vector y (9,480,) Regression: logS = −3.61 (continuous) Classification: Soluble (0) / Insoluble (1)
MoleculeSMILESMolWt (x1)MolLogP (x2)TPSA Ų (x3)Arom. Rings (x4)Target y: logSScreening Class
EthanolCCO46.07−0.0020.230+1.100 (Soluble)
Benzenec1ccccc178.11+1.690.001−1.640 (Soluble)
Naphthalenec1ccc2ccccc2c1128.17+2.840.002−3.610 (Borderline)
Anthracenec1ccc2cc3ccccc3cc2c1178.23+3.990.003−6.441 (Insoluble < −4)
Each row of X is one molecule; each column is a quantitative descriptor; y is the measured property we train the model to predict.
Linköping University Laboratory of Organic Electronics

Reading a Parity Plot: three progressive leaps on AqSolDB

Every circle is an unseen test molecule (N = 1,896); falling exactly on the dashed diagonal y = x means zero prediction error
Reading a Parity Plot: three progressive leaps on AqSolDB
Adding richer physicochemical descriptors (1 → 17) and nonlinear interactions (OLS → RF) compresses molar solubility error from ~77× to ~15×.
Linköping University Laboratory of Organic Electronics

Materials data ≠ internet AI: interpolation vs. extrapolation

Conjugated oligomer bandgap Eg(N) = 1.65 + 4.20 / N eV: trained only on short oligomers (N ≤ 6), tested on polymers (N > 6)
Materials data ≠ internet AI: interpolation vs. extrapolation
Purely statistical curves diverge (polynomial) or flatline (trees) outside training bounds; encoding physical scaling 1/N enables true extrapolation.
Linköping University Laboratory of Organic Electronics

Standard 6-step materials ML workflow and thesis route selector

A reproducible checklist for every research project—from raw experimental spreadsheets to wet-lab validation
1. Define Problem Fix target y, solvent & temperature priors 2. Clean & Featurize Deduplicate SMILES; descriptors / FPs 3. Leak-Free Split Random, Stratified, or Murcko Scaffold split 4. Baseline & Metrics Beat Dummy mean; RMSE / R² / ROC-AUC 5. Model Ladder Linear → kNN/SVR → RF/XGB inside Pipeline 6. AD & Lab Test Check similarity bounds & physical attribution
SMALL DATA · N = 20 – 100

Active Learning Regime

Avoid deep neural nets! Use 5–12 physical descriptors + Ridge / Gaussian Process (GPR) + Bayesian Optimization (Module 04) to guide experiments.

MEDIUM DATA · N = 100 – 10,000

Classical Tabular Sweet Spot

Random Forest, XGBoost, and Scaled RBF-SVR on domain descriptors + Count Fingerprints (Module 02) typically outperform deep learning.

LARGE DATA · N > 10,000 – 10⁶

Representation Learning

End-to-end Graph Neural Networks (Chemprop, CGCNN, MACE) & Transformers (Modules 07–10) learn features directly from atoms and bonds.

Match model complexity to dataset size N: on typical experimental tables (N < 10⁴), well-validated classical ML is the gold standard.
Linköping University Laboratory of Organic Electronics

Train/test split, regression metrics, and logarithmic error scale

80% Training set (homework examples, N = 7,584) vs. 20% Locked Test set (unseen final exam, N = 1,896)
Train/test split, regression metrics, and logarithmic error scale
Because logS is base-10, RMSE = 1.0 means a 10× molar concentration error; every model must beat the Dummy Mean (RMSE = 2.42).
Linköping University Laboratory of Organic Electronics

Zero-barrier Python: the universal 3-line scikit-learn workflow

Every supervised algorithm in Python—from linear regression to Random Forest—shares the exact same three-step interface
1
model = LinearRegression()
Instantiate: Create an blank model object and choose its hyperparameters (knobs).
2
model.fit(X_train, y_train)
Learn from Training Set ONLY: Adjust internal weights/trees to minimize error on (X_train, y_train).
3
y_pred = model.predict(X_test)
Closed-Book Exam: Freeze the model, feed X_test (without y_test!), and compare y_pred vs. y_test.
Algorithm FamilySwap Line 1 Only!Section
Ordinary Least SquaresLinearRegression()02a
L2 / L1 RegularizedRidge(alpha=50) / Lasso(0.05)02a
k-Nearest NeighborsKNeighborsRegressor(n_neighbors=5)02b
Support Vector Reg.SVR(kernel="rbf", C=5.0)02b
Random ForestRandomForestRegressor(150)02c
Gradient BoostingXGBRegressor(n_estimators=300)02c
Binary ClassifierLogisticRegression()02d
Once you understand fit(X_train, y_train) and predict(X_test), you can run dozens of ML algorithms by changing a single line.
Linköping University Laboratory of Organic Electronics

How linear regression learns: least squares & gradient descent

Hypothesis: ŷ = w·MolLogP + b  ·  Minimize squared vertical residuals L(w, b) = (1/n) Σ (w xi + b − yi)2
How linear regression learns: least squares & gradient descent
Squaring vertical residuals creates a smooth convex bowl; stepping opposite the gradient (−∇L) reaches the exact analytical minimum.
Linköping University Laboratory of Organic Electronics

Fitting curves with linear models: polynomial features & overfitting

Expanding [x, x2, …, xd] on N = 40 molecules: linear in weights wk, nonlinear in descriptor x
Fitting curves with linear models: polynomial features & overfitting
Underfitting (d = 1, high bias) misses curved trends; overfitting (d = 9, high variance) memorizes random lab noise and fails on new data.
Linköping University Laboratory of Organic Electronics

Multivariate linear regression and the multicollinearity trap

Combining all 17 standardized RDKit descriptors  ·  Test RMSE drops from 1.89 → 1.64 (R2 = 0.54)
Multivariate linear regression and the multicollinearity trap
When two descriptors measure the same molecular size (r = 0.99), OLS assigns huge opposing weights (−6.3 vs. +4.7) that lose physical meaning.
Linköping University Laboratory of Organic Electronics

Regularization intuition: putting a budget on runaway weights

Adding a weight penalty α·Penalty(w) to MSE stops collinear coefficients from exploding against each other
Ridge (L₂): w₁² + w₂² ≤ t w₁w₂ Smooth circle → both w₁, w₂ small ≠ 0 Lasso (L₁): |w₁| + |w₂| ≤ t w₁w₂ Sharp corner on axis → w₁ = 0 (sparse!)
RIDGE REGRESSION (L₂ PENALTY)

Loss = MSE + α Σ wj2

Squares large weights heavily: (−6)² + (+5)² = 61 is crushed into (−0.5)² + (−0.5)² = 0.50! Correlated features share small, stable weights; none become exact zero.

LASSO REGRESSION (L₁ PENALTY)

Loss = MSE + α Σ |wj|

Diamond constraint has sharp corners sitting directly on coordinate axes—MSE contours hit corners first, driving redundant descriptors to exact 0 (automatic feature selection).

Use Ridge (L2) as your default stable linear baseline; use Lasso (L1) when you want a compact subset of key descriptors.
Linköping University Laboratory of Organic Electronics

Ridge (L2) and Lasso (L1) regularization paths on AqSolDB

Tracking all 17 standardized descriptor weights as penalty strength α increases across orders of magnitude
Ridge (L2) and Lasso (L1) regularization paths on AqSolDB
At α = 50, Ridge collapses opposing size weights into stable negative values; at α = 0.05, Lasso zeros out 11 redundant features, leaving MolLogP.
Linköping University Laboratory of Organic Electronics

k-Nearest Neighbors (kNN): learning by chemical analogy

Zero global equations—predict an unknown molecule by averaging the k most similar molecules in your database
STEP 1 · MEMORIZE LIBRARY

No Formula Fitted in .fit()

Unlike linear regression, kNN fits zero weights during training—it simply stores all known molecules (X_train, y_train) as coordinates in p-dimensional feature space.

STEP 2 · MEASURE DISTANCE

Euclidean Distance d(x, xi)

For a query molecule x, compute straight-line distance across all p features:
d = √[ Σj=1..p (xj − xij)² ]
Pick the k closest training neighbors.

STEP 3 · LOCAL CONSENSUS

Average or Distance-Weight

Uniform: ŷ = (1/k) Σ yi.
Distance-weighted: closer analogs get higher weight wi = 1/di.
k = 1 overfits noise; k = 100 oversmooths.

⚠️ Critical Beginner Question: What happens inside √[ (ΔMolLogP)² + (ΔBertzCT)² ] when MolLogP spans −5 to +7, while complexity index BertzCT spans 0 to 4,000?  →  A 1% change in BertzCT completely drowns out hydrophobicity!
kNN directly mirrors how chemists reason by structural analogy—provided all descriptor axes share a fair numerical scale.
Linköping University Laboratory of Organic Electronics

Why feature scaling is mandatory: rescuing Naphthalene’s neighbors

Standardizing each column zj = (xj − μtrain) / σtrain strictly using training-set mean & standard deviation
Why feature scaling is mandatory: rescuing Naphthalene’s neighbors
Training-only StandardScaler rescues neighbor chemistry (Pred −0.74 → −2.99) and slashes 17D kNN Test RMSE from 1.56 to 1.19.
Linköping University Laboratory of Organic Electronics

Support Vector Machines (SVM): widest street, RBF kernel & ε-tube

Three geometric ideas that turn linear boundaries into smooth, noise-tolerant nonlinear predictors
1 · MAXIMUM MARGIN & C

The Widest Separating Street

Among infinitely many lines separating two classes, SVM picks the centerline with the widest safety margin—anchored solely by boundary molecules called Support Vectors. Knob C balances margin width vs. margin violations.

2 · RBF KERNEL TRICK

Lifting 2D Rings into 3D

When classes form concentric rings inseparable by any straight line, the Radial Basis Function kernel K(x, x′) = exp(−γ‖x−x′‖²) measures Gaussian similarity—implicitly slicing a 3D hill into smooth nonlinear contours in 2D!

3 · SVR ε-INSENSITIVE TUBE

Ignoring Lab Noise ≤ ε

Wet-lab logS measurements naturally fluctuate by ±0.2 units. Support Vector Regression wraps a tolerance tube of half-width ε around the curve: points inside incur zero loss, preventing overfitting to titration noise.

Hyperparameter Intuition for RBF-SVR:  •  Mandatory: Apply StandardScaler first (RBF depends on ‖x−x′‖²)!  •  Too large γ shrinks Gaussian width into tiny “overfitting islands” around individual molecules; balanced C = 5, gamma = "scale" yields smooth generalization.
SVM/SVR excels on medium-sized tabular descriptors (N < 104), combining smooth kernel nonlinearity with explicit noise tolerance.
Linköping University Laboratory of Organic Electronics

Visualizing SVM margins, RBF boundaries, and SVR solubility contours

From linear support vectors (a) and concentric RBF separation (b) to 2D/17D AqSolDB regression (c)
Visualizing SVM margins, RBF boundaries, and SVR solubility contours
Scaled 17-descriptor RBF-SVR reaches Test RMSE = 1.23 (R2 = 0.74), outperforming linear models by over 0.40 logS units.
Linköping University Laboratory of Organic Electronics

How a decision tree thinks: playing “20 questions” with molecules

CART greedily picks the descriptor j and threshold t that minimize weighted variance inside left & right child subsets
Root Split: MolLogP ≤ 2.75 ? (7,584 training molecules) Yes (Hydrophilic) No (Hydrophobic) MolLogP ≤ 0.85 ? MolLogP ≤ 4.55 ? Leaf 1 Mean ŷ = −0.78 Leaf 2 Mean ŷ = −2.46 Leaf 3 Mean ŷ = −4.42 Leaf 4 Mean ŷ = −6.85
WHY NO FEATURE SCALING?

Rank-Order Invariance

Asking MolWt ≤ 250 splits the exact same molecules left and right as asking MolWt_scaled ≤ +0.12! Decision trees, Random Forests, and XGBoost never need StandardScaler.

CRUCIAL STRUCTURAL PROPERTY

Leaf Output = Training Average

Every terminal leaf simply outputs the average y of training molecules inside that box—making a tree a piecewise-constant step function bounded by [y_min, y_max].

Out of all 17 descriptors, a 12-line NumPy search automatically discovers MolLogP ≤ 2.75 as the single most informative root split.
Linköping University Laboratory of Organic Electronics

Piecewise-constant steps and single-tree variance overfitting

Comparing shallow max_depth=2 steps vs. an unpruned tree that isolates single noisy molecules per leaf
Piecewise-constant steps and single-tree variance overfitting
An unlimited single tree memorizes the training set (RMSE = 0.06) while rebounding badly on unseen molecules (Test RMSE = 1.53).
Linköping University Laboratory of Organic Electronics

Wisdom of crowds: Bagging (Random Forest) vs. Boosting (XGBoost)

Two complementary strategies for combining hundreds of weak/noisy trees into a powerhouse tabular predictor
PARALLEL DEMOCRACY · REDUCES VARIANCE

Random Forest (Bagging)

  • Bootstrap rows + random features: Train 150 deep, independent trees in parallel, each seeing a slightly different random sample of molecules and descriptors.
  • Average out noise: Individual deep trees overfit in different random directions; averaging all 150 trees cancels variance:
    ŷ = (1 / B) Σb=1..B Treeb(x)
  • Strength: Extremely hard to overfit by adding more trees; works great out-of-the-box with minimal tuning.
SEQUENTIAL RELAY · REDUCES BIAS

XGBoost (Gradient Boosting)

  • Learn from prior mistakes: Train shallow trees (max_depth = 4–6) one after another in series.
  • Fit residuals: Tree t does NOT predict y—it predicts the remaining error r(t−1) = y − ŷ(t−1), nudged by learning rate η:
    ŷ(T) = Σt=1..T η · Treet(x)
  • Strength: Highest tabular accuracy, but aggressive learning_rate or excessive depth can overfit noise.
Analogy: Random Forest averages 150 independent committee members; XGBoost passes an exam draft through a chain of specialist editors.
Linköping University Laboratory of Organic Electronics

Boosting residual stages and ensemble convergence on AqSolDB

Progressive residual correction (a) and Test RMSE vs. ensemble size on 17 descriptors (b)
Boosting residual stages and ensemble convergence on AqSolDB
Both Random Forest (1.17) and XGBoost (1.15, R2 = 0.77) slash single-tree error (1.53) by nearly 0.40 logS units.
Linköping University Laboratory of Organic Electronics

Molecular representations: global descriptors vs. local fingerprints

Comparing 2048-bit Morgan FP, 2048-count Morgan FP, 17 RDKit descriptors, and hybrid 2065D concatenation
Molecular representations: global descriptors vs. local fingerprints
Count FP (1.27) beats binary Bit FP (1.43) by preserving repeat-ring count; combining 17 global descriptors + Count FP hits 1.11!
Linköping University Laboratory of Organic Electronics

Organic semiconductor stress test: why tree ensembles cannot extrapolate

Predicting aqueous solubility across Benzene (N = 1) → Tetracene (N = 4, in AqSolDB) → Pentacene (N = 5, unseen)
Organic semiconductor stress test: why tree ensembles cannot extrapolate
Because every leaf outputs an average of bounded training molecules, Random Forest and XGBoost flatline at ~ −8.2 on unseen Pentacene.
Linköping University Laboratory of Organic Electronics

Binary classification: from Perceptron to Logistic Regression

High-throughput screening goal: flag insoluble candidates (logS < −4.0 → Positive y = 1, 28.6% prevalence, stratified split)
Binary classification: from Perceptron to Logistic Regression
Passing linear score z = wTx + b through Sigmoid σ(z) = 1/(1+e−z) yields calibrated probabilities predict_proba.
Linköping University Laboratory of Organic Electronics

Classification metrics for beginners: escaping the Accuracy trap

When 71.5% of molecules are soluble, blindly guessing “all soluble” gets 71.5% Accuracy while catching 0% of bad candidates!
2×2 Confusion MatrixPredicted Soluble (0)Predicted Insoluble (1)
Truly Soluble (0)
(Good candidate)
TN (True Negative)
Correctly passed to lab
FP (False Alarm)
Viable molecule discarded
Truly Insoluble (1)
(“Brick dust”)
FN (Missed Trap!)
Wastes 2 wks synthesis!
TP (True Positive)
Successfully intercepted
Precision = TP / (TP + FP): “When the alarm rings, how often is the molecule truly insoluble?” (High Precision = few false alarms).
Recall = TP / (TP + FN): “Out of all truly insoluble molecules, what fraction did we catch?” (High Recall = few costly synthesis failures!).
F1 = 2·(Prec·Rec)/(Prec+Rec): Harmonic mean balancing both; ROC-AUC (0.5 → 1.0): threshold-independent ranking score.
Always match your metric to laboratory cost: when synthesis is expensive, missing an insoluble molecule (FN) hurts far more than a false alarm (FP).
Linköping University Laboratory of Organic Electronics

Confusion matrix, ROC curves, and decision threshold tuning

Comparing Logistic Regression (AUC = 0.892), Random Forest (0.952), and XGBoost (0.956) on 1,896 test molecules
Confusion matrix, ROC curves, and decision threshold tuning
Without retraining the model, lowering alarm threshold τ from 0.50 to 0.25 boosts insoluble Recall above 93% to protect synthesis.
Linköping University Laboratory of Organic Electronics

Opening the black box: solvent priors & Yalkowsky’s solubility equation

General Solubility Equation: logSwater ≈ 0.5 − 0.01(Tm − 25 °C) − logP  ·  Screening BTBT vs. C8-BTBT
Opening the black box: solvent priors & Yalkowsky’s solubility equation
C8-BTBT dissolves well in chlorobenzene yet scores insoluble in water (MolLogP = 11.1)—models strictly obey training solvent priors!
Linköping University Laboratory of Organic Electronics

Leak-free validation architecture: 5-Fold CV and sklearn.Pipeline

Eliminating single-split luck while strictly preventing validation folds from contaminating preprocessing
80% Training Set (Rotate Validation 5×) 20% Vault Val 1 Train Folds 2–5 Val 2 Train Folds 3–5 Val 3 Val 4 Train Folds 1–4 Val 5 Locked X_test (Touch ONCE at the very end!)
❌ COMMON DESK-REJECT MISTAKE (LEAKAGE)

X_s = SelectKBest().fit_transform(X_train, y_train)
cross_val_score(Ridge(), X_s, y_train, cv=5)
Validation fold labels already leaked into feature selection before CV even started!

✅ GOLD-STANDARD PIPELINE HYGIENE

pipe = make_pipeline(StandardScaler(), SVR())
cross_val_score(pipe, X_train, y_train, cv=5)
Automatically fits scaler/selector inside the 4 blue folds only during every round!

Rule of thumb: any step with a .fit() method (scaling, imputation, PCA, feature selection) belongs inside a Pipeline.
Linköping University Laboratory of Organic Electronics

Quantifying split variance and catching leakage on pure random noise

5-Fold CV stability on AqSolDB (a)  ·  Synthetic pure-noise audit with N = 80 samples and p = 2,000 random columns (b)
Quantifying split variance and catching leakage on pure random noise
Pre-CV feature selection fabricates a fake R2 = +0.35 out of pure Gaussian noise; Pipeline honestly reports R2 = −0.77.
Linköping University Laboratory of Organic Electronics

Hyperparameter tuning (GridSearchCV) and learning curves

Parameters (learned inside .fit) vs. Hyperparameters (tuned via 5-Fold CV on X_train)  ·  Scaling with dataset size N
Hyperparameter tuning (GridSearchCV) and learning curves
Learning curves diagnose bottlenecks: Ridge saturates at N ≈ 400 (high bias—change model!), whereas Random Forest keeps improving with more data.
Linköping University Laboratory of Organic Electronics

Realistic generalization: Bemis–Murcko scaffold and ring-size splits

Grouping molecules by core ring skeleton so ortho/meta/para derivatives never leak across train and test sets
Realistic generalization: Bemis–Murcko scaffold and ring-size splits
Global physical descriptors generalize to unseen scaffolds far better than bit fingerprints (+0.02 vs. +0.29 RMSE), though size extrapolation still clips.
Linköping University Laboratory of Organic Electronics

Applicability domain (AD): knowing when NOT to trust your model

Dual confidence check before wet-lab synthesis: Tanimoto structural similarity + training descriptor percentile bounds
Applicability domain (AD): knowing when NOT to trust your model
Error jumps sharply below Tanimoto 0.35; Count-FP similarity fixes Pentacene’s false 1.00 Bit-FP score and flags extreme-LogP semiconductors.
Linköping University Laboratory of Organic Electronics

How good is good enough? Benchmarking against experimental noise

Every model from 02a–02c against the label noise floor measured in Lecture 01 (a), and the same Random Forest re-scored by how much the sources agreed (b)
Test RMSE of every Lecture 02 model compared with the experimental noise floor of 0.52 log units Random Forest out-of-fold RMSE stratified by how much the independent sources disagreed about each label
Quote RMSE against a floor, never alone: we are still 2× above it (keep improving!), yet the identical forest scores 0.81 where sources agree and 1.48 where they conflict—so part of “model error” was never the model’s.
Linköping University Laboratory of Organic Electronics

Practical cheat-sheet: which supervised model should I choose?

Comparing all classical supervised algorithms covered in Lecture 02 across scaling, sample size, interpretability, and extrapolation
Algorithm StandardScaler? AqSolDB RMSE Extrapolates Trend? Best Materials Science Use Case
OLS / Ridge (L2) Yes (for Ridge) 1.64 – 1.65 Yes (linear/physics) Fast mandatory baseline; physical scaling laws (e.g., 1/N oligomer bandgap)
Lasso (L1) Yes (mandatory) 1.67 Yes (linear) Automatic feature selection when pruning dozens of collinear descriptors
kNN Mandatory! 1.19 – 1.24 No (local average) Intuitive chemical-analogy lookup; inspect actual nearest database molecules
RBF-SVM / SVR Mandatory! 1.23 No (decays to mean) Smooth nonlinear surfaces on small-to-medium descriptor tables (N < 5,000)
Random Forest No (scale-free) 1.17 No (flatlines!) Rock-solid nonlinear tabular workhorse; minimal tuning, resistant to overfitting
XGBoost No (scale-free) 1.11 (Hybrid) No (flatlines!) Highest accuracy on descriptors + Count Fingerprints (tune lr & max_depth)
Logistic Reg. Yes (for L2) AUC = 0.892 Linear log-odds Calibrated baseline probabilities for binary pass/fail screening
Best practice: always train Ridge first (linear sanity check), then Random Forest / XGBoost (nonlinear ceiling), inside a leak-free Pipeline.
Linköping University Laboratory of Organic Electronics

Summary (Take home notes)

  • Start simple, benchmark fairly: Lock away X_test first, beat the Dummy baseline (2.42), and progress systematically from Ridge (1.65) → Scaled kNN/SVR (1.19–1.23) → RF/XGBoost + Count FP (1.11, R2 = 0.79).
  • Respect geometry & units: Distance, kernel, and regularized models require training-only StandardScaler inside a Pipeline; tree ensembles are scale-invariant, while Ridge (L2) and Permutation Importance tame collinearity.
  • Match metrics to lab costs: Under class imbalance, replace Accuracy with Confusion Matrices, ROC-AUC (0.956), and threshold tuning (lowering τ = 0.25 catches >93% of insoluble compounds).
  • Never ignore physical priors: Tree ensembles strictly interpolate within training label bounds (Pentacene flatline); predictions obey training solvent conditions (water vs. chlorobenzene for C8-BTBT) and miss unencoded 3D crystal lattice energy (Tm).
  • Validate like a skeptic before synthesis: Combine 5-Fold CV (mean ± std), Murcko Scaffold Splits, Learning Curves, and Count-FP Applicability Domain checks.
Linköping University Laboratory of Organic Electronics

Thanks for your listening

Any question contact: Zesheng.liu@liu.se
AI for Materials Science  ·  Interactive Notebooks 020 & 02a–02f
Linköping University Laboratory of Organic Electronics