Counterfactual.counterFactualModel
- static Counterfactual.counterFactualModel(cm, *args)
Build the twin network of Balke and Pearl (see
pyagrum.counterfactualModel).- Parameters:
cm (
pyagrum.CausalModel) – The original causal model.whatif (
setofstr) – Intervened variables in the counterfactual scenario. The former callcounterFactualModel(cm, profile, whatif)is deprecated after 3.3.2: the twin network does not depend on the profile.
- Returns:
The twin network.
- Return type:
- Raises:
pyagrum.InvalidArgument – If the causal model has latent variables, or if the name of a copy is already used.
Warning
counterFactualModel(cm, profile, whatif)is deprecated after 3.3.2, usecounterFactualModel(cm, whatif).
Example
import pyagrum as gum
bn = gum.fastBN("U{low|high}->Y{no|yes}<-X{no|yes}")
cm = gum.CausalModel(bn)
twin = gum.Counterfactual.counterFactualModel(cm, {"X"})
# Y* has the CPT of Y, with X* (no parent, uniform prior) instead of X
sorted(twin.observationalBN().names())
# ['U', 'X', 'X*', 'Y', 'Y*']
Class