An interventional expectation is the expected value of an outcome or utility after externally setting a variable, written E(U(YX=x)). It answers a causal decision question: what utility should we expect if we impose X = x? This differs from the observational conditional expectation E(U(Y) | X = x), which describes cases where X was observed at x. section 12.2.4
Use the distinction when comparing decisions:
- Model the investment choice X, outcome Y, context C, and utility U in a Bayesian network. section 12.2.4
- Query E(U(Y) | X = x) for observed associations, then apply an ideal intervention and query E(U(YX=x)) for imposed choices. section 12.2.4
- Compare the maximizing actions rather than assuming the two expectations agree; changing one probability can make debt optimal observationally while equity becomes optimal interventionally. section 12.2.4
Listing 12.5 Calculate E(U(Y)|X=x) and E(U(YX=x))
def get_expectation(marginal): #1
u_values = marginal.state_names["U"] #1
probs = marginal.values #1
expectation = sum([x * p for x, p in zip(u_values, probs)]) #1
return expectation #1
infer = VariableElimination(model) #2
marginal_u_given_debt = infer.query( #2
variables=['U'], evidence={'X': 'debt'}) #2
marginal_u_given_equity = infer.query( #2
variables=['U'], evidence={'X': 'equity'}) #2
e_u_given_x_debt = get_expectation(marginal_u_given_debt) #2
e_u_given_x_equity = get_expectation(marginal_u_given_equity) #2
print("E(U(Y)|X=debt)=", e_u_given_x_debt) #2
print("E(U(Y)|X=equity)=", e_u_given_x_equity) #2
int_model_x_debt = do(model, {"X": "debt"}) #3
infer_debt = VariableElimination(int_model_x_debt) #3
marginal_u_given_debt = infer_debt.query(variables=['U']) #3
expectation_u_given_debt = get_expectation(marginal_u_given_debt) #3
print("E(U(Y_{X=debt}))=", expectation_u_given_debt) #3
int_model_x_equity = do(model, {"X": "equity"}) #3
infer_equity = VariableElimination(int_model_x_equity) #3
marginal_u_given_equity = infer_equity.query(variables=['U']) #3
expectation_u_given_equity = get_expectation(marginal_u_given_equity) #3
print("E(U(Y_{X=equity}))=", expectation_u_given_equity) #3
Use the implementation listing to calculate both conditional and interventional utility expectations in pgmpy. section 12.2.4
