Learning Statistics with Python
Companion slide decks
Learning Statistics with Python
Companion slide decks for ISOM 5650 · interactive, runs Python in your browser
Pick a chapter for the full deck, or jump straight to a section mini-deck. Every deck runs Python through Pyodide: predict the output, run the cell, edit it, break it. The companion book is at statpython-book.pages.dev.
Basics of Python
Python as a calculator, numbers, strings, lists, tuples, sets, dictionaries, control flow, comprehensions, functions, error handling.
Data Structures and Methods of Series
pandas Series end to end: operators, aggregation, apply/where, missing data, sorting, clipping, ranking, binning, indexing, dates, rolling windows, resampling, plotting.
DataFrames
DataFrame methods end to end: axes and alignment, agg and apply, missing and duplicated values, filtering, groupby, pivot, melt, stack, merging and concatenation, and the modern method-chaining style.
Reshaping Statistics
From averages to distributions: empirical and theoretical distributions, bootstrap confidence intervals and hypothesis tests, experimental design with A/B tests and bandits, linear and nonlinear association, and extreme value theory for the tails.
Statistical Predictive Models
Credit-risk case (default, EAD, LGD): feature engineering, multiple regression, model selection, inference, trees and boosting, logistic classification, and why prediction is not causation, plus attention-based cross-sectional features.
- §4.1 Credit Risk Data: Default, EAD, LGD, Feature Engineering, Multiple Regression
- §4.2 Model Selection: Adjusted R², Interactions, Best Subset, Inference, Multicollinearity
- §4.3 Nonlinear Models: Trees, Random Forests, Gradient Boosting, Logistic Classification
- §4.4 Causal Analysis: Prediction vs Causation, Confounders, Difference-in-Differences, Instrumental Variables
- §4.5 Cross-Sectional Attention Features: Transformers for the Stock Cross-Section
Rethinking Statistics with Bayesian Methods
Priors, likelihoods and posteriors for risk and reward, credible intervals, Bayesian regression with predictive checks, robust regression with fat tails, dynamic updating.
Time Series Models for Trading and Risk
Stationarity, ACF/PACF and ARIMA as the foundations — then where time-series models still earn their keep in quant trading: volatility (ARCH/GARCH/GJR, VaR, vol targeting), structural arbitrage (cointegration and pairs, Kalman hedge ratios, regime switching), and the walk-forward discipline that underpins every ML pipeline. Mean forecasting itself has largely been ceded to ML.
- §6.1 Foundations: Stationarity, Unit Roots, ACF/PACF, ARIMA as a Baseline
- §6.2 Why Mean Forecasting Lost to ML: Forecast Accuracy, Walk-Forward Discipline, Time Series as the Base of the ML Pipeline
- §6.3 Structural Arbitrage I: Cointegration and Pairs Trading
- §6.4 Structural Arbitrage II: Kalman Filters and Regime Switching
- §6.5 Volatility I: ARCH, GARCH(1,1), Forecasts and VaR
- §6.6 Volatility II: Leverage (GJR), ARMA+GARCH, and Volatility Targeting
Modern Statistical Learning in Practice
Six methods that have moved from research papers into everyday practice, each built on what earlier chapters taught: learning to rank, quantile and conformal prediction, double machine learning, covariance shrinkage and cluster-based allocation, event-based labels and meta-labeling, and the statistics that decide whether a discovered pattern is real. The demonstrations use market data; the methods are used far beyond it — search and recommendation, demand forecasting, policy and marketing evaluation, any high-dimensional covariance, two-stage decision systems, and large-scale experimentation.
- §7.1 Learning to Rank
- §7.2 Quantile and Conformal Prediction: Intervals, Not Points
- §7.3 Double Machine Learning: Effects with Many Controls
- §7.4 Covariance Shrinkage and Cluster-Based Allocation (Hierarchical Risk Parity)
- §7.5 Event-Based Labels and Meta-Labeling: Triple Barriers and Two-Stage Decisions
- §7.6 Selection Statistics: Deflated Performance, Overfitting Probability, and 42 Rules on Trial