BottomUpParceLiNGAM

class lingam.BottomUpParceLiNGAM(random_state=None, alpha=0.1, regressor=None, prior_knowledge=None, independence='hsic', ind_corr=0.5)[source]

Implementation of ParceLiNGAM Algorithm [1]

References

__init__(random_state=None, alpha=0.1, regressor=None, prior_knowledge=None, independence='hsic', ind_corr=0.5)[source]

Construct a BottomUpParceLiNGAM model.

Parameters:
  • random_state (int, optional (default=None)) – random_state is the seed used by the random number generator.

  • alpha (float, optional (default=0.1)) – Significant level of statistical test. If alpha=0.0, rejection does not occur in statistical tests.

  • regressor (regressor object implementing 'fit' and 'predict' function (default=None)) – Regressor to compute residuals. This regressor object must have fit``method and ``predict function like scikit-learn’s model.

  • prior_knowledge (array-like, shape (n_features, n_features), optional (default=None)) –

    Prior knowledge used for causal discovery, where n_features is the number of features.

    The elements of prior knowledge matrix are defined as follows [1]:

    • 0 : \(x_i\) does not have a directed path to \(x_j\)

    • 1 : \(x_i\) has a directed path to \(x_j\)

    • -1 : No prior knowledge is available to know if either of the two cases above (0 or 1) is true.

  • independence ({'hsic', 'fcorr'}, optional (default='hsic')) – Methods to determine independence. If ‘hsic’ is set, test for independence by HSIC. If ‘fcorr’ is set, independence is determined by F-correlation.

  • ind_corr (float, optional (default=0.5)) – The threshold value for determining independence by F-correlation; independence is determined when the value of F-correlation is below this threshold value.

property adjacency_matrix_

Estimated adjacency matrix.

Returns:

adjacency_matrix_ – The adjacency matrix B of fitted model, where n_features is the number of features. Set np.nan if order is unknown.

Return type:

array-like, shape (n_features, n_features)

bootstrap(X, n_sampling)[source]

Evaluate the statistical reliability of DAG based on the bootstrapping.

Parameters:
  • X (array-like, shape (n_samples, n_features)) – Training data, where n_samples is the number of samples and n_features is the number of features.

  • n_sampling (int) – Number of bootstrapping samples.

Returns:

result – Returns the result of bootstrapping.

Return type:

BootstrapResult

property causal_order_

Estimated causal ordering.

Returns:

causal_order_ – The causal order of fitted model, where n_features is the number of features. Set the features as a list if order is unknown.

Return type:

array-like, shape (n_features)

estimate_total_effect(X, from_index, to_index)[source]

Estimate total effect using causal model.

Parameters:
  • X (array-like, shape (n_samples, n_features)) – Original data, where n_samples is the number of samples and n_features is the number of features.

  • from_index – Index of source variable to estimate total effect.

  • to_index – Index of destination variable to estimate total effect.

Returns:

total_effect – Estimated total effect.

Return type:

float

estimate_total_effect2(from_index, to_index)[source]

Estimate total effect using causal model.

Parameters:
  • from_index – Index of source variable to estimate total effect.

  • to_index – Index of destination variable to estimate total effect.

Returns:

total_effect – Estimated total effect.

Return type:

float

fit(X)[source]

Fit the model to X.

Parameters:

X (array-like, shape (n_samples, n_features)) – Training data, where n_samples is the number of samples and n_features is the number of features.

Returns:

self – Returns the instance itself.

Return type:

object

get_error_independence_p_values(X)[source]

Calculate the p-value matrix of independence between error variables.

Parameters:

X (array-like, shape (n_samples, n_features)) – Original data, where n_samples is the number of samples and n_features is the number of features.

Returns:

independence_p_values – p-value matrix of independence between error variables.

Return type:

array-like, shape (n_features, n_features)