Skip to content

Abstract Syntax Tree for Do-Calculus

The pyCausal package compute every causal query into an Abstract Syntax Tree (CausalFormula) that represents the exact computations to be done in order to answer to the probabilistic causal query.

The different types of node in an CausalFormula are presented below and are organized as a hierarchy of classes from pyagrum.causal.ASTtree.

class pyagrum.causal.ASTtree(typ, verbose=False)

Section titled “class pyagrum.causal.ASTtree(typ, verbose=False)”

Represents a generic node for the CausalFormula. The type of the node will be registered in a string.

  • Parameters:
    • typ (str) – the type of the node (will be specified in concrete children classes.
    • verbose (bool) – if True, add some messages

Copy an CausalFormula tree

  • Returns: the new causal tree
  • Return type: ASTtree

Evaluation of a AST tree from inside a BN

  • Parameters: contextual_bn (pyagrum.BayesNet) – the observational Bayesian network in which will be done the computations
  • Returns: the resulting Tensor
  • Return type: pyagrum.Tensor

Internal virtual function to create a LaTeX representation of the ASTtree

  • Parameters: nameOccur (Dict [**str ,**int ]) – the number of occurrence for each variable
  • Returns: LaTeX representation of the tree
  • Return type: str

Create a protected LaTeX representation of a ASTtree

  • Parameters: nameOccur (Dict [**str ,**int ]) – the number of occurrence for each variable
  • Returns: a protected version of LaTeX representation of the tree
  • Return type: str

Create a LaTeX representation of a ASTtree

  • Parameters: nameOccur (Dict [**str ,**int ] default=None) – the number of occurrence for each variable
  • Returns: LaTeX representation of the tree
  • Return type: str
  • Returns: the type of the node
  • Return type: str

class pyagrum.causal.ASTBinaryOp(typ, op1, op2)

Section titled “class pyagrum.causal.ASTBinaryOp(typ, op1, op2)”

Represents a generic binary node for the CausalFormula. The op1 and op2 are the two operands of the class.

  • Parameters:
    • typ (str) – the type of the node (will be specified in concrete children classes
    • op1 (ASTtree) – left operand
    • op2 (ASTtree) – right operand

Copy an CausalFormula tree

  • Returns: the new causal tree
  • Return type: ASTtree

Evaluation of a AST tree from inside a BN

  • Parameters: contextual_bn (pyagrum.BayesNet) – the observational Bayesian network in which will be done the computations
  • Returns: the resulting Tensor
  • Return type: pyagrum.Tensor

Internal virtual function to create a LaTeX representation of the ASTtree

  • Parameters: nameOccur (Dict [**str ,**int ]) – the number of occurrence for each variable
  • Returns: LaTeX representation of the tree
  • Return type: str
  • Returns: the left operand
  • Return type: ASTtree
  • Returns: the right operand
  • Return type: ASTtree

Create a protected LaTeX representation of a ASTtree

  • Parameters: nameOccur (Dict [**str ,**int ]) – the number of occurrence for each variable
  • Returns: a protected version of LaTeX representation of the tree
  • Return type: str

Create a LaTeX representation of a ASTtree

  • Parameters: nameOccur (Dict [**str ,**int ] default=None) – the number of occurrence for each variable
  • Returns: LaTeX representation of the tree
  • Return type: str
  • Returns: the type of the node
  • Return type: str

Represents the sum of 2 causal.ASTtree

  • Parameters:

Copy an CausalFormula tree

  • Returns: the new causal tree
  • Return type: ASTtree

Evaluation of a AST tree from inside a BN

  • Parameters: contextual_bn (pyagrum.BayesNet) – the observational Bayesian network in which will be done the computations
  • Returns: the resulting Tensor
  • Return type: pyagrum.Tensor

Internal virtual function to create a LaTeX representation of the ASTtree

  • Parameters: nameOccur (Dict [**str ,**int ]) – the number of occurrence for each variable
  • Returns: LaTeX representation of the tree
  • Return type: str
  • Returns: the left operand
  • Return type: ASTtree
  • Returns: the right operand
  • Return type: ASTtree

Create a protected LaTeX representation of a ASTtree

  • Parameters: nameOccur (Dict [**str ,**int ]) – the number of occurrence for each variable
  • Returns: a protected version of LaTeX representation of the tree
  • Return type: str

Create a LaTeX representation of a ASTtree

  • Parameters: nameOccur (Dict [**str ,**int ] default=None) – the number of occurrence for each variable
  • Returns: LaTeX representation of the tree
  • Return type: str
  • Returns: the type of the node
  • Return type: str

Represents the substraction of 2 causal.ASTtree

  • Parameters:

Copy an CausalFormula tree

  • Returns: the new causal tree
  • Return type: ASTtree

Evaluation of a AST tree from inside a BN

  • Parameters: contextual_bn (pyagrum.BayesNet) – the observational Bayesian network in which will be done the computations
  • Returns: the resulting Tensor
  • Return type: pyagrum.Tensor

Internal virtual function to create a LaTeX representation of the ASTtree

  • Parameters: nameOccur (Dict [**str ,**int ]) – the number of occurrence for each variable
  • Returns: LaTeX representation of the tree
  • Return type: str
  • Returns: the left operand
  • Return type: ASTtree
  • Returns: the right operand
  • Return type: ASTtree

Create a protected LaTeX representation of a ASTtree

  • Parameters: nameOccur (Dict [**str ,**int ]) – the number of occurrence for each variable
  • Returns: a protected version of LaTeX representation of the tree
  • Return type: str

Create a LaTeX representation of a ASTtree

  • Parameters: nameOccur (Dict [**str ,**int ] default=None) – the number of occurrence for each variable
  • Returns: LaTeX representation of the tree
  • Return type: str
  • Returns: the type of the node
  • Return type: str

Represents the division of 2 causal.ASTtree

  • Parameters:

Copy an CausalFormula tree

  • Returns: the new causal tree
  • Return type: ASTtree

Evaluation of a AST tree from inside a BN

  • Parameters: contextual_bn (pyagrum.BayesNet) – the observational Bayesian network in which will be done the computations
  • Returns: the resulting Tensor
  • Return type: pyagrum.Tensor

Internal virtual function to create a LaTeX representation of the ASTtree

  • Parameters: nameOccur (Dict [**str ,**int ]) – the number of occurrence for each variable
  • Returns: LaTeX representation of the tree
  • Return type: str
  • Returns: the left operand
  • Return type: ASTtree
  • Returns: the right operand
  • Return type: ASTtree

Create a protected LaTeX representation of a ASTtree

  • Parameters: nameOccur (Dict [**str ,**int ]) – the number of occurrence for each variable
  • Returns: a protected version of LaTeX representation of the tree
  • Return type: str

Create a LaTeX representation of a ASTtree

  • Parameters: nameOccur (Dict [**str ,**int ] default=None) – the number of occurrence for each variable
  • Returns: LaTeX representation of the tree
  • Return type: str
  • Returns: the type of the node
  • Return type: str

Represents the multiplication of 2 causal.ASTtree

  • Parameters:

Copy an CausalFormula tree

  • Returns: the new causal tree
  • Return type: ASTtree

Evaluation of a AST tree from inside a BN

  • Parameters: contextual_bn (pyagrum.BayesNet) – the observational Bayesian network in which will be done the computations
  • Returns: the resulting Tensor
  • Return type: pyagrum.Tensor

Internal virtual function to create a LaTeX representation of the ASTtree

  • Parameters: nameOccur (Dict [**str ,**int ]) – the number of occurrence for each variable
  • Returns: LaTeX representation of the tree
  • Return type: str
  • Returns: the left operand
  • Return type: ASTtree
  • Returns: the right operand
  • Return type: ASTtree

Create a protected LaTeX representation of a ASTtree

  • Parameters: nameOccur (Dict [**str ,**int ]) – the number of occurrence for each variable
  • Returns: a protected version of LaTeX representation of the tree
  • Return type: str

Create a LaTeX representation of a ASTtree

  • Parameters: nameOccur (Dict [**str ,**int ] default=None) – the number of occurrence for each variable
  • Returns: LaTeX representation of the tree
  • Return type: str
  • Returns: the type of the node
  • Return type: str

Represents a sum over a variable of a causal.ASTtree.

  • Parameters:
    • var (str) – name of the variable on which to sum
    • term (ASTtree) – the tree to be evaluated

Copy an CausalFormula tree

  • Returns: the new causal tree
  • Return type: ASTtree

Evaluation of a AST tree from inside a BN

  • Parameters: contextual_bn (pyagrum.BayesNet) – the observational Bayesian network in which will be done the computations
  • Returns: the resulting Tensor
  • Return type: pyagrum.Tensor

Internal virtual function to create a LaTeX representation of the ASTtree

  • Parameters: nameOccur (Dict [**str ,**int ]) – the number of occurrence for each variable
  • Returns: LaTeX representation of the tree
  • Return type: str

Create a protected LaTeX representation of a ASTtree

  • Parameters: nameOccur (Dict [**str ,**int ]) – the number of occurrence for each variable
  • Returns: a protected version of LaTeX representation of the tree
  • Return type: str
  • Returns: the term to sum
  • Return type: ASTtree

Create a LaTeX representation of a ASTtree

  • Parameters: nameOccur (Dict [**str ,**int ] default=None) – the number of occurrence for each variable
  • Returns: LaTeX representation of the tree
  • Return type: str
  • Returns: the type of the node
  • Return type: str

class pyagrum.causal.ASTjointProba(varNames)

Section titled “class pyagrum.causal.ASTjointProba(varNames)”

Represent a joint probability in the base observational part of the causal.CausalModel

  • Parameters: varNames (Set [**str ]) – a set of variable names

Copy an CausalFormula tree

  • Returns: the new causal tree
  • Return type: ASTtree

Evaluation of a AST tree from inside a BN

  • Parameters: contextual_bn (pyagrum.BayesNet) – the observational Bayesian network in which will be done the computations
  • Returns: the resulting Tensor
  • Return type: pyagrum.Tensor

Internal virtual function to create a LaTeX representation of the ASTtree

  • Parameters: nameOccur (Dict [**str ,**int ]) – the number of occurrence for each variable
  • Returns: LaTeX representation of the tree
  • Return type: str

Create a protected LaTeX representation of a ASTtree

  • Parameters: nameOccur (Dict [**str ,**int ]) – the number of occurrence for each variable
  • Returns: a protected version of LaTeX representation of the tree
  • Return type: str

Create a LaTeX representation of a ASTtree

  • Parameters: nameOccur (Dict [**str ,**int ] default=None) – the number of occurrence for each variable
  • Returns: LaTeX representation of the tree
  • Return type: str
  • Returns: the type of the node
  • Return type: str
  • Returns: the set of names of var
  • Return type: Set[str]

class pyagrum.causal.ASTposteriorProba(bn, varset, knw)

Section titled “class pyagrum.causal.ASTposteriorProba(bn, varset, knw)”

Represent a conditional probability Pbn(varsknw)P_{bn}(vars|knw) that can be computed by an inference in a BN.

  • Parameters:
    • bn (pyagrum.BayesNet) – the pyAgrum:pyagrum.BayesNet
    • varset (Set [**str ]) – a set of variable names (in the BN) conditioned in the posterior
    • knw (Set [**str ]) – a set of variable names (in the BN) conditioning in the posterior
  • Returns: the observationnal BayesNet in Pbn(varsknw)P_{bn}(vars|knw)
  • Return type: pyagrum.BayesNet

Copy an CausalFormula tree

  • Returns: the new causal tree
  • Return type: ASTtree

Evaluation of a AST tree from inside a BN

  • Parameters: contextual_bn (pyagrum.BayesNet) – the observational Bayesian network in which will be done the computations
  • Returns: the resulting Tensor
  • Return type: pyagrum.Tensor

Internal virtual function to create a LaTeX representation of the ASTtree

  • Parameters: nameOccur (Dict [**str ,**int ]) – the number of occurrence for each variable
  • Returns: LaTeX representation of the tree
  • Return type: str
  • Returns: (Conditioning) knw in Pbn(varsknw)P_{bn}(vars|knw)
  • Return type: Set[str]

Create a protected LaTeX representation of a ASTtree

  • Parameters: nameOccur (Dict [**str ,**int ]) – the number of occurrence for each variable
  • Returns: a protected version of LaTeX representation of the tree
  • Return type: str

Create a LaTeX representation of a ASTtree

  • Parameters: nameOccur (Dict [**str ,**int ] default=None) – the number of occurrence for each variable
  • Returns: LaTeX representation of the tree
  • Return type: str
  • Returns: the type of the node
  • Return type: str
  • Returns: (Conditioned) vars in Pbn(varsknw)P_{bn}(vars|knw)
  • Return type: Set[str]