Lab 3·Good, Bad and Ugly — Honest vs Misleading Visualizations
Steps
- Part 1Anscombe's Quartet
- Part 2Lie Factor and honest redesign
- Part 3Four versions of one dataset
- Part 4Systematic EDA on World Bank data
- AI expansionWrite the prompt, run the code, check it against your own result
- Part 5Push to GitHub with the P.R.I.M.E. README
Skills you need
Setup & load
Read a CSV from a link and take a first lookcoming
Clean & reshape
groupby: one number per groupcomingDates: parse_dates, .dt.year, and a monthly gridcomingMissing values: find them, drop them, fill themcoming
Graduate extras
Function signatures: type hints, defaults and docstringscomingYour own module: %%writefile, import, and importlib.reloadcomingDefensive code: raise, assert and try/exceptcoming
and the everyday basics: Colab, imports, variables, reading an error, f-strings, one bracket or two, a first chart, loops, more charts, numpy arrays and seeds.
Lab 4·Robust Statistics — When One Row Moves the Answer
Steps
- Part 1Robust vs non-robust
- Part 2Tukey fences
- Part 3Isolation Forest
- ExtensionContamination experiment
- Challengeflag_outliers(), their first function
- AI expansionWrite the prompt, run the code, check it against your own result
- CloseTake-home and submission
Skills you need
Setup & load
Read a CSV from a link and take a first lookcomingData that isn't a CSV: FRED with a secret key, and built-in datasetscoming
Machine learning
scikit-learn's pattern: build, fit, predictcomingfirst time you need this
Graduate extras
Function signatures: type hints, defaults and docstringscomingYour own module: %%writefile, import, and importlib.reloadcomingDefensive code: raise, assert and try/exceptcoming
and the everyday basics: Colab, imports, variables, reading an error, f-strings, one bracket or two, a first chart, loops, more charts, numpy arrays and seeds.
Lab 5·Probability & Simulation — When Intuition Is Wrong
Steps
- Part 1Coin flips and the Law of Large Numbers
- Part 2Monty Hall
- Part 3Bayes — the 99% accurate test
- Part 4Monte Carlo Value at Risk
- ExtensionMonte Carlo convergence rate
- AI expansionWrite the prompt, run the code, check it against your own result
- CloseSubmission
Skills you need
Evaluate & report
Line up a results table: <, > and widths in f-stringscoming
Graduate extras
Function signatures: type hints, defaults and docstringscomingYour own module: %%writefile, import, and importlib.reloadcomingDefensive code: raise, assert and try/exceptcomingQuick charts straight from pandas: df.plot()coming
and the everyday basics: Colab, imports, variables, reading an error, f-strings, one bracket or two, a first chart, loops, more charts, numpy arrays and seeds.
Lab 7·Estimation & Bootstrapping — How Uncertain Is the Median?
Steps
- SetupStep 1–2 — seed, then a download
- Part 1Standard deviation vs standard error
- Part 2The parametric interval
- Part 3The bootstrap by hand — where it fails, then where it earns it
- Part 4scipy, and the two blanks
- ExtensionDoes a 95% interval actually cover 95%?
- ChallengeAn estimate with no formula
- AI expansionWrite the prompt, run the code, check it against your own result
- CloseSubmission
Skills you need
Setup & load
Read a CSV from a link and take a first lookcoming
Evaluate & report
Line up a results table: <, > and widths in f-stringscoming
Graduate extras
Your own module: %%writefile, import, and importlib.reloadcomingDefensive code: raise, assert and try/exceptcoming
and the everyday basics: Colab, imports, variables, reading an error, f-strings, one bracket or two, a first chart, loops, more charts, numpy arrays and seeds.
Lab 8·Hypothesis Testing — Was the Job Training Worth It?
Steps
- SetupStep 1 — an install, then a download
- Part 1The LaLonde data, and the raw gap
- Part 2One sample, then two
- Part 3How big, and could we have seen it
- Part 4Five subgroups, two blanks
- Write itWelch's t from six numbers
- ExtensionWhat α and power actually are
- ChallengeThe replication crisis, simulated
- CloseREADME and submission
Skills you need
Setup & load
Read a CSV from a link and take a first lookcoming
Evaluate & report
Line up a results table: <, > and widths in f-stringscoming
Graduate extras
Your own module: %%writefile, import, and importlib.reloadcomingDefensive code: raise, assert and try/exceptcomingQuick charts straight from pandas: df.plot()coming
and the everyday basics: Colab, imports, variables, reading an error, f-strings, one bracket or two, a first chart, loops, more charts, numpy arrays and seeds.
Lab 9·A/B Testing — Designing the Data-Generating Process
Steps
- SetupStep 1 — one install, one seed
- Part 1The experimental benchmark, and what losing it costs
- Part 2Permutation for the p-value, bootstrap for the size
- Part 3Power, before any data
- Part 4Cookie Cats: the decision
- Write itn_needed(), then a rerun sized for Cookie Cats
- ExtensionMetric design, and the peeking problem
- ChallengeDesign and simulate a full A/B test
- CloseREADME and submission
Skills you need
Setup & load
Read a CSV from a link and take a first lookcoming
Evaluate & report
Line up a results table: <, > and widths in f-stringscoming
Graduate extras
Your own module: %%writefile, import, and importlib.reloadcomingDefensive code: raise, assert and try/exceptcomingQuick charts straight from pandas: df.plot()coming
and the everyday basics: Colab, imports, variables, reading an error, f-strings, one bracket or two, a first chart, loops, more charts, numpy arrays and seeds.
Lab 10·Correlation & Causality — Which Story Made This Scatterplot?
Steps
- SetupStep 1 — imports and one seeded generator
- Part 1Three worlds, one scatterplot
- Part 2Writing the claim down, then the good control
- Part 3The control that creates bias
- Part 4M-bias, then LaLonde against the benchmark
- Write itcoef_on_d(), then the path closed by u1
- ExtensionSample size does not cure bias
- ChallengeLet the graph choose the controls
- CloseREADME and submission
Skills you need
Clean & reshape
Join two tables: .merge() and SQL's JOINcoming
Regression & time series
Fit a regression with statsmodels: sm.OLS(y, sm.add_constant(X)).fit()comingfirst time you need thisRead regression results: coefficients, standard errors, intervalscomingfirst time you need this
Evaluate & report
Line up a results table: <, > and widths in f-stringscoming
Graduate extras
Function signatures: type hints, defaults and docstringscomingYour own module: %%writefile, import, and importlib.reloadcomingRegression by formula: smf.ols('y ~ x', data=df) and clustered SEscomingfirst time you need this
and the everyday basics: Colab, imports, variables, reading an error, f-strings, one bracket or two, a first chart, loops, more charts, numpy arrays and seeds.
Lab 11·SQL for Economists — The Same Operations, A Different Grammar
Steps
- SetupStep 1 — a pip install, then DuckDB
- Part 1You already know this
- Part 2The cardinality trap
- Part 3Aggregating without collapsing
- Part 4NULL is not a value, and data you never downloaded
- ExtensionFix the fan-out: aggregate before you join
- ChallengeRead a query you did not write
- AI expansionWrite the prompt, run the code, check it against your own result
- CloseREADME and submission
Skills you need
Setup & load
Read a CSV from a link and take a first lookcoming
Clean & reshape
groupby: one number per groupcomingJoin two tables: .merge() and SQL's JOINcoming
Evaluate & report
Line up a results table: <, > and widths in f-stringscoming
Graduate extras
Function signatures: type hints, defaults and docstringscomingYour own module: %%writefile, import, and importlib.reloadcomingDefensive code: raise, assert and try/exceptcomingQuick charts straight from pandas: df.plot()comingRegression by formula: smf.ols('y ~ x', data=df) and clustered SEscoming
and the everyday basics: Colab, imports, variables, reading an error, f-strings, one bracket or two, a first chart, loops, more charts, numpy arrays and seeds.
Lab 12·Predictive Modeling — The Same Machinery, A New Scorecard
Steps
- SetupStep 1 — imports and two seeds
- Part 1One predictor, three routes to the same line
- Part 2R-squared, and why it cannot fall
- Part 3The test set
- Part 4The two jobs
- Write itholdout_rmse(), then median income alone
- ExtensionOkun's Law: the coefficient is the result
- ChallengeWhere the line breaks: the $500,001 ceiling
- CloseREADME and submission
Skills you need
Setup & load
Read a CSV from a link and take a first lookcomingData that isn't a CSV: FRED with a secret key, and built-in datasetscoming
Clean & reshape
Dates: parse_dates, .dt.year, and a monthly gridcomingMissing values: find them, drop them, fill themcoming
Regression & time series
Fit a regression with statsmodels: sm.OLS(y, sm.add_constant(X)).fit()comingRead regression results: coefficients, standard errors, intervalscomingTime series: shift and rolling, then STL, ARIMA and Prophetcomingfirst time you need thisRobust standard errors and residuals: cov_type and res.residcomingfirst time you need this
Machine learning
scikit-learn's pattern: build, fit, predictcomingSplit the data: train_test_split and stratifycoming
Evaluate & report
Line up a results table: <, > and widths in f-stringscomingScore a model: RMSE, R-squared and sklearn.metricscomingfirst time you need this
Graduate extras
Function signatures: type hints, defaults and docstringscomingYour own module: %%writefile, import, and importlib.reloadcomingRegression by formula: smf.ols('y ~ x', data=df) and clustered SEscoming
and the everyday basics: Colab, imports, variables, reading an error, f-strings, one bracket or two, a first chart, loops, more charts, numpy arrays and seeds.
Lab 13·Multivariate OLS — What "Controlling For" Actually Does
Steps
- SetupStep 1 — imports and one seeded generator
- Part 1Omitted-variable bias, with the truth known
- Part 2Frisch-Waugh-Lovell
- Part 3The control that creates bias, and two that cannot be told apart
- Part 4Interactions
- ExtensionChoosing what goes in: a specification table by hand
- ChallengeSign the bias before you run it
- AI expansionWrite the prompt, run the code, check it against your own result
- CloseREADME and submission
Skills you need
Everywhere
.loc and .iloc: rows by label or by positioncoming
Setup & load
Read a CSV from a link and take a first lookcoming
Regression & time series
Fit a regression with statsmodels: sm.OLS(y, sm.add_constant(X)).fit()comingRead regression results: coefficients, standard errors, intervalscomingRobust standard errors and residuals: cov_type and res.residcoming
Evaluate & report
Line up a results table: <, > and widths in f-stringscoming
Graduate extras
Function signatures: type hints, defaults and docstringscomingYour own module: %%writefile, import, and importlib.reloadcomingRegression by formula: smf.ols('y ~ x', data=df) and clustered SEscoming
and the everyday basics: Colab, imports, variables, reading an error, f-strings, one bracket or two, a first chart, loops, more charts, numpy arrays and seeds.
Lab 14·OLS Diagnostics — When the Standard Error Is Lying
Steps
- SetupStep 1 — imports and one seeded generator
- Part 1The coefficient survives, the interval does not
- Part 2Reading residuals: four pictures, two tests
- Part 3Influence: which number one row moves
- Part 4Real data: California Housing, classical and HC3 side by side
- Write ithc3_se(), then three sentences
- ExtensionInfluence in real data, and when robust is not enough
- ChallengeThe specification that passes everything
- CloseREADME and submission
Skills you need
Setup & load
Data that isn't a CSV: FRED with a secret key, and built-in datasetscoming
Regression & time series
Fit a regression with statsmodels: sm.OLS(y, sm.add_constant(X)).fit()comingRead regression results: coefficients, standard errors, intervalscomingRobust standard errors and residuals: cov_type and res.residcoming
Machine learning
scikit-learn's pattern: build, fit, predictcoming
Evaluate & report
Line up a results table: <, > and widths in f-stringscoming
Graduate extras
Function signatures: type hints, defaults and docstringscomingYour own module: %%writefile, import, and importlib.reloadcomingRegression by formula: smf.ols('y ~ x', data=df) and clustered SEscoming
and the everyday basics: Colab, imports, variables, reading an error, f-strings, one bracket or two, a first chart, loops, more charts, numpy arrays and seeds.
Lab 15·The Bias-Variance Tradeoff — Watching a Model Overfit
Steps
- SetupStep 1 — imports and the seed
- Part 1Two ways to be wrong
- Part 2The curve that misleads
- Part 3Cross-validation, and the spread across folds
- Part 4The selection you did not account for
- Write itkfold_mse(), then 10 folds
- ExtensionMore data instead of less complexity
- ChallengeWhere the tradeoff is not a curve
- CloseREADME and submission
Skills you need
Machine learning
scikit-learn's pattern: build, fit, predictcoming
Evaluate & report
Line up a results table: <, > and widths in f-stringscomingCross-validation: KFold by hand, then cv=5comingfirst time you need this
Graduate extras
Your own module: %%writefile, import, and importlib.reloadcoming
and the everyday basics: Colab, imports, variables, reading an error, f-strings, one bracket or two, a first chart, loops, more charts, numpy arrays and seeds.
Lab 16·Regularization — Buying Bias to Sell Variance
Steps
- SetupStep 1 — the scikit-learn upgrade, imports and the seed
- Part 1Where OLS runs out
- Part 2The path, and λ by cross-validation
- Part 3What it recovered
- Part 4Correlated predictors
- ExtensionElastic Net
- ChallengeStandardisation is not optional
- AI expansionWrite the prompt, run the code, check it against your own result
- CloseREADME and submission
Skills you need
Machine learning
scikit-learn's pattern: build, fit, predictcomingSplit the data: train_test_split and stratifycomingScale, then fit: StandardScaler and make_pipelinecoming
Evaluate & report
Line up a results table: <, > and widths in f-stringscomingScore a model: RMSE, R-squared and sklearn.metricscomingCross-validation: KFold by hand, then cv=5coming
Graduate extras
Function signatures: type hints, defaults and docstringscomingYour own module: %%writefile, import, and importlib.reloadcoming
and the everyday basics: Colab, imports, variables, reading an error, f-strings, one bracket or two, a first chart, loops, more charts, numpy arrays and seeds.