citk.tests package

This package contains the implementations of various conditional independence tests.

Partial Correlation Tests

class citk.tests.partial_correlation_tests.FisherZ(data: ndarray, **kwargs)

Bases: CITKTest

This class is a wrapper around the fisherz test from the causal-learn library.

Parameters:

data (np.ndarray) – The dataset from which to run the test.

supported_dtypes = {'continuous'}
class citk.tests.partial_correlation_tests.Spearman(data: ndarray, **kwargs)

Bases: CITKTest

This class is a wrapper around the fisherz test from the causal-learn library on ranked data.

Parameters:

data (np.ndarray) – The dataset from which to run the test.

supported_dtypes = {'continuous'}

Contingency Table Tests

class citk.tests.contingency_table_tests.GSq(data, **kwargs)

Bases: CITKTest

This class is a wrapper around the gsq test from the causal-learn library.

Parameters:

data (np.ndarray) – The dataset from which to run the test.

supported_dtypes = {'discrete'}
class citk.tests.contingency_table_tests.ChiSq(data, **kwargs)

Bases: CITKTest

This class is a wrapper around the chisq test from the causal-learn library.

Parameters:

data (np.ndarray) – The dataset from which to run the test.

supported_dtypes = {'discrete'}

Regression-Based Tests

class citk.tests.regression_tests.RegressionCI(data: ndarray, **kwargs)

Bases: _TigramiteBase

class_candidates: List[str] = ['tigramite.independence_tests.regressionCI.RegressionCI']
method_name = 'regci'

Nearest Neighbor Tests

class citk.tests.nearest_neighbor_tests.CMIknn(data: ndarray, **kwargs)

Bases: _TigramiteBase

class_candidates: List[str] = ['tigramite.independence_tests.cmiknn.CMIknn']
method_name = 'cmiknn'
class citk.tests.nearest_neighbor_tests.CMIknnMixed(data: ndarray, **kwargs)

Bases: _TigramiteBase

class_candidates: List[str] = ['tigramite.independence_tests.cmiknn.CMIknnMixed', 'tigramite.independence_tests.cmiknn_mixed.CMIknnMixed']
method_name = 'cmiknn_mixed'
class citk.tests.nearest_neighbor_tests.MCMIknn(data: ndarray, **kwargs)

Bases: CITKTest

supported_dtypes = {'continuous', 'discrete'}

Kernel Tests

class citk.tests.kernel_tests.KCI(data, **kwargs)

Bases: CITKTest

Wrapper for the Kernel Conditional Independence (KCI) test from the causal-learn library.

Parameters:
  • data (np.ndarray) – The dataset from which to run the test.

  • **kwargs (dict) – Additional keywords for the KCI test. See causal-learn documentation.

supported_dtypes = {'continuous'}
class citk.tests.kernel_tests.RCoT(data: ndarray, **kwargs)

Bases: _RCITBase

method_name = 'rcot'
rcit_func_name = 'RCoT'
class citk.tests.kernel_tests.RCIT(data: ndarray, **kwargs)

Bases: _RCITBase

method_name = 'rcit'
rcit_func_name = 'RCIT'

ML-Based Tests

class citk.tests.ml_based_tests.RandomForest(data: ndarray, **kwargs)

Bases: CITKTest

Performs a conditional independence test using Random Forest feature importance.

Parameters:
  • data (np.ndarray) – The dataset from which to run the test.

  • n_estimators (int, optional) – The number of trees in the forest.

  • num_permutations (int, optional) – The number of permutations to perform for the permutation test.

  • random_state (int, optional) – Seed for the random number generator for reproducibility.

supported_dtypes = {'continuous', 'discrete'}
class citk.tests.ml_based_tests.GCMLinear(data: ndarray, **kwargs)

Bases: CITKTest

supported_dtypes = {'continuous'}
class citk.tests.ml_based_tests.GCMRF(data: ndarray, **kwargs)

Bases: CITKTest

supported_dtypes = {'continuous'}
class citk.tests.ml_based_tests.WGCMRF(data: ndarray, **kwargs)

Bases: CITKTest

supported_dtypes = {'continuous'}
class citk.tests.ml_based_tests.DML(data: ndarray, **kwargs)

Bases: CITKTest

Double-ML based conditional independence test.

Parameters:
  • data (np.ndarray) – The dataset from which to run the test.

  • model (scikit-learn compatible regressor, optional) – The model used to predict X from Z and Y from Z. Defaults to HistGradientBoostingRegressor.

  • cv_folds (int, optional) – The number of folds for cross-fitting.

  • n_perms (int, optional) – Deprecated. Kept for backward compatibility.

supported_dtypes = {'continuous'}
class citk.tests.ml_based_tests.CRIT(data: ndarray, **kwargs)

Bases: CITKTest

Conformalized Residual Independence Test (CRIT).

Parameters:
  • data (np.ndarray) – The dataset from which to run the test.

  • alpha (float, optional) – The significance level for the conformal prediction intervals.

  • cv_folds (int, optional) – The number of folds for cross-fitting.

  • n_perms (int, optional) – Deprecated. Kept for backward compatibility.

supported_dtypes = {'continuous'}
class citk.tests.ml_based_tests.EDML(data: ndarray, **kwargs)

Bases: CITKTest

E-Value Double-ML based conditional independence test.

Parameters:
  • data (np.ndarray) – The dataset from which to run the test.

  • model (scikit-learn compatible regressor, optional) – The model used to predict X from Z and Y from Z. Defaults to HistGradientBoostingRegressor.

  • cv_folds (int, optional) – The number of folds for cross-fitting the residual models.

  • betting_folds (int, optional) – The number of folds for the e-value betting mechanism.

supported_dtypes = {'continuous'}

Adapter Tests

class citk.tests.adapter_tests.DiscChiSq(data: ndarray, **kwargs)

Bases: CITKTest

supported_dtypes = {'continuous', 'discrete'}
class citk.tests.adapter_tests.DiscGSq(data: ndarray, **kwargs)

Bases: CITKTest

supported_dtypes = {'continuous', 'discrete'}
class citk.tests.adapter_tests.DummyFisherZ(data: ndarray, **kwargs)

Bases: CITKTest

supported_dtypes = {'continuous', 'discrete'}
class citk.tests.adapter_tests.HarteminkChiSq(data: ndarray, **kwargs)

Bases: CITKTest

supported_dtypes = {'continuous', 'discrete'}
class citk.tests.external_repo_tests.DCT(data: ndarray, **kwargs)

Bases: CITKTest

supported_dtypes = {'continuous', 'discrete'}