Class ClRcitPython

java.lang.Object
edu.cmu.tetrad.algcomparison.independence.ClRcitPython
All Implemented Interfaces:
IndependenceWrapper, HasParameters, TetradSerializable, Serializable

@TestOfIndependence(name="RCIT, Causal Learn (Python)", command="rcit-cl-test", dataType=Continuous) @General public class ClRcitPython extends Object implements IndependenceWrapper
An IndependenceWrapper that runs the Randomized Conditional Independence Test (RCIT) implemented in the Python causal-learn library, bridging it into Tetrad's IndependenceTest framework.

How it works

Each call to getTest(DataModel, Parameters) launches (or connects to) a persistent Python process running a bundled server script (python/rcit_server.py). CI queries from Java are forwarded to that process via ProcessPythonCiService, and results are returned as standard IndependenceTest responses through PythonRcitIndependenceTest.

Python environment

A Python interpreter that has causal-learn and its dependencies installed must be available on the host machine. The path to that interpreter is supplied via the Params.PYTHON_EXE parameter. There is no default that is likely to be valid on any machine other than the developer's, so this parameter should always be set explicitly before use.

Server script resolution

The Python server script is resolved in the following order:
  1. If Params.PYTHON_CI_SERVER is set to a non-empty path (and not the sentinel value "Use bundled script"), that path is used directly.
  2. Otherwise, the bundled resource python/rcit_server.py is extracted to the user's local cache directory (via PythonResource.extractToUserCache(String, String)) and that extracted copy is used.

Parameters

  • Params.PYTHON_EXE — path to the Python executable (required).
  • Params.PYTHON_CI_SERVER — path to the RCIT server script, or "Use bundled script" to use the packaged default.
  • Params.ALPHA — significance level for the independence test (default: 0.01).
  • Params.VERBOSE — if true, the test logs additional detail during execution (default: false).
  • rcitNumF — number of random Fourier features for the conditioning set Z (default: 100, matching causal-learn's default).
  • rcitNumF2 — number of random Fourier features for X and Y (default: 5, matching causal-learn's default).

Data

Only continuous DataSet inputs are supported. Passing any other DataModel type will throw an IllegalArgumentException.
See Also:
  • Constructor Details

    • ClRcitPython

      public ClRcitPython()
      Default constructor for the ClRcitPython class.
  • Method Details

    • getTest

      public IndependenceTest getTest(DataModel dataModel, Parameters parameters)
      Retrieves an independence test based on the provided data model and parameters.
      Specified by:
      getTest in interface IndependenceWrapper
      Parameters:
      dataModel - the input data model, must be an instance of DataSet
      parameters - configuration parameters
      Returns:
      an instance of IndependenceTest configured with the provided data model and parameters
      Throws:
      IllegalArgumentException - if the provided dataModel is not a continuous DataSet or if required parameters are invalid
      RuntimeException - if the bundled Python server script cannot be extracted
    • getDescription

      public String getDescription()
      Provides a textual description of the test implementation.
      Specified by:
      getDescription in interface IndependenceWrapper
      Returns:
      a string describing the test, "RCIT-CL (Python)"
    • getDataType

      public DataType getDataType()
      Retrieves the data type associated with the test.
      Specified by:
      getDataType in interface IndependenceWrapper
      Returns:
      DataType.Continuous
    • getParameters

      public List<String> getParameters()
      Retrieves the list of parameter names used by this test.
      Specified by:
      getParameters in interface HasParameters
      Specified by:
      getParameters in interface IndependenceWrapper
      Returns:
      list of parameter name strings