:py:mod:`causal_testing.discovery.hill_climber_discovery` ========================================================= .. py:module:: causal_testing.discovery.hill_climber_discovery .. autoapi-nested-parse:: This module implements a hill climbing algorithm to optimise causal DAGs based on the tests that pass/fail. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: causal_testing.discovery.hill_climber_discovery.HillClimberDiscovery .. py:class:: HillClimberDiscovery(df: pandas.DataFrame, random_seed: int = 0, include_edges: str = None, exclude_edges: str = None, alpha: float = 0.05, max_iterations: int = 100, max_iterations_without_improvement: int = 10) Bases: :py:obj:`causal_testing.discovery.abstract_discovery.Discovery` Simple hill climber evolution of cauasl DAGs via 1+1EA. Attempts to maximise the number of passing tests and minimise the number of failing tests. .. py:method:: sum_test_outcomes(test_results: pandas.DataFrame) -> dict Aggregate the number of passing, failing, and inestimable tests :param test_results: Dataframe containing the raw pass/fail/inestimable outcome of each test case. :returns: Dictionary containing the number of pass/fail/inestimable outcomes. .. py:method:: evaluate_fitness(individual: causal_testing.specification.causal_dag.CausalDAG) -> tuple[tuple[float, float, float], list[tuple[str, str]]] Evaluate the fitness of a given causal DAG by evaluating the corresponding test cases using a tier based fitness metric. lexicographical order (max pass, minimise failure, minimise unknown) e.g. (X pass, Y fail, Z+1 unknown) is better than (X pass, Y+1 fail, Z unknown) :param individual: The candidate individual to evaluate. :returns: Tuple of the form (X, Y), where X is a triple containing the number of passing, failing, and inestimable tests respectively, and Y is a list of failing edges. .. py:method:: discover() -> causal_testing.specification.causal_dag.CausalDAG Discover the causal DAG. :returns: The inferred causal DAG.