Chapter 3: Classic Machine Learning in Geosciences¶
This chapter covers classic machine learning (CML) for geoscience: models that learn from feature tables rather than raw waveforms or images. Classic ML is fast to build, cheap to run, and easy to interrogate. That makes it the right place to learn the habits that carry over to deep learning: baselines, honest data splits, and evaluation that matches how a model will actually be used.
The arc of the chapter¶
Concepts (3.1) — the training-supervision taxonomy: supervised, unsupervised, semi-supervised, self-supervised, reinforcement, and active learning, and where each shows up in geoscience.
Classification and regression (3.2) — the two supervised problem types, a first end-to-end workflow, and the train/validation/test split.
Fitting a line, finding groups (3.3) — least-squares regression and its uncertainty, k-means from its two steps, choosing K with the elbow, and PCA before clustering, on height and weight, Old Faithful, rock chemistry and Pacific Northwest seismic events.
Binary classification (3.4) — event-vs-noise detection, classifier comparison, the metrics that matter when classes are imbalanced (precision, recall, PR curves vs ROC), and two knobs for treating imbalance (class weights, threshold moving).
Multiclass classification (3.5) — four seismic source types, per-class confusion matrices, one-vs-rest ROC, and the class leaderboard exercise.
Logistic regression from scratch (3.6) — the one lesson where the black box is opened: the loss function, gradient descent, automatic differentiation with PyTorch, and a calibration check — reliability diagrams and the Brier score — on the predicted probabilities.
Trees, forests, and boosting (3.7) — decision trees, random forest regression, feature importance and its pitfalls (permutation importance, partial dependence, correlated features), and gradient boosting as the modern tabular default.
Robust training (3.8): what a validation score answers on correlated data. A GNSS forecast on shuffled and future folds, spatial blocks on a soil moisture map, whole events in a ground-motion table, persistence baselines, and an interval that respects correlation.
Ensembles (3.9): averaging, boosting written by hand, and stacking on out-of-fold predictions, with shared errors as the limit of a combination and disagreement between models as a first estimate of epistemic uncertainty.
AutoML (3.10): a small AutoML written with scikit-learn only, how the choice of validation changes its winner, why the best score of a search is optimistic, and an audit of a modeling script written by an AI agent.
Forests in practice (3.11): an active notebook for Session 17, with a ROC curve from ten events, thresholds across two models, forest regression on real soil moisture, and a test beyond the training range.
Dimensionality reduction (PCA, t-SNE) is covered in Chapter 2.12 and is used here as a preprocessing step, not re-taught.
The fair-evaluation thread¶
A single discipline runs through every notebook in this chapter:
Baselines first. Before any model, establish what a trivial predictor achieves: the majority class for classification, the historical mean for regression. A model that cannot beat the baseline has learned nothing.
Never evaluate on training data. Model quality is measured on data the model has not seen. Cross-validation happens inside the training set; the test set is touched once.
Splits must respect data structure. Autocorrelated series and clustered spatial data need temporal, blocked, or grouped splits (3.8).
Hidden test sets exist. The instructor holds regenerated variants of the course datasets with private seeds. Scores that were tuned against a public test set will show a gap on the hidden one.
Lesson 3.5 puts this into practice with a class leaderboard: students train a classifier of their choice on a canonical split of a real seismic-source dataset, submit predictions by pull request, and are scored by continuous integration against both the public and the hidden test sets.
Tools¶
The chapter uses scikit-learn as the workhorse, lightgbm and scikit-learn’s histogram gradient boosting for boosted trees, optuna for hyperparameter search, and pytorch in 3.6 to introduce automatic differentiation. Course datasets come from the mlgeo_synth package (physically motivated synthetic generators), the course data repository, and a curated Zenodo archive of Pacific Northwest seismic events.
Learning outcomes¶
By the end of this chapter, you will be able to:
Frame a geoscience problem as classification, regression, or clustering, and pick an appropriate first model.
Establish baselines and evaluate models with metrics suited to the problem, including imbalanced classes.
Design data splits and cross-validation schemes that respect temporal and spatial correlation.
Train, tune, and compare tree ensembles and other classic models, and report results honestly.
Read a machine-generated modeling script and find its flaws.
Assignments¶
Homework: one homework assignment (a whole-rock geochemistry classification problem) covering data preparation, PCA, clustering, and model comparison, plus a short homework on scoring clusters (about 2 hours): homogeneity, completeness and the silhouette, by hand and on the data of your Session 7 track, with PCA and an AI review of your work.
Final project milestone: one milestone guideline (3.20) applying these methods to your own project dataset.