Causal Inference in Python: Applying Causal Inference in the Tech Industry (Fourth Early Release)
Book information
Description
This book is an introduction to Causal Inference in Python, but it is not an introductory book in general. It’s introductory because I’ll focus on application, rather than rigorous proofs and theorems of causal inference; additionally, when forced to choose, I’ll opt for a simpler and intuitive explanation, rather than a complete and complex one. It is not introductory in general because I’ll assume some prior knowledge about Machine Learning (ML), statistics and programming in Python. It is not too advanced either, but I will be throwing in some terms that you should know beforehand. How many buyers will an additional dollar of online marketing bring in? Which customers will only buy when given a discount coupon? How do you establish an optimal pricing strategy? The best way to determine how the levers at our disposal affect the business metrics we want to drive is through causal inference. In this book, author Matheus Facure, senior data scientist at Nubank, explains the largely untapped potential of causal inference for estimating impacts and effects. Managers, data scientists, and business analysts will learn classical causal inference methods like randomized control trials (A/B tests), linear regression, propensity score, synthetic controls, and difference-in-differences. Each method is accompanied by an application in the industry to serve as a grounding example. Here is a non exhaustive list of the things I recommend you know before reading this book: - Basic knowledge of Python, including the most commonly used data scientists libraries: Pandas, Numpy, Matplotlib, Scikit-Learn. I come from an Economics background, so you don’t have to worry about me using very fancy code. Just make sure you know the basics pretty well. - Knowledge of basic statistical concepts like distributions, probability, hypothesis testing, regression, noise, expected values, standard deviation, independence. I will include a statistical review in the book in case you need a refresher. - Knowledge of basic data science concepts, like machine learning model, cross validation, overfitting and some of the most used machine learning models (gradient boosting, decision trees, linear regression, logistic regression). With this book, you will: Learn how to use basic concepts of causal inference Frame a business problem as a causal inference problem Understand how bias gets in the way of causal inference Learn how causal effects can differ from person to person Use repeated observations of the same customers across time to adjust for biases Understand how causal effects differ across geographic locations Examine noncompliance bias and effect dilution The main audience of this book is Data Scientists who are working in the industry. If you fit this description, there is a pretty good chance that you cover the prerequisites that I’ve mentioned. Also, keep in mind that this is a broad audience, with very diverse skill sets. For this reason, I might include some note or paragraph which is meant for the most advanced reader. So don’t worry if you don’t understand every single line in this book. You’ll still be able to extract a lot from it. And maybe it will come back for a second read once you mastered some of its basics. Preface Prerequisites Data and Code Outline Conventions Used in This Book Using Code Examples O’Reilly Online Learning How to Contact Us Acknowledgments I. Fundamentals 1. Introduction To Causal Inference What is Causal Inference Why we Do Causal Inference Machine Learning and Causal Inference Association and Causation The Treatment and the Outcome The Fundamental Problem of Causal Inference Causal Models Interventions Individual Treatment Effect Potential Outcomes Consistency and Stable Unit Treatment Values Causal Quantities of Interest Causal Quantities: An Example Bias The Bias Equation A Visual Guide to Bias Identifying the Treatment Effect The Independence Assumption Identification with Randomization Key Ideas 2. Randomized Experiments and Stats Review Brute Force Independence with Randomization An A/B Testing Example The Ideal Experiment The Most Dangerous Equation The Standard Error of Our Estimates Confidence Intervals Hypothesis Testing Null Hypothesis Test Statistic P-values Power Sample Size Calculation Key Ideas 3. Graphical Causal Models Thinking About Causality Visualizing Causal Relationships Are Consultants Worth it? Crash Course in Graphical Models Chains Forks Immorality or Collider The Flow of Association Cheat Sheet Querying a Graph in Python Identification Revisited CIA and The Adjustment Formula Positivity Assumption An Identification Example with Data Confounding Bias Surrogate Confounding Randomization Revisited Selection Bias Conditioning on a Collider Adjusting for Selection Bias Conditioning on a Mediator Key Ideas II. Adjusting for Bias 4. The Unreasonable Effectiveness of Linear Regression All You Need is Linear Regression Why We Need Models Regression in A/B Tests Adjusting with Regression Regression Theory Single Variable Linear Regression Multivariate Linear Regression Frisch-Waugh-Lovell Theorem and Orthogonalization Debiasing Step Denoising Step Standard Error of the Regression Estimator Final Outcome Model FWL Summary Regression as an Outcome Model Positivity and Extrapolation Non-Linearities in Linear Regression Linearizing the Treatment Non-Linear FWL and Debiasing Regression for Dummies Conditionally Random Experiments Dummy Variables Saturated Regression Model Regression as Variance Weighted Average De-Meaning and Fixed Effects Omitted Variable Bias: Confounding Through the Lens of Regression Neutral Controls Noise Inducing Control Feature Selection: A Bias-Variance Trade-Off Key Ideas 5. Propensity Score The Impact of Management Training Adjusting with Regression Propensity Score Propensity Score Estimation Propensity Score and Orthogonalization Propensity Score Matching Inverse Propensity Weighting Variance of IPW Stabilized Propensity Weights Pseudo-Populations Selection Bias Bias-Variance Trade-Off Positivity Design vs Model-Based Identification Doubly Robust Estimation Treatment is Easy to Model Outcome is Easy to Model Generalized Propensity Score for Continuous Treatment Keys Ideas III. Effect Heterogeneity and Personalization 6. Effect Heterogeneity From ATE to CATE Why Prediction is not the Answer CATE with Regression Evaluating CATE Predictions Effect by Model Quantile Cumulative Effect Cumulative Gain Target Transformation When Prediction Models are Good for Effect Ordering Marginal Decreasing Returns Binary Outcomes CATE for Decision Making Key Ideas 7. Meta-Learners Meta-Learners for Discrete Treatments T-Learner X-Learner Meta-Learners for Continuous Treatments S-Learner Double/Debiased Machine Learning Key Ideas IV. Panel Data 8. Difference-in-Differences Panel Data Canonical Difference-in-Differences Diff-in-Diff with Outcome Growth Diff-in-Diff with OLS Diff-in-Diff with Fixed Effects Multiple Time Periods Inference Identification Assumptions Parallel Trends No Anticipation Assumption and SUTVA Strict Exogeneity No Time Varying Confounders No Feedback No Carryover and no Lagged Dependent Variable Effect Dynamics Over Time Diff-in-Diff with Covariates Doubly Robust Diff-in-Diff Propensity Score Model Delta Outcome Model All Together Now Staggered Adoption Heterogeneous Effect over Time Covariates Key Ideas 9. Synthetic-Control Online Marketing Dataset Matrix Representation Synthetic Control as Horizontal Regression Canonical Synthetic Control Synthetic Control with Covariants Debiasing Synthetic Control Inference Synthetic Difference-in-Differences DID Refresher Synthetic Controls Revisited Estimating Time Weights Synthetic Control and DID Key Ideas V. Alternative Experimental Designs 10. Geo and Switchback Experiments Geo-Experiments Synthetic Control Design Trying a Random Set of Treated Units Random Search Switchback Experiment Potential Outcomes of Sequences Estimating the Order of Carryover Effect Design Based Estimation Optimal Switchback Design Robust Variance Key Ideas 11. Non-Compliance and Instruments Non-Compliance Extending Potential Outcomes Instrument Identification Assumptions First Stage Reduced Form Two Stage Least Squares Standard Error Additional Controls and Instruments 2SLS by Hand Matrix Implementation Discontinuity Design Discontinuity Design Assumptions Intention to Treat Effect The IV Estimate Bunching Key Ideas 12. Next Steps Causal Discovery Sequential Decision Making Causal Reinforcement Learning Causal Forecasting Domain Adaptation Closing Thoughts Index About the Author
Similar books
Downloaded Causal Inference in Python: Applying Causal Inference in the Tech Industry (Final Release)
2023 · EPUB
Causal Inference in Python: Applying Causal Inference in the Tech Industry
2023 · PDF
Causal Inference in Python: Applying Causal Inference in the Tech Industry
2023 · EPUB
Causal Inference in Python (5th Early Release))
2023 · EPUB
Causal Inference in Python
2022 · PDF
Causal Inference in Python
2022 · EPUB
EXCEL 2023 CRASH COURSE: Master Excel 2023 With This Complete Crash Course In 7 Days
2022 · EPUB
The arraignment and tryall with a declaration of the Ranters also, several sentences proceedings at the sessions in the Old-Baily, and Councel of War: their protestations and the hanging of one up by the thumbs; with divers penalties to be inflicted upon others. The dancing and revelling of Dr. Buckeridge and his wife, and other gent. dancing all in white, in Berkshire, and their Christmas carol. A dispute between a Ranter in Bridewel, and one that came to see him; with his creed and pater noster: and the names of the false gods they worship. As also, a list of many of the Ranters, from whence they are derived: and of many hundreds of them in England
2019 · EPUB