ananke.identification

ananke.identification.missing_id

Class for missing ID

class ananke.identification.missing_id.MissingFullID(graph)[source]

Bases: object

id()[source]

Function to ID the full law

Returns

boolean is ID or not

ananke.identification.one_line

Class for one line ID algorithms.

exception ananke.identification.one_line.NotIdentifiedError[source]

Bases: Exception

Custom error for when desired functional is not identified.

class ananke.identification.one_line.OneLineAID(graph, treatments, outcomes)[source]

Bases: object

functional(experiments)[source]

Creates a string representing the identifying functional

Parameters

experiments – A list of sets denoting the interventions of the available experimental distributions

Returns

id(experiments)[source]

Checks if identification query is identified given the set of experimental distributions.

Parameters

experiments – a list of ADMG objects in which intervened variables are fixed.

class ananke.identification.one_line.OneLineGID(graph, treatments, outcomes)[source]

Bases: ananke.identification.one_line.OneLineAID

id(experiments=[])[source]

Checks if identification query is identified given the set of experimental distributions.

Parameters

experiments – A list of ADMG objects denoting the interventions of the available experimental distributions.

Returns

boolean indicating if query is ID or not.

class ananke.identification.one_line.OneLineID(graph, treatments, outcomes)[source]

Bases: object

draw_swig(direction=None)[source]

Draw the proper SWIG corresponding to the causal query.

Returns

dot language representation of the SWIG.

export_intermediates(folder='intermediates')[source]

Export intermediate CADMGs obtained during fixing.

Parameters

folder – string specifying path to folder where the files will be written.

Returns

None.

functional()[source]

Creates and returns a string for identifying functional.

Returns

string representing the identifying functional.

id()[source]

Run one line ID for the query.

Returns

boolean that is True if p(Y(a)) is ID, else False.

ananke.identification.one_line.assert_valid_witness(net_1: Union[pgmpy.models.BayesianNetwork.BayesianNetwork, ananke.models.bayesian_network.BayesianNetwork], net_2: Union[pgmpy.models.BayesianNetwork.BayesianNetwork, ananke.models.bayesian_network.BayesianNetwork], observed_variables: list, treatment_dict: dict, outcome_variables=None)[source]

Asserts that two BayesianNetwork objects represent a valid witness for identification, meaning that the two Bayesian networks agree on the marginal distribution over observed_variables but disagree in at least one part of the counterfactual distribution for outcome_variables under the intervention specified by treatment_dict.

Parameters
  • net_1 – The first BayesianNetwork object

  • net_2 – The second BayesianNetwork object

  • observed_variables – A list of variables for the observed margin

  • treatment_dict – A dictionary of treatment variables and values

  • outcome_variables – An optional list of outcome variables. If left unspecified, then it is

all variables in observed_variables except those in treatment_dict.

ananke.identification.one_line.check_experiments_ancestral(admg, experiments)[source]

Check that each experiment G(S(b_i)) is ancestral in ADMG G(V(b_i)) https://simpleflying.com/

Parameters
  • admg – An ADMG

  • experiments – A list of ADMGs representing experiments

Returns

ananke.identification.one_line.check_experiments_conform_to_gid(admg, experiments)[source]
ananke.identification.one_line.get_allowed_intrinsic_sets(experiments)[source]
ananke.identification.one_line.get_required_intrinsic_sets(admg)[source]
ananke.identification.one_line.powerset([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)[source]

ananke.identification.opt_adjust

Optimal adjustment sets finding

class ananke.identification.opt_adjust.OptAdjustment(graph)[source]

Bases: object

generate_opt_adjustment_set(vertex1, vertex2)[source]

Fits the binary nested model. Let N the number of observations, M the number of variables.

Parameters
  • self – DAG

  • vertex1 – inference from vertex1, say treatment

  • vertex2 – inference to vertex2, say outcome

ananke.identification.opt_adjust.get_min_set(G, input, vertex1, vertex2)[source]

function for minimal set

Parameters
  • G – DAG

  • input – optimal set found using get_opt_set function

  • vertex1 – inference from vertex1, say treatment

  • vertex2 – inference to vertex2, say outcome

ananke.identification.opt_adjust.get_opt_set(G, vertex1, vertex2)[source]

function to get the optimal set from two vertices

Parameters
  • G – the graph

  • vertex1 – inference from vertex1, say treatment

  • vertex2 – inference to vertex2, say outcome

ananke.identification.opt_adjust.get_opt_set_from_set(G, node_set1, node_set2)[source]

function to get the optimal set from two vertices sets

Parameters
  • G – the graph

  • node_set1 – set of inference from

  • node_set2 – set of inference to

ananke.identification.oracle

ananke.identification.oracle.compute_effect_from_discrete_model(net, treatment_dict, outcome_dict, conditioning_dict=None)[source]

Compute the causal effect by directly performing an intervention in a Bayesian Network corresponding to the true structural equation model to obtain the counterfactual distribution, and then computing the marginal distribution of the outcome. Note that this function does not consider issues of identification as interventions are performed in the true model (regardless if those interventions were identified).

Parameters
  • net – A Bayesian Network representing the causal problem. Note that this object is used only as a representation of the observed data distribution.

  • treatment_dict – Dictionary of treatment variables to treatment values.

  • outcome_dict – Dictionary of outcome variables to outcome values.