Class ClFisherZPython
java.lang.Object
edu.cmu.tetrad.algcomparison.independence.ClFisherZPython
- All Implemented Interfaces:
IndependenceWrapper, HasParameters, TetradSerializable, Serializable
@TestOfIndependence(name="Fisher Z, Causal Learn (Python)",
command="fisherz-cl-test",
dataType=Continuous)
@General
public class ClFisherZPython
extends Object
implements IndependenceWrapper
An
IndependenceWrapper that runs the Fisher Z conditional independence test
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/fisherz_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/fisherz_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 Fisher Z 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).
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 a list of parameter names required for the Python-based independence test.getTest(DataModel dataModel, Parameters parameters) Retrieves an independence test based on the provided data model and parameters.
-
Constructor Details
-
ClFisherZPython
public ClFisherZPython()Default constructor for the ClFisherZPython class. This constructor initializes an instance of the ClFisherZPython class, which serves as a wrapper and utility for performing independence tests using Python-based methods. It does not take any parameters or perform any custom initialization logic.
-
-
Method Details
-
getTest
Retrieves an independence test based on the provided data model and parameters. The method specifically requires a continuousDataSetand utilizes a Python-based process to perform the independence test.- Specified by:
getTestin interfaceIndependenceWrapper- Parameters:
dataModel- the input data model, must be an instance ofDataSetparameters- an optional collection of configuration parameters, used to customize the Python executable path, server script location, alpha threshold, and verbosity settings- 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, "FisherZ-CL (Python)"
-
getDataType
Retrieves the data type associated with the test.- Specified by:
getDataTypein interfaceIndependenceWrapper- Returns:
- the data type of the test, which is
DataType.Continuous
-
getParameters
Retrieves a list of parameter names required for the Python-based independence test.- Specified by:
getParametersin interfaceHasParameters- Specified by:
getParametersin interfaceIndependenceWrapper- Returns:
- a list of parameter names as strings, including: ALPHA, PYTHON_EXE, PYTHON_CI_SERVER, and VERBOSE.
-