ETIA.CausalLearning.configurations package

Submodules

ETIA.CausalLearning.configurations.causal_configs module

ETIA.CausalLearning.configurations.ci_tests module

ETIA.CausalLearning.configurations.class_causal_configurator module

class CausalDiscoveryConfigurator[source]

Bases: object

Configurator for creating causal discovery algorithm configurations based on various parameters.

causal_algs

Dictionary of causal discovery algorithms and their parameters.

Type:

dict

ci_tests

Dictionary of conditional independence tests.

Type:

dict

scores

Dictionary of scoring functions.

Type:

dict

create_causal_configs(data_type, causal_sufficiency, assume_faithfulness, time_series, time_lagged, include_algs=None, exclude_algs=None)[source]

Generates a list of configurations for causal discovery algorithms based on input parameters.

create_causal_configs(data_type: str, causal_sufficiency: bool, assume_faithfulness: bool, time_series: bool, time_lagged: bool, include_algs: List[str] | None = None, exclude_algs: List[str] | None = None) Dict[str, Dict][source]

Generates a list of causal discovery algorithm configurations based on input parameters.

Parameters:
  • data_type (str) – Type of data (e.g., ‘continuous’, ‘discrete’, ‘mixed’).

  • causal_sufficiency (bool) – Whether causal sufficiency is assumed in the dataset.

  • assume_faithfulness (bool) – Whether to assume the faithfulness condition.

  • time_series (bool) – Whether the dataset is time-series.

  • time_lagged (bool) – Whether time-lagged variables are included in the dataset.

  • include_algs (list, optional) – List of specific algorithms to include in the configuration. Default is None.

  • exclude_algs (list, optional) – List of algorithms to exclude from the configuration. Default is None.

Returns:

Dictionary of causal discovery algorithm configurations.

Return type:

dict

ETIA.CausalLearning.configurations.configurations module

class Configurations(dataset: Dataset | None = None, n_lags: int = 0, time_lagged: bool = False, time_series: bool = False, conf_file: str | None = None, n_jobs: int | None = -1, verbose=False)[source]

Bases: object

Configurations class for setting up the causal discovery experiment.

Parameters:
  • dataset (Dataset) – The dataset object.

  • n_lags (int, optional) – Number of lags (for time series).

  • time_lagged (bool, optional) – Indicates if the data is time-lagged.

  • time_series (bool, optional) – Indicates if the dataset is time series data.

  • conf_file (str, optional) – JSON configuration file containing parameters for the causal discovery experiment.

  • n_jobs (int, optional) – Number of jobs to use for parallel processing.

  • verbose (bool, optional) – Whether to print debug information.

cdhpo_params

Parameters for the CDHPO algorithm.

Type:

CDHPOParameters

results_folder

Folder path for storing results.

Type:

str

set_default_configuration()[source]

Set default configurations based on the dataset when no JSON configuration file is provided.

process_conf_file()[source]

Process the JSON file containing all vital information, such as algorithms, algorithm parameters, run mode, etc.

add_configurations_from_file(filename: str) None[source]

Add additional configurations to the experiment from a JSON file.

Parameters:

filename (str) – The filename of the JSON file containing configurations.

ETIA.CausalLearning.configurations.default_parameters module

ETIA.CausalLearning.configurations.parameters module

class MVP_Parameters(protocol_name='KFoldCV', parameters={'folds': 10, 'folds_to_run': 1}, verbose=False)[source]

Bases: object

Class to manage the out-of-sample (OOS) protocol for model validation.

Parameters:
  • protocol_name (str, optional) – The name of the OOS protocol. Default is ‘KFoldCV’.

  • parameters (dict, optional) – Parameters for the chosen OOS protocol. Default is {‘folds’: 10, ‘folds_to_run’: 1}.

  • verbose (bool, optional) – If True, enables detailed logging. Default is False.

protocol_name

Name of the chosen OOS protocol.

Type:

str

protocol

Instance of the chosen OOS protocol.

Type:

object

parameters

Parameters for the OOS protocol.

Type:

dict

__init__(protocol_name='KFoldCV', parameters={'folds': 10, 'folds_to_run': 1}, verbose=False)[source]

Initializes the OOS protocol with the given or default parameters.

class Regressor_parameters(regressor_name='RandomForestRegressor', parameters={'max_depth': 10, 'min_samples_leaf': 0.1, 'n_trees': 100}, verbose=False)[source]

Bases: object

Class to manage the configuration of regressors for the CDHPO process.

Parameters:
  • regressor_name (str, optional) – The name of the regressor. Default is ‘RandomForestRegressor’.

  • parameters (dict, optional) – Parameters for the regressor. Default is {‘n_trees’: 100, ‘min_samples_leaf’: 0.1, ‘max_depth’: 10}.

  • verbose (bool, optional) – If True, enables detailed logging. Default is False.

regressor_name

Name of the chosen regressor.

Type:

str

regressor

Instance of the chosen regressor.

Type:

object

parameters

Parameters for the regressor.

Type:

dict

__init__(regressor_name='RandomForestRegressor', parameters={'n_trees': 100, 'min_samples_leaf': 0.1, 'max_depth': 10}, verbose=False)[source]

Initializes the regressor with the given or default parameters.

class CDHPO_Parameters[source]

Bases: object

Class to manage the configuration of the CDHPO (Causal Discovery with Hyperparameter Optimization) process.

init_main_params(alpha=0.01, n_permutations=200, causal_sufficiency=True, variables_type='mixed', n_jobs: int | None = 1, verbose=False)[source]

Initializes the main parameters for CDHPO.

set_regressor(name, parameters)[source]

Sets the regressor used in the CDHPO process.

set_oos_protocol(name, parameters)[source]

Sets the out-of-sample (OOS) protocol for validation.

set_cd_algorithms(algorithms, data_info)[source]

Sets the causal discovery algorithms for CDHPO.

check_configs(data_info)[source]

Verifies the configurations for the causal discovery algorithms.

add_cd_algorithm(algorithm, parameters, data_info)[source]

Adds a new causal discovery algorithm with parameters.

add_cd_algorithm_parameters(algorithm, parameters)[source]

Adds parameters to an existing causal discovery algorithm.

init_main_params(alpha=0.01, n_permutations=200, causal_sufficiency=True, variables_type='mixed', n_jobs: int | None = 1, verbose=False)[source]

Initializes the main parameters for the CDHPO process.

Parameters:
  • alpha (float, optional) – The significance level. Default is 0.01.

  • n_permutations (int, optional) – The number of permutations for statistical tests. Default is 200.

  • causal_sufficiency (bool, optional) – Whether to assume causal sufficiency. Default is True.

  • variables_type (str, optional) – Type of variables in the data (e.g., ‘mixed’, ‘discrete’, ‘continuous’). Default is ‘mixed’.

  • n_jobs (int, optional) – Number of parallel jobs. Default is 1.

  • verbose (bool, optional) – If True, enables detailed logging. Default is False.

Return type:

None

set_regressor(name, parameters)[source]

Sets the regressor for the CDHPO process.

Parameters:
  • name (str) – The name of the regressor.

  • parameters (dict) – The parameters for the regressor.

Return type:

None

set_oos_protocol(name, parameters)[source]

Sets the out-of-sample (OOS) protocol for validation.

Parameters:
  • name (str) – The name of the OOS protocol.

  • parameters (dict) – The parameters for the OOS protocol.

Return type:

None

set_cd_algorithms(algorithms, data_info)[source]

Sets the causal discovery algorithms for CDHPO.

Parameters:
  • algorithms (dict) – Dictionary of algorithms and their configurations.

  • data_info (dict) – Information about the dataset.

Return type:

None

Raises:

RuntimeError – If an algorithm is not found in the database.

check_configs(data_info)[source]

Verifies the configurations for the causal discovery algorithms.

Parameters:

data_info (dict) – Information about the dataset.

Return type:

None

Raises:

RuntimeError – If any algorithm has incorrect parameters.

add_cd_algorithm(algorithm, parameters, data_info)[source]

Adds a new causal discovery algorithm to the CDHPO configuration.

Parameters:
  • algorithm (str) – Name of the algorithm to add.

  • parameters (dict) – Configuration parameters for the algorithm.

  • data_info (dict) – Information about the dataset.

Return type:

None

Raises:

RuntimeError – If the algorithm is not found in the database.

add_cd_algorithm_parameters(algorithm, parameters)[source]

Adds parameters to an existing causal discovery algorithm.

Parameters:
  • algorithm (str) – Name of the algorithm.

  • parameters (dict) – Additional parameters for the algorithm.

Return type:

None

Raises:

RuntimeError – If the algorithm does not exist or the parameters are invalid.

ETIA.CausalLearning.configurations.scores module