Class ProcessPythonCiService
java.lang.Object
edu.cmu.tetrad.search.test.ProcessPythonCiService
- All Implemented Interfaces:
PythonCiService, Closeable, AutoCloseable
Spawns a persistent Python process running kci_server.py and communicates using JSONL over stdin/stdout.
Intended for experimentation / profiling, not a hardened production transport.
-
Constructor Summary
ConstructorsConstructorDescriptionProcessPythonCiService(String pythonExe, String serverScriptPath) Constructor for ProcessPythonCiService, which sets up the Python executable and the server script path for the service. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidPrepares the service for operation if it has not been initialized yet.doublepValue(int xIndex, int yIndex, int[] zIndices, double alpha) Computes the p-value for a conditional independence test based on the specified variables and parameters.voidsetVerbose(boolean verbose) Sets the verbosity mode for the service.voidupdateParams(Map<String, Object> kciParams) Updates the parameters for the service with the provided map of key-value pairs.
-
Constructor Details
-
ProcessPythonCiService
Constructor for ProcessPythonCiService, which sets up the Python executable and the server script path for the service.- Parameters:
pythonExe- the path to the Python executable. Must nojt be null or empty.serverScriptPath- the path to the Python server script. Must not be null or empty.- Throws:
NullPointerException- if eitherpythonExeorserverScriptPathis null.IllegalArgumentException- if eitherpythonExeorserverScriptPathis empty.
-
-
Method Details
-
setVerbose
public void setVerbose(boolean verbose) Description copied from interface:PythonCiServiceSets the verbosity mode for the service. When verbosity is enabled, additional logs or debug information may be emitted to assist in tracking the execution flow or diagnosing issues.- Specified by:
setVerbosein interfacePythonCiService- Parameters:
verbose- a boolean flag indicating whether to enable or disable verbosity. If true, verbose output is enabled; if false, it is disabled.
-
initializeIfNeeded
Description copied from interface:PythonCiServicePrepares the service for operation if it has not been initialized yet. This method ensures that the necessary state, resources, or configurations are set up based on the provided dataset, variable list, and parameters.- Specified by:
initializeIfNeededin interfacePythonCiService- Parameters:
data- the dataset on which the service operates, containing the data required for conditional independence tests.vars- the list of variables (nodes) relevant to the operations, representing the context in which tests or analyses are conducted.kciParams- a map of configuration parameters used to customize the initialization, such as specific settings for the Python backend or statistical operations.
-
updateParams
Description copied from interface:PythonCiServiceUpdates the parameters for the service with the provided map of key-value pairs. This method allows customization or reconfiguration of the service at runtime by changing its operational parameters.- Specified by:
updateParamsin interfacePythonCiService- Parameters:
kciParams- a map containing key-value pairs representing the parameters to be updated. Each key is a string identifying the parameter, and the associated value determines the new configuration or setting to be applied.
-
pValue
public double pValue(int xIndex, int yIndex, int[] zIndices, double alpha) Description copied from interface:PythonCiServiceComputes the p-value for a conditional independence test based on the specified variables and parameters. The method evaluates whether the variables indexed by xIndex and yIndex are conditionally independent given the variables indexed by zIndices.- Specified by:
pValuein interfacePythonCiService- Parameters:
xIndex- the index of the first variable in the conditional independence test.yIndex- the index of the second variable in the conditional independence test.zIndices- an array of indices representing the conditioning set of variables.alpha- the significance level used for the test, helping to determine the threshold for rejecting the null hypothesis of independence.- Returns:
- a double representing the p-value of the conditional independence test. A smaller p-value indicates stronger evidence against the null hypothesis of independence.
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-