causal_testing.discovery.hill_climber_discovery

This module implements a hill climbing algorithm to optimise causal DAGs based on the tests that pass/fail.

Module Contents

Classes

HillClimberDiscovery

Simple hill climber evolution of cauasl DAGs via 1+1EA.

class causal_testing.discovery.hill_climber_discovery.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: 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.

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.

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)

Parameters:

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.

discover() causal_testing.specification.causal_dag.CausalDAG

Discover the causal DAG.

Returns:

The inferred causal DAG.