Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Three rules that fit nothing, then three models of rising flexibility, read against the base rate: accuracy alone would crown the rule that never calls a wet winter.

Overview

  1. Rung 0: three rules that set the bars.

  2. Rungs 1–3: logistic regression, a decision tree and gradient boosting, built from scikit-learn.

  3. Precision, recall and average precision against the base rate.

  4. The decision threshold as a trial.

The glossary defines ladder, rung, incumbent, register, base rate and wet-call share.

Prerequisites

ConceptsImportanceNotes
Pythia Foundations: Matplotlib BasicsHelpfulthe confusion-matrix figures
Chapter 3Helpfulthe member-grouped folds
scikit-learn User Guide, §3.4 MetricsHelpfulprecision, recall
Logistic regression, decision treesHelpfulthe idea, not the maths
  • Time to learn: about 15 minutes; every cell runs in seconds.

  • System requirements: the environment.yml at the repository root; no account, no local data beyond the committed cache.

Imports

cache header has no AUTUMN_MONTHS field (it predates the field): taken as AUTUMN_MONTHS=[9, 10, 11], the only autumn the derivation code had: the file's autumn is assumed, not read from the header. A rebuild records it.
train: 80 members / 9200 winters   test: 20 members / 2300 winters   N_FOLDS = 5

The ladder

Unidata compares two algorithms; this cookbook climbs a ladder of three above rules.

RungEstimatorWhat you can read from it
0always-dry · always-wet · Niño-sign rulethe bars and the physical prior
1LogisticRegressionone coefficient, in log-odds
2DecisionTreeClassifierthe rules themselves
3GradientBoostingClassifierlittle directly

Always-dry bars accuracy, always-wet bars precision (at the base rate), and the sign rule is the prior every rung must beat.

The cell builds all six; SignRule, the one custom estimator, prints its source. The asserts check the six against lensml.ladder, which chapters 5–7 reuse.

Loading...

Train

Each rung is scored on the member-grouped folds; rung 1 is also fit once on all training members to print its one coefficient.

trained: always-dry, always-wet, nino-sign, logistic, tree, boosting
logistic coefficient on the scaled Niño 3.4 anomaly (all training members): -0.013 log-odds per SD

The logistic coefficient is tiny, as chapter 2’s standard errors line predicted: its sign is evidence for neither rule.

Validate: confusion matrix, precision, recall

Every number below comes from members the fit never saw. Rows are true, columns predicted; precision (for wet) reads down “pred wet”, recall along “true wet”. called_wet is the wet-call share; accuracy, F1 and average precision (AP) sit beside them.

nino-sign summed confusion matrix (rows = true, columns = predicted); the figure below draws the same matrix:
          pred dry  pred wet
true dry      3019      3117
true wet      1583      1481
Loading...
Six summed confusion matrices over member-grouped folds, one per rung — always-dry, always-wet, nino-sign, logistic regression, decision tree, gradient boosting — rows true, columns predicted, with pooled precision and recall in each title.

Why accuracy misleads

Find the highest accuracy, then read that rung’s called_wet: with a base rate near one third, never calling wet is right two times in three. A weak-signal model rarely clears the default 0.5 threshold, so its near-zero recall is an operating point, not a verdict; ap, which reads the ranking at every threshold, says whether a rung separates wet from dry at all.

The decision threshold is a trial

The decision is a statistical statement in a briefing, and the two errors cost differently. A missed wet winter (recall falls) leaves the briefing at CPC’s “equal chances” — a cheap miss. A false alarm (precision falls) puts a statistically wetter line in a briefing before a dry winter — the costlier error, this cookbook assumes, for an office whose briefing is read as guidance.

Lowering the threshold from 0.5 to the designed base rate (1 - WET_QUANTILE) trades precision for recall along the same ranking, adding no skill: the threshold table below prints the same ap at both. The cell only shows this; a threshold you keep is a chapter 5 trial (FixedThresholdClassifier), and once this table has been read, that trial is no longer blind.

Loading...

Read the two rows: how many wet calls does each threshold make, what happens to recall, and does AP change?

Summary

Rung 0 sets two bars and a prior; three scikit-learn models climb above it. Accuracy rewards never calling wet, so every rung is read on precision, recall and AP against the base rate. A threshold moves the operating point, not the ranking: a trial to record, not a default to change.

What’s next?

Chapter 5 climbs the ladder for real: each rung and threshold trial against the incumbent, with a paired test.

Resources and references

ResourceWhere it bearsLicence
Grover, M., & Banihirwe, A. (2021). NCAR CESM2 Large Ensemble Cloud-Optimized Dataset. NSF NCAR CISL. doi:10.26024/y48t-q717the dataset (required citation)UCAR Data Terms of Use
scikit-learn User Guide: §1.1 Linear models, §1.10 Decision trees, §1.11 Ensembles. https://scikit-learn.org/stable/modules/linear_model.html https://scikit-learn.org/stable/modules/tree.html https://scikit-learn.org/stable/modules/ensemble.htmlthe three rungsBSD-3-Clause
scikit-learn User Guide, §3.4 Metrics and scoring. https://scikit-learn.org/stable/modules/model_evaluation.htmlconfusion matrix, precision, recall, APBSD-3-Clause
MET User’s Guide, Appendix C, Verification Measures (Table 35.2). https://met.readthedocs.io/en/latest/Users_Guide/appendixC.htmlhits, false alarms, POD, FARApache-2.0
NWS Boulder (2020). La Niña and the Upcoming 2020-2021 Winter Season (contains 2010-era slides, e.g. “perhaps through the spring of 2011”). https://www.weather.gov/media/bou/LaNinaWinterOutlook_Sept20.pdf“moderate to strong”US Government work
NWS Pueblo (2025). Winter of 2025-2026 Outlook. https://www.weather.gov/media/pub/pdf/SC_SE_CO_Winter_2025_26_Outlook.pdfCPC’s “equal chances”US Government work
NSF Unidata, Supervised Machine Learning Readiness. https://github.com/Unidata/supervised-ml-readinesschoose, train, validateApache-2.0