citests.tests.kernel_tests

Kernel CI tests (survey family): KCI, RCIT, RCoT.

  • KCI wraps causal-learn’s KCI implementation; available only with the optional [causallearn] extra.

  • RCIT and RCoT are randomized kernel CI tests from the R RCIT package (Strobl et al., 2019); require the [r] extra and the R RCIT package installed in your R environment.

Classes

KCI

Kernel Conditional Independence (KCI) test, wrapping causal-learn.

RCIT

Abstract base class for all conditional independence tests in citests.

RCoT

Abstract base class for all conditional independence tests in citests.

Module Contents

class citests.tests.kernel_tests.KCI(data: numpy.ndarray, **kwargs: Any)

Bases: citests.tests.base.CITKTest

Kernel Conditional Independence (KCI) test, wrapping causal-learn.

Initialise the test and (optionally) load a JSON p-value cache.

Parameters:
  • data – Sample matrix in shape (n, p).

  • cache_path – Optional path to a JSON cache file used to memoise p-values across calls. The cache is keyed by (data_hash, method_name, parameters_hash) and stamped with format_version so v0.1.0 caches can be detected and invalidated by future releases.

Raises:

TypeError – If kwargs contains keys outside cls.accepted_kwargs and cls._protocol_kwargs.

kci_instance
supported_dtypes
class citests.tests.kernel_tests.RCIT(data: numpy.ndarray, **kwargs: Any)[source]

Bases: _RCITBase

Abstract base class for all conditional independence tests in citests.

Standalone — does not inherit from causal-learn. Subclasses implement _compute() and use the inherited __call__() for caching.

Conforms to the structural cbcd.CITest Protocol (see n_vars and details()), so any citests test instance can be passed straight to a cbcd algorithm: cbcd.pc(data, ci_test=cit).

Initialise the test and (optionally) load a JSON p-value cache.

Parameters:
  • data – Sample matrix in shape (n, p).

  • cache_path – Optional path to a JSON cache file used to memoise p-values across calls. The cache is keyed by (data_hash, method_name, parameters_hash) and stamped with format_version so v0.1.0 caches can be detected and invalidated by future releases.

Raises:

TypeError – If kwargs contains keys outside cls.accepted_kwargs and cls._protocol_kwargs.

method_name = 'rcit'
rcit_func_name = 'RCIT'
class citests.tests.kernel_tests.RCoT(data: numpy.ndarray, **kwargs: Any)[source]

Bases: _RCITBase

Abstract base class for all conditional independence tests in citests.

Standalone — does not inherit from causal-learn. Subclasses implement _compute() and use the inherited __call__() for caching.

Conforms to the structural cbcd.CITest Protocol (see n_vars and details()), so any citests test instance can be passed straight to a cbcd algorithm: cbcd.pc(data, ci_test=cit).

Initialise the test and (optionally) load a JSON p-value cache.

Parameters:
  • data – Sample matrix in shape (n, p).

  • cache_path – Optional path to a JSON cache file used to memoise p-values across calls. The cache is keyed by (data_hash, method_name, parameters_hash) and stamped with format_version so v0.1.0 caches can be detected and invalidated by future releases.

Raises:

TypeError – If kwargs contains keys outside cls.accepted_kwargs and cls._protocol_kwargs.

method_name = 'rcot'
rcit_func_name = 'RCoT'