The do_operation function#
Aliases#
halerium.core.do_operation
halerium.core.causal_calculus.do_operation
- do_operation(scopetor, variables, inplace=False, strict=True)#
Perform Do operation of variable(s) in scopetor.
Do operations are required to accurately model interventions.
The Do operation cuts all dependencies the variables have by setting all of the distribution parameters to None. This way values that are fed to the variable as data can only propagate forwards in the dependency structure.
- Parameters:
scopetor (Scopetor (Graph, Entity, Variable)) – The scopetor in which the Do operation is applied. Must be a top-level scopetor, i.e. a scopetor without a parent scope.
variables (VariableBase, str or iterable) – The variable(s) to which the Do operation is applied. If the variable(s) are not scopees in scopetor, their equivalents in scopetor will be located and the do operation will be applied to the equivalents instead.
inplace (bool, optional) – Whether or not to modify scopetor (True) or to leave scopetor unchanged and return a modified copy (False). The default is False.
strict (bool, optional) – Only has an effect if inplace=False. If True the scopetor has to be self-contained. If False not self-contained parts are left out and will be set to None in the copied instance. The default is True.
- Returns:
modified_scopetor – The modified scopetor.
- Return type:
Scopetor