:py:mod:`causal_testing.discovery.nsga_discovery` ================================================= .. py:module:: causal_testing.discovery.nsga_discovery .. autoapi-nested-parse:: This module implements a multiobjective discovery algorithm in terms of test outcomes. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: causal_testing.discovery.nsga_discovery.NSGADiscovery .. py:class:: 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: :py:obj:`causal_testing.discovery.abstract_discovery.Discovery` Multiobjective evolution of cauasl DAGs via NSGA2. Attempts to optimise the number of passing tests, where each possible relationship is a "feature". .. py:method:: 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. :param 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. .. py:method:: causal_dag_to_binary_string(causal_dag: causal_testing.specification.causal_dag.CausalDAG) -> numpy.array Converts a CausalDAG to a binary string representation. :param 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. .. py:method:: 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). :param ga_instance: The calling GA instance. NOT USED - required for compatibility. :param individual: The individual to evaluate. :param 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. .. py:method:: discover() -> causal_testing.specification.causal_dag.CausalDAG Discover the causal DAG. :returns: The inferred causal DAG.