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 togetTest(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 hascausal-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:- If
Params.PYTHON_CI_SERVERis set to a non-empty path (and not the sentinel value"Use bundled script"), that path is used directly. - Otherwise, the bundled resource
python/rcit_server.pyis extracted to the user's local cache directory (viaPythonResource.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— iftrue, 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 continuousDataSet inputs are supported. Passing any other
DataModel type will throw an IllegalArgumentException.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the data type associated with the test.Provides a textual description of the test implementation.Retrieves the list of parameter names used by this test.getTest(DataModel dataModel, Parameters parameters) Retrieves an independence test based on the provided data model and parameters.
-
Constructor Details
-
ClRcitPython
public ClRcitPython()Default constructor for the ClRcitPython class.
-
-
Method Details
-
getTest
Retrieves an independence test based on the provided data model and parameters.- Specified by:
getTestin interfaceIndependenceWrapper- Parameters:
dataModel- the input data model, must be an instance ofDataSetparameters- configuration parameters- Returns:
- an instance of
IndependenceTestconfigured with the provided data model and parameters - Throws:
IllegalArgumentException- if the provideddataModelis not a continuousDataSetor if required parameters are invalidRuntimeException- if the bundled Python server script cannot be extracted
-
getDescription
Provides a textual description of the test implementation.- Specified by:
getDescriptionin interfaceIndependenceWrapper- Returns:
- a string describing the test, "RCIT-CL (Python)"
-
getDataType
Retrieves the data type associated with the test.- Specified by:
getDataTypein interfaceIndependenceWrapper- Returns:
DataType.Continuous
-
getParameters
Retrieves the list of parameter names used by this test.- Specified by:
getParametersin interfaceHasParameters- Specified by:
getParametersin interfaceIndependenceWrapper- Returns:
- list of parameter name strings
-