liveBook · Manning

Conditional expectation

As explained in Causal Inference for Data Science

A conditional expectation is the expected value of a variable under a specified condition or given values of other variables.

Conditional expectation asks for the average value of an outcome after restricting attention to a condition. E[Y|X = a] is the expected value of Y among cases with X = a; operationally, condition on X = a by filtering to those rows, then examine the resulting distribution or its mean. This can differ from the unconditional expectation E[Y] because the composition of cases changes after conditioning. section 1.5.2

Figure 1.8 On the left is a sample of a variable y. On the right, the same data is split by two different values of x, giving the conditional distributions for different xs. The central black dots are the means for each group, so on the left is the unconditional expectation and on the right are the two conditional expectations.
figure

Compare the overall mean of Y with the means after splitting Y by values of X. The group means are conditional expectations, while the single mean is unconditional. section 1.5.2

For prediction under squared-error loss, the mean is the best single prediction for a collection of values. Once inputs are available, the corresponding target is the conditional expectation: a predictive model learns the average outcome associated with each input configuration, rather than trying to reproduce every observed outcome. section 4.1.2 section 4.2.5

Predicting signal rather than noise

Write an observed outcome as Y = E[Y|X] + ε. For a given x, the observed y may depart from its conditional expectation because of ε, whose conditional mean is zero. A model that follows each observed point too closely learns noise; a useful predictive model instead targets E[Y|X]. Cross-validation and cross-fitting help keep fitting focused on that target rather than the training observations. section 4.2.5

Conditional expectation has distinct roles in prediction and causal analysis:

  • In supervised learning, estimating E[Y|X] supports forecasting the most likely or average outcome from patterns in past data. This use depends on future events behaving similarly to past events. section 4.0
  • In causal inference, E[Y|X,Z] can supply the conditional quantity needed by the adjustment formula when Y has many possible values. A supervised learning model can estimate it in the presence of many confounders. section 4.2
  • A conditional expectation is observational: it describes outcomes associated with observed conditions. It is not, by itself, an interventional expectation such as E[Y|do(X = x)], which concerns changing X. section 4.0

How Causal Inference for Data Science covers it

How deep it goes
Defines conditioning through filtering and group means, then derives its squared-loss prediction role and relates it to overfitting.
Examples
Uses simulated X, Y, and Z tables, split distributions with group means, and noisy curves contrasting fitted signal with overfitting.
What it assumes
Assumes solid conditional-probability and conditional-expectation knowledge, while rebuilding intuition through filtered data tables.
What you can do after
Apply it via supervised learning models to predict conditional outcomes and evaluate adjustment formulas with many confounders.
How it connects
Connects conditional probability, supervised learning, squared loss, cross-fitting, overfitting, confounders, and the adjustment formula.

Also explained in

Compare how 2 books explain conditional expectation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Causal Inference for Data Science. The section links point to the parts of the book it draws on.