A counterfactual inference algorithm computes what would have happened under an alternative condition using a structural causal model (SCM). Unlike prediction, it preserves the observed case while changing a specified condition through an ideal intervention. section 9.5
Run the algorithm in three stages:
- Abduction: infer the exogenous variables that plausibly generated the observed endogenous variables. section 9.5
- Action: apply the hypothetical condition as an ideal intervention in the model. section 9.5
- Prediction: generate the hypothetical outcome using the intervened model and the exogenous-variable distribution inferred during abduction. section 9.5
Abduction may be exact when every endogenous variable is observed and the SCM assignment functions are invertible. More commonly, only some variables are observed, so variational inference approximates the posterior over exogenous variables with a trainable guide function. section 9.3.3
Changing femur length
Given femur length 44 cm and height 165 cm, ask what height would result if femur length were 46 cm. Condition the Pyro model on the observations, optimize a guide with SVI and Trace_ELBO, extract the updated exogenous distribution, then run the hypothetical world. section 9.3.3
Semantic image editing
For an image of a person wearing glasses, abduct a latent representation, intervene to remove glasses, and predict a new image. A causal model aims to preserve image elements not downstream of the edit. section 9.4
Figure 9.12 The parallel world graph for the femur length counterfactual
Use the parallel-world graph to trace the observed case, intervention, shared exogenous variables, and hypothetical outcome. section 9.3.3
