# Causal Structures - Intervention-Prediction#

```
[1]:
```

```
%%capture
# execute the creation & training notebook first
%run "02-02-prediction.ipynb"
```

In the prediction section made prediction based on our trained causal structure. The `prediction`

method propagates information to all directions. This is correct from an information theoretical point of view. An observation of a certain parameter can contain information about all other parameters.

The `InterventionPredictor`

, that can be applied by calling the `predict_interventions`

method of the `CausalStructure`

, distinguishes between interventions and observations by applying the Do calculus for causal models. Information from parameters that are subject to an intervention can only propagate forwards in the causal model.

We can observe this difference when making intervention predictions given the parameter “(b|a)”. This parameter depends on “(a)” and influences “(c|a,b)”. In that sense it is both input and output.

```
[2]:
```

```
causal_structure
```

```
[2]:
```

```
CausalStructure([({'(a)'}, '(b|a)'),
(set(), '(a)'),
({'(a)', '(b|a)'}, '(c|a,b)')])
```

With neither observations nor interventions we just get the learned mean values.

```
[3]:
```

```
causal_structure.predict_interventions(data={}, interventions={})
```

```
[3]:
```

(a) | (b|a) | (c|a,b) | |
---|---|---|---|

0 | 4.989583 | -24.723056 | 40.030782 |

With the observation b=0 we see that both the predicted values for “(a)” and “(c|a,b)” change, since observational information travels forwards and backwards.

```
[4]:
```

```
causal_structure.predict_interventions(data={"(b|a)": [0]}, interventions={})
```

```
[4]:
```

(a) | (b|a) | (c|a,b) | |
---|---|---|---|

0 | 4.526823 | 0.0 | 47.290798 |

With the intervention b=0 we see that only “(c|a,b)” changes, since interventional information only travels forwards. The predicted values for “(c|a,b)” also changed because “(c|a,b)” also depends on “(a)” (and therefore its estimate).

```
[5]:
```

```
causal_structure.predict_interventions(data={}, interventions={"(b|a)": [0]})
```

```
[5]:
```

(a) | (b|a) | (c|a,b) | |
---|---|---|---|

0 | 4.989583 | 0.0 | 51.021084 |

In the next section we will evaluate the causal structures predictive performance.