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 = 30, 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.

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(individual: causal_testing.specification.causal_dag.CausalDAG = None) → causal_testing.specification.causal_dag.CausalDAG

Discover the causal DAG.

Parameters:

individual – An initial individual for the hill climber to start from (defaults to a fully connected graph).

Returns:

The inferred causal DAG.