The Regression Cookbook (Stats Flavours)

Open-access textbook that teaches regression in both the machine learning and statistics idioms, with Python and R code side by side. Funded by the UBC OER Fund.

The Regression Cookbook: Machine Learning and Stats Flavours

An open educational resource, funded by the UBC OER Fund, for teaching regression across two academic cultures that often speak past each other: the machine-learners and the statisticians.

Most regression content forces a choice: either the scikit-learn/cross-validation idiom of machine learning or the inference-and-estimators idiom of statistics. Working data scientists need both. The Cookbook presents each method once, in both dialects, same data, both implementation languages, and a common terminology glossary:

  • Dual-language code: every worked example runs in Python and R, side by side, so readers can translate fluently between team conventions.
  • Shared vocabulary: a deliberate common lexicon (e.g., “regularization” ↔ “shrinkage”, “training set” ↔ “estimation sample”) so statisticians and ML engineers stop talking past each other in code review.
  • Complete method coverage: from OLS and GLMs through penalized models (ridge/lasso/elastic net), trees and ensembles, to structured data regression, each chapter with assumptions, diagnostics, and end-to-end working code.
  • Open source and citable: the full source lives publicly; instructors are encouraged to adapt chapters into their own courses.

Links: book source (GitHub) · rendered chapters · toy dataset.

The project grew out of two years as primary instructor across the UBC Master of Data Science (DSCI), statistics (STAT), and science communication curricula. The same material serves DSCI 551 (Descriptive Statistics and Probability), DSCI 100, and STAT 302 cohorts with very different mathematical backgrounds.