causal_testing.discovery.nsga_discovery
This module implements a multiobjective discovery algorithm in terms of test outcomes.
Module Contents
Classes
Multiobjective evolution of cauasl DAGs via NSGA2. |
- class causal_testing.discovery.nsga_discovery.NSGADiscovery(df: pandas.DataFrame, random_seed: int = 0, include_edges: str = None, exclude_edges: str = None, alpha: float = 0.05, max_iterations: int = 100, num_parents_mating: int = 2, population_size: int = 5)
Bases:
causal_testing.discovery.abstract_discovery.DiscoveryMultiobjective evolution of cauasl DAGs via NSGA2. Attempts to optimise the number of passing tests, where each possible relationship is a “feature”.
- binary_string_to_causal_dag(individual: numpy.array) causal_testing.specification.causal_dag.CausalDAG
Converts a binary string representation of a causal DAG to a CausalDAG object.
- Parameters:
individual – Bitstring of the same length as possible_edges such that 1 at position i represents
possible_edges[i] being an edge in the graph and 0 represents it not being. :returns: The converted CausalDAG instance.
- causal_dag_to_binary_string(causal_dag: causal_testing.specification.causal_dag.CausalDAG) numpy.array
Converts a CausalDAG to a binary string representation.
- Parameters:
causal_dag – The CausalDAG to convert.
- Returns:
The converted binary string such that 1 at position i represents possible_edges[i] being an edge in the graph and 0 represents it not being.
- multi_objective_fitness(ga_instance: pygad.GA, individual: numpy.array, individual_inx: int) numpy.array
Remove cycles and calculate the multi-objective fitness of the resulting causal DAG in terms of tests passing failing, and being inestimable. NOTE: this is in terms of the number of possible (X, Y) relationships rather than edges, so is not order dependent. I.e. (X, Y) and (Y, X) are the same. This stops the algorithm optimising for independences, which get two tests (one in each direction).
- Parameters:
ga_instance – The calling GA instance. NOT USED - required for compatibility.
individual – The individual to evaluate.
individual_inx – The index of the individual in the population. NOT USED - required for compatibility.
- Returns:
Numeric numpy array representing the outcome of each test.
- discover() causal_testing.specification.causal_dag.CausalDAG
Discover the causal DAG.
- Returns:
The inferred causal DAG.