causal_testing.surrogate.causal_surrogate_assisted
Module containing classes to define and run causal surrogate assisted test cases
Module Contents
Classes
Data class holding the data and result metadata of a simulation |
|
Class to be inherited with the search algorithm consisting of a search function and the fitness function of the |
|
Class to be inherited with Simulator specific functions to start, shutdown and run the simulation with the give |
|
A class representing a single causal surrogate assisted test case. |
Attributes
- causal_testing.surrogate.causal_surrogate_assisted.logger
- class causal_testing.surrogate.causal_surrogate_assisted.SimulationResult
Data class holding the data and result metadata of a simulation
- data: dict
- fault: bool
- relationship: str
- to_dataframe() pandas.DataFrame
Convert the simulation result data to a pandas DataFrame
- class causal_testing.surrogate.causal_surrogate_assisted.SearchAlgorithm
Bases:
abc.ABCClass to be inherited with the search algorithm consisting of a search function and the fitness function of the space to be searched
- abstract search(surrogate_models: list[causal_testing.estimation.cubic_spline_estimator.CubicSplineRegressionEstimator], scenario: causal_testing.specification.scenario.Scenario) list
Function which implements a search routine which searches for the optimal fitness value for the specified scenario :param surrogate_models: The surrogate models to be searched :param scenario: The modelling scenario
- class causal_testing.surrogate.causal_surrogate_assisted.Simulator
Bases:
abc.ABCClass to be inherited with Simulator specific functions to start, shutdown and run the simulation with the give config file
- abstract startup(**kwargs)
Function that when run, initialises and opens the Simulator
- abstract shutdown(**kwargs)
Function to safely exit and shutdown the Simulator
- abstract run_with_config(configuration: dict) SimulationResult
Run the simulator with the given configuration and return the results in the structure of a SimulationResult :param configuration: The configuration required to initialise the Simulation :return: Simulation results in the structure of the SimulationResult data class
- class causal_testing.surrogate.causal_surrogate_assisted.CausalSurrogateAssistedTestCase(scenario: causal_testing.specification.scenario.Scenario, causal_dag: causal_testing.specification.causal_dag.CausalDAG, search_algorithm: SearchAlgorithm, simulator: Simulator)
A class representing a single causal surrogate assisted test case.
- execute(df: pandas.DataFrame, max_executions: int = 200, custom_data_aggregator: Callable[[dict, dict], dict] = None)
For this specific test case, a search algorithm is used to find the most contradictory point in the input space which is, therefore, most likely to indicate incorrect behaviour. This cadidate test case is run against the simulator, checked for faults and the result returned. :param df: An dataframe which contains data relevant to the specified scenario :param max_executions: Maximum number of simulator executions before exiting the search :param custom_data_aggregator: :return: tuple containing SimulationResult or str, execution number and dataframe
- generate_surrogates(df: pandas.DataFrame) list[causal_testing.estimation.cubic_spline_estimator.CubicSplineRegressionEstimator]
Generate a surrogate model for each edge of the DAG that specifies it is included in the DAG metadata. :param df: An dataframe which contains data relevant to the specified scenario :return: A list of surrogate models