causalcompass.algorithms.LGC

class causalcompass.algorithms.LGC(tau_max=3, threshold=0.01, lgc_alphas=[1e-4, 5e-3, 1e-2, 2e-2, 5e-2], seed=None, **kwargs)[source]

Granger causality-based causal discovery method that augments the VAR model with a Lasso penalty term.

References

https://github.com/cloud36/graphical_granger_methods

Parameters:
  • tau_max (int, default 3) – Maximum time lag

  • threshold (float, default 0.01) – Edge filtering threshold

  • lgc_alphas (list[float], default [1e-4, 5e-3, 1e-2, 2e-2, 5e-2]) – L1 regularization candidates

Examples

>>> from causalcompass.algorithms import LGC
>>> model = LGC(tau_max=3, threshold=0.01, lgc_alphas=[1e-4, 5e-3, 1e-2, 2e-2, 5e-2])
>>> predicted_adj = model.run(X)
>>> all_metrics, no_diag_metrics = model.eval(true_adj, predicted_adj)
__init__(tau_max=3, threshold=0.01, lgc_alphas=[1e-4, 5e-3, 1e-2, 2e-2, 5e-2], seed=None, **kwargs)[source]

Initialize LGC

Methods

__init__([tau_max, threshold, lgc_alphas, seed])

Initialize LGC

eval(true_adj, predicted_adj[, shd_thresholds])

Evaluate the predicted adjacency matrix against the ground truth.

run(X)

Run LGC algorithm.

run_raw(X)

Run the algorithm and return an unthresholded intermediate result that can be reused across multiple threshold values.

run_threshold_sweep(X, thresholds)

Run the algorithm once and post-process the raw result for each threshold.