dowhy.causal_identifiers package

Submodules

dowhy.causal_identifiers.backdoor module

class dowhy.causal_identifiers.backdoor.Backdoor(graph, nodes1, nodes2)[source]

Bases: object

Class for optimized implementation of Backdoor variable search between the source nodes and the target nodes.

get_backdoor_vars()[source]

Obtains sets of backdoor variable to condition on for each node pair.

Returns

List of sets with each set containing backdoor variable corresponding to a given node pair.

is_backdoor(path)[source]

Check if path is a backdoor path.

Parameters

path – List of nodes comprising the path.

class dowhy.causal_identifiers.backdoor.HittingSetAlgorithm(list_of_sets, colliders={})[source]

Bases: object

Class for the Hitting Set Algorithm to obtain a approximate minimal set of backdoor variables to condition on for each node pair.

Parameters

list_of_sets – List of sets such that each set comprises nodes representing a single backdoor path between a source node and a target node.

find_set()[source]

Find approximate minimal set of nodes such that there is atleast one node from each set in list_of_sets.

Returns

Approximate minimal set of nodes.

num_sets()[source]

Obtain number of backdoor paths between a node pair.

class dowhy.causal_identifiers.backdoor.NodePair(node1, node2)[source]

Bases: object

Data structure to store backdoor variables between 2 nodes.

get_condition_vars()[source]
is_complete()[source]
set_complete()[source]
update(path, condition_vars=None)[source]
class dowhy.causal_identifiers.backdoor.Path[source]

Bases: object

Data structure to store a particular path between 2 nodes.

get_condition_vars()[source]
is_blocked()[source]
update(path, is_blocked)[source]

path is a list

dowhy.causal_identifiers.id_identifier module

class dowhy.causal_identifiers.id_identifier.IDExpression[source]

Bases: object

Class for storing a causal estimand, as a result of the identification step using the ID algorithm. The object stores a list of estimators(self._product) whose porduct must be obtained and a list of variables (self._sum) over which the product must be marginalized.

add_product(element)[source]

Add an estimator to the list of product.

Parameters

element – Estimator to append to the product list.

add_sum(element)[source]

Add variables to the list.

Parameters

element – Set of variables to append to the list self._sum.

get_val(return_type)[source]

Get either the list of estimators (for product) or list of variables (for the marginalization).

Parameters

return_type – “prod” to return the list of estimators or “sum” to return the list of variables.

class dowhy.causal_identifiers.id_identifier.IDIdentifier(graph, estimand_type, method_name='default', proceed_when_unidentifiable=None)[source]

Bases: CausalIdentifier

Class to perform identification using the ID algorithm.

Parameters
  • self – instance of the IDIdentifier class.

  • estimand_type – Type of estimand (“nonparametric-ate”, “nonparametric-nde” or “nonparametric-nie”).

  • method_name – Identification method (“id-algorithm” in this case).

  • proceed_when_unidentifiable – If True, proceed with identification even in the presence of unobserved/missing variables.

identify_effect(treatment_names=None, outcome_names=None, adjacency_matrix=None, node_names=None)[source]

Implementation of the ID algorithm. Link - https://ftp.cs.ucla.edu/pub/stat_ser/shpitser-thesis.pdf The pseudo code has been provided on Pg 40.

Parameters
  • self – instance of the IDIdentifier class.

  • treatment_names – OrderedSet comprising names of treatment variables.

:param outcome_names:OrderedSet comprising names of outcome variables. :param adjacency_matrix: Graph adjacency matrix. :param node_names: OrderedSet comprising names of all nodes in the graph

Returns

target estimand, an instance of the IDExpression class.

Module contents