causal_testing.testing.causal_effect

This module contains the CausalEffect abstract class, as well as the concrete extension classes: ExactValue, Positive, Negative, SomeEffect, NoEffect

Module Contents

Classes

CausalEffect

An abstract class representing an expected causal effect.

SomeEffect

An extension of CausalEffect representing that the expected causal effect should not be zero.

NoEffect

An extension of CausalEffect representing that the expected causal effect should be zero.

ExactValue

An extension of CausalEffect representing that the expected causal effect should be a specific value.

Positive

An extension of CausalEffect representing that the expected causal effect should be positive.

Negative

An extension of CausalEffect representing that the expected causal effect should be negative.

class causal_testing.testing.causal_effect.CausalEffect(effect_type: str = 'direct')

Bases: abc.ABC

An abstract class representing an expected causal effect.

abstract apply(effect_estimate: causal_testing.estimation.effect_estimate.EffectEstimate) → bool

Abstract apply method that should return a bool representing if the result meets the outcome :param effect_estimate: EffectEstimate to be checked :return: Bool that is true if outcome is met

__str__() → str

Return str(self).

to_dict()

Convert the expected effect to a python dictionary for easy serialisation as JSON.

Returns:

A JSON serialisable dict representing the expected effect.

class causal_testing.testing.causal_effect.SomeEffect(effect_type: str = 'direct')

Bases: CausalEffect

An extension of CausalEffect representing that the expected causal effect should not be zero.

apply(effect_estimate: causal_testing.estimation.effect_estimate.EffectEstimate) → bool

Abstract apply method that should return a bool representing if the result meets the outcome :param effect_estimate: EffectEstimate to be checked :return: Bool that is true if outcome is met

class causal_testing.testing.causal_effect.NoEffect(effect_type: str = 'direct', atol: float = 0, ctol: float = 0.0)

Bases: CausalEffect

An extension of CausalEffect representing that the expected causal effect should be zero. :param atol: Arithmetic tolerance. The test will pass if the absolute value of the causal effect is less than atol. :param ctol: Categorical tolerance. The test will pass if this proportion of categories pass.

apply(effect_estimate: causal_testing.estimation.effect_estimate.EffectEstimate) → bool

Abstract apply method that should return a bool representing if the result meets the outcome :param effect_estimate: EffectEstimate to be checked :return: Bool that is true if outcome is met

to_dict()

Convert the expected effect to a python dictionary for easy serialisation as JSON.

Returns:

A JSON serialisable dict representing the expected effect.

class causal_testing.testing.causal_effect.ExactValue(value: float, effect_type: str = 'direct', atol: float = 0, ci_low: float = None, ci_high: float = None)

Bases: CausalEffect

An extension of CausalEffect representing that the expected causal effect should be a specific value.

apply(effect_estimate: causal_testing.estimation.effect_estimate.EffectEstimate) → bool

Abstract apply method that should return a bool representing if the result meets the outcome :param effect_estimate: EffectEstimate to be checked :return: Bool that is true if outcome is met

__str__()

Return str(self).

to_dict()

Convert the expected effect to a python dictionary for easy serialisation as JSON or CSV.

Returns:

A JSON serialisable dict representing the expected effect.

class causal_testing.testing.causal_effect.Positive(effect_type: str = 'direct')

Bases: SomeEffect

An extension of CausalEffect representing that the expected causal effect should be positive. Currently only single values are supported for the test value

apply(effect_estimate: causal_testing.estimation.effect_estimate.EffectEstimate) → bool

Abstract apply method that should return a bool representing if the result meets the outcome :param effect_estimate: EffectEstimate to be checked :return: Bool that is true if outcome is met

class causal_testing.testing.causal_effect.Negative(effect_type: str = 'direct')

Bases: SomeEffect

An extension of CausalEffect representing that the expected causal effect should be negative. Currently only single values are supported for the test value

apply(effect_estimate: causal_testing.estimation.effect_estimate.EffectEstimate) → bool

Abstract apply method that should return a bool representing if the result meets the outcome :param effect_estimate: EffectEstimate to be checked :return: Bool that is true if outcome is met