liveBook · Manning

Causal Markov kernel

As explained in Causal AI

A causal Markov kernel is a conditional probability factor associated with a node in a causal graph and interpreted as the mechanism determining that node from its parents.

Suppose you want to predict how in-game purchases would change if players became more engaged with side quests. A purchase model fitted to engagement alone may miss guild membership, which affects both engagement and purchases. A causal DAG makes these assumed relationships explicit. Each node then has a causal Markov kernel: a probability distribution for that node given its direct parents, interpreted as the mechanism generating it if the DAG is correct. section 7.1.6 section 3.5

For guild membership G, side-quest engagement E, and purchases P, the DAG specifies three kernels: P(G), P(E|G), and P(P|G,E). Composing them gives the joint model P(G,E,P) = P(G)P(E|G)P(P|G,E). A root node has no parent inputs. A conditional kernel takes parent values and a queried child value to return a probability; a generative implementation can also sample a child value. section 7.1.6 section 3.1.7

A practical modeling workflow is:

  • Specify the causal DAG before fitting distributions. Its arrows state which parent variables each kernel uses; they are causal assumptions, not conclusions supplied by the fitted parameters. section 3.5 section 7.1.6
  • Choose a parameterization for each kernel. Options range from conditional probability tables and regression models to neural networks. section 3.5
  • Estimate parameters from data and compose the kernels into a generative model. For the game example, membership proportions, engagement proportions conditional on membership, and purchase statistics conditional on both parents provide separate estimates. section 7.1.6 section 3.1.7

The kernels are modular: each represents a distinct mechanism, and its parameters can be learned separately. Under the assumed causal model, changing one mechanism need not change the others. This is why a composed model can be used for an intervention rather than only for observational prediction: an intervention on engagement changes how engagement is set while the other modeled mechanisms remain in place. section 3.5 section 7.1.6

Listing 7.8 Building a causal model of In-Game Purchases in Pyro
import pyro
from torch import tensor
from pyro.distributions import Bernoulli, Normal

def model():
    p_member = tensor(0.5)    #1
    is_guild_member = pyro.sample(    #1
        "Guild Membership",     #1
        Bernoulli(p_member)     #1
    )     #1
    p_engaged = (tensor(0.8)*is_guild_member +    #2
                 tensor(.2)*(1-is_guild_member))    #2
    is_highly_engaged = pyro.sample(    #2
        "Side-quest Engagement",     #2
        Bernoulli(p_engaged)     #2
    )     #2
    get_purchase_param = lambda param1, param2, param3, param4: (     #3
        param1 * (1-is_guild_member) * (1-is_highly_engaged) +     #3
        param2 * (1-is_guild_member) * (is_highly_engaged) +   #3
        param3 * (is_guild_member)   * (1-is_highly_engaged) +    #3
        param4 * (is_guild_member)   * (is_highly_engaged)     #3
    )     #3
    μ = get_purchase_param(37.95, 54.92, 223.71, 125.50)     #4
    σ = get_purchase_param(23.80, 4.92, 5.30, 53.49)    #4
    in_game_purchases = pyro.sample(    #4
        "In-game Purchases",   #4
        Normal(μ, σ)     #4
    )   #4
    guild_membership = "member" if is_guild_member else "nonmember"     #5
    engagement = "high" if is_highly_engaged else "low"   #5
    in_game_purchases = float(in_game_purchases)     #5
    return guild_membership, engagement, in_game_purchases     #5

The Pyro model samples guild membership, sets the engagement probability using membership, and selects purchase-distribution parameters using both parent values. section 7.1.6

The same interface, different mechanisms

A kernel need not be a small table. In an image model, a variational autoencoder decoder models P(image|digit, is-handwritten, Z), where Z stands in for additional image causes; its learned representation is not itself the actual latent causes. In a Markov decision process represented as a DAG, the state-transition function P(next state|current state, action) is the next state's kernel. For generated text, fine-tuned GPT-2 and BART models serve as kernels for successive nodes in a causal story. section 5.2.2 section 12.5.2 section 13.3.2

How Causal AI covers it

How deep it goes
Defines the mechanism interpretation and works through separate estimation and Pyro composition, without requiring a single kernel parameterization.
Examples
Uses guild engagement and purchases, image generation with a VAE decoder, state transitions, and Transformer-generated causal stories.
What it assumes
Assumes a causal DAG and conditional probabilities; builds from those to fitted mechanisms, while making the DAG's correctness an explicit condition.
What you can do after
Build it from scratch by specifying a DAG, fitting node-level kernels, composing a generative model, and applying interventions with Pyro.
How it connects
Connects causal DAGs and the causal Markov property to parameter modularity, interventions, variational autoencoders, and Markov decision processes.

Related concepts

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