Rare events, honest metrics:
grading a detector that hardly ever triggers

Session 14 · Fri Oct 30 · Book section 3.4

⚖️

Today’s question

A detector that never triggers is 98% accurate.

What should an earthquake detector actually be graded on?

This lecture in the literature

📖 The playbook: why ROC plots flatter classifiers on imbalanced data, and why the precision-recall plot tells the truth.

Saito, T., & Rehmsmeier, M. (2015). The precision-recall plot is more informative than the ROC plot when evaluating binary classifiers on imbalanced datasets. PLOS ONE, 10(3), e0118432.

Rare-event detection done right: an earthquake detector graded — and celebrated — on precision and recall, not accuracy.

Mousavi, S. M., Ellsworth, W. L., Zhu, W., Chuang, L. Y., & Beroza, G. C. (2020). Earthquake transformer — an attentive deep-learning model for simultaneous earthquake detection and phase picking. Nature Communications, 11, 3952.

A celebrated deep aftershock model, matched by a single neuron — headline scores on imbalanced data hid how little was learned.

DeVries, P. M. R., et al. (2018). Deep learning of aftershock patterns following large earthquakes. Nature, 560, 632–634. — Mignan, A. & Broccardo, M. (2019). One neuron versus deep learning in aftershock prediction. Nature, 574, E1–E3.

Metric choice has made and unmade published claims — these three calibrate today’s tools.

The detection problem in two features

Events carry high STA/LTA and high-frequency energy; noise sits low on both. Heavy-tailed ratio → take the log first. Synthetic (mlgeo_synth), 2000 windows.

Units are not optional

0.96 k-NN accuracy — both features standardized

0.87 same classifier — centroid in millihertz, no scaling

The scaler is fit on the training split only, then applied to both splits — fitting it on everything leaks test statistics into training.

Distance sees numbers, not units. A colleague’s unit change silently deleted one feature.

Three numbers per detector

  • Recall = TP / (TP + FN) — of the real events, how many did we catch?
  • Precision = TP / (TP + FP) — of our triggers, how many were real?
  • F1 = harmonic mean of the two — high only when both are high

The harmonic mean weights the lower number: precision 1.0 with recall 0.1 gives F1 0.18, not 0.55.

Report both. A detector can be excellent on one and useless on the other.

Make events rare — accuracy dies first

0.980 accuracy of a detector that never triggers — 2% events

0.650 recall of a trained model with 0.992 accuracy

Same features, same models — only the class balance changed. The 99%-accurate detector misses a third of the earthquakes.

Two curves, one honest

ROC divides false alarms by ~1,960 test-split noise windows — flattering. Precision divides by your trigger list — the analyst’s workload. Rare positives: read the PR curve.

Moving the operating point

Same logistic regression Precision Recall The trigger list
threshold 0.5 (default) 0.93 0.65 short — misses ⅓ of events
class weights ≈ 1:49 0.44 0.93 long — catches nearly all
threshold lowered to 0.25 0.78 0.73 in between

Class weights make one event error cost ~49 noise errors during training; threshold moving re-cuts the same fitted probabilities.

Neither knob is “better” — they slide along one curve. The operating point is a scientific decision about analyst time vs missed events.

Which metric answers which question

Metric The question it answers When it misleads Today’s detector
Accuracy fraction correct, all classes any class imbalance never-trigger scores 0.980
Precision how clean is the trigger list alone — one sure trigger wins 0.93 while missing ⅓
Recall how many events caught alone — trigger on everything 0.93 at precision 0.44
F1 both at once, harmonic when error costs are unequal 0.77 at the default cut
ROC AUC ranking, all thresholds rare positives 0.99 while recall is 0.65

Price your errors first — a missed event costs science, a false trigger costs analyst time — then pick the metric that charges those prices.

Now run it yourself — open 3.4

  1. pixi run jupyter lab3.4_binary_classification.ipynb
  2. Balanced set: race the nine classifiers; verify precision/recall/F1 barely separate them
  3. Imbalanced set: reproduce the three operating points, then choose one and defend it in a sentence
  4. Find the two discipline lines: the scaler fit on train only, and the curves computed on the test split

Project proposals due today on Canvas. · Mon: multiclass classification (3.5) — the leaderboard opens