Book Image

Causal Inference and Discovery in Python

By : Aleksander Molak
4.7 (9)
Book Image

Causal Inference and Discovery in Python

4.7 (9)
By: Aleksander Molak

Overview of this book

Causal methods present unique challenges compared to traditional machine learning and statistics. Learning causality can be challenging, but it offers distinct advantages that elude a purely statistical mindset. Causal Inference and Discovery in Python helps you unlock the potential of causality. You’ll start with basic motivations behind causal thinking and a comprehensive introduction to Pearlian causal concepts, such as structural causal models, interventions, counterfactuals, and more. Each concept is accompanied by a theoretical explanation and a set of practical exercises with Python code. Next, you’ll dive into the world of causal effect estimation, consistently progressing towards modern machine learning methods. Step-by-step, you’ll discover Python causal ecosystem and harness the power of cutting-edge algorithms. You’ll further explore the mechanics of how “causes leave traces” and compare the main families of causal discovery algorithms. The final chapter gives you a broad outlook into the future of causal AI where we examine challenges and opportunities and provide you with a comprehensive list of resources to learn more. By the end of this book, you will be able to build your own models for causal inference and discovery using statistical and machine learning techniques as well as perform basic project assessment.
Table of Contents (21 chapters)
1
Part 1: Causality – an Introduction
7
Part 2: Causal Inference
14
Part 3: Causal Discovery

Estimand first!

In this section, we’re going to introduce the notion of an estimand – an essential building block in the causal inference process.

We live in a world of estimators

In statistical inference and machine learning, we often talk about estimates and estimators. Estimates are basically our best guesses regarding some quantities of interest given (finite) data. Estimators are computational devices or procedures that allow us to map between a given (finite) data sample and an estimate of interest.

Let’s imagine you just got a new job. You’re interested in estimating how much time you’ll need to get from your home to your new office. You decide to record your commute times over 5 days. The data you obtain looks like this:

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow><mrow><mrow><mo>[</mo><mn>22.1</mn><mo>,</mo><mn>23.7</mn><mo>,</mo><mn>25.2</mn><mo>,</mo><mn>20.0</mn><mo>,</mo><mn>21.8</mn><mo>]</mo></mrow></mrow></mrow></math>

One thing you can do is to take the arithmetic average of these numbers, which will give you the so-called sample mean - your estimate of the true average commute time. You might feel that this is not enough...