causalcompass.algorithms.DyNotears

class causalcompass.algorithms.DyNotears(tau_max=3, wthre=0.01, lambda_w=0.1, lambda_a=0.1, max_iter=100, h_tol=1e-8, seed=None)[source]

Score-based causal discovery method that extends the NOTEARS framework to dynamic (time series) settings using continuous optimization with acyclicity constraints.

References

https://github.com/mckinsey/causalnex

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

  • wthre (float, default 0.01) – Weight threshold for edge filtering

  • lambda_w (float, default 0.1) – Parameter for L1 regularization of intra-slice edges

  • lambda_a (float, default 0.1) – Parameter for L1 regularization of inter-slice edges

  • max_iter (int, default 100) – Max number of dual ascent steps during optimization

  • h_tol (float, default 1e-8) – Tolerance for acyclicity constraint

Examples

>>> from causalcompass.algorithms import DyNotears
>>> model = DyNotears(tau_max=3, wthre=0.01, lambda_w=0.1, lambda_a=0.1)
>>> predicted_adj = model.run(X)
>>> all_metrics, no_diag_metrics = model.eval(true_adj, predicted_adj)
__init__(tau_max=3, wthre=0.01, lambda_w=0.1, lambda_a=0.1, max_iter=100, h_tol=1e-8, seed=None)[source]

Initialize DYNOTEARS

Methods

__init__([tau_max, wthre, lambda_w, ...])

Initialize DYNOTEARS

eval(true_adj, predicted_adj[, shd_thresholds])

Evaluate the predicted adjacency matrix against the ground truth.

run(X)

Run DYNOTEARS algorithm.

run_raw(X)

Run DYNOTEARS once and return the aggregated absolute edge-weight matrix.

run_threshold_sweep(X, thresholds)

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