Data Science for Economists

A reading companion for Econ 368 · Bates College · Winter 2027

Hitanshu Pandit · Department of Economics


For reading I recommend Aurélien Géron, Hands-On Machine Learning with Scikit-Learn and PyTorch (O’Reilly, 2025). This is not a replacement for it. It is my teaching notes written up, in the order we teach the course, with economic examples and Python you can run.

Use it for three things: to read the week’s material before Monday, to run the code (every block works in the course environment or Google Colab), and to work the exercises at the end of each chapter. Géron is where you go for the fuller treatment and more engineering detail; this is where you go for how we did it in class.

Contents

  Chapter Covers
  Part I — Tools for economic data  
1 What data science is for description, prediction and causation; what “big” data changes
2 Python for economists types, lists and dictionaries, functions, NumPy, a regression by hand
3 Reproducible projects with Git folders, scripts, paths, commits, branches, pull requests
4 Wrangling, bigger data, and pictures tidy data, pandas verbs, merges, missing values, Parquet/DuckDB, charts that inform
5 Mapping opportunity the Opportunity Atlas, rank-rank mobility, geopandas, choropleths
6 Getting data from the web HTTP, JSON, APIs and keys, HTML and scraping, the ethics
  Part II — Experiments and uncertainty  
7 A/B tests randomization, difference in means, power, CUPED, peeking, many metrics
8 Resampling: simulation and the bootstrap Monte Carlo, coverage, the bootstrap, permutation tests
  Part III — Machine learning  
9 An end-to-end machine learning project the landscape, train/test, pipelines, cross-validation, the test set is sacred
10 Training linear models OLS as a predictor, gradient descent, polynomials and splines, learning curves
11 Regularization and model selection ridge, LASSO, elastic net, choosing the penalty by cross-validation
12 Classification logistic regression, other classifiers, confusion matrices, thresholds and costs
13 Support vector machines the widest street, soft margins, kernels
14 Decision trees splits, impurity, depth, why trees overfit
15 Ensembles: forests and boosting bagging, random forests, gradient boosting, importance and SHAP
16 Dimensionality reduction the curse of dimensionality, PCA, a development index
17 Clustering k-means, choosing k, hierarchical clustering, Gaussian mixtures
18 Neural networks from logit to a neuron, backpropagation, training, when nets lose to trees
  Part IV — Language  
19 Text as data regex, bag of words, tf-idf, dictionaries, text regression
20 Embeddings and topic models topic models, word and sentence embeddings, similarity
21 Transformers, LLMs, and how they are told to behave attention, pretraining and fine-tuning, constitutions, LLMs as annotators

Every chapter ends with Economics reading: published papers in which economists use the chapter’s method, each with a question to think about.

How to read it

Read with a laptop open. Every code block runs, top to bottom, and the numbers in the text are the numbers the code prints. Change something and run it again; that is how this material is learned.

The datasets repeat on purpose. Bay Area rents appear in Chapters 9, 10, 14 and 15; hotel bookings in Chapters 12 and 13; county childcare costs in Chapters 4 and 11. You are meant to notice that a new method is answering a different question about data you already understand.

A note on accuracy

Every number in this book is computed by the code in it. If a number here disagrees with a slide, the book is right and the slide is wrong. Please tell me in class or open an issue.


© 2026 Hitanshu Pandit. Text released under CC BY-NC-SA 4.0; code under the MIT license.

Econ 368 · Bates College · Hitanshu Pandit · source
. -->