causalcompass.algorithms.NTSNotears
- class causalcompass.algorithms.NTSNotears(tau_max=3, wthre=0.01, lambda_1=0.001, lambda_2=0.01, device='cuda', max_iter=100, h_tol=1e-8, rho_max=1e+16, seed=None)[source]
NTS-NOTEARS is a score-based nonlinear extension of DYNOTEARS.
References
https://github.com/xiangyu-sun-789/NTS-NOTEARS
- Parameters:
tau_max (int, default 3) – Maximum time lag
wthre (float or list, default 0.01) – Weight threshold for edge filtering
lambda_1 (float, list, or str, default 0.001) – L1 regularization parameter
lambda_2 (float, default 0.01) – L2 regularization parameter
device (str, default 'cuda') – Computation device
max_iter (int, default 100) – Max number of dual ascent steps during optimization
h_tol (float, default 1e-8) – Tolerance for acyclicity constraint
rho_max (float, default 1e+16) – Maximum value for the augmented Lagrangian penalty parameter
Examples
>>> from causalcompass.algorithms import NTSNotears >>> model = NTSNotears(tau_max=3, wthre=0.01, lambda_1=0.001, lambda_2=0.01, device='cuda') >>> predicted_adj = model.run(X) >>> all_metrics, no_diag_metrics = model.eval(true_adj, predicted_adj)
- __init__(tau_max=3, wthre=0.01, lambda_1=0.001, lambda_2=0.01, device='cuda', max_iter=100, h_tol=1e-8, rho_max=1e+16, seed=None)[source]
Initialize NTS-NOTEARS
Methods
__init__([tau_max, wthre, lambda_1, ...])Initialize NTS-NOTEARS
eval(true_adj, predicted_adj[, shd_thresholds])Evaluate the predicted adjacency matrix against the ground truth.
run(X)Run NTS-NOTEARS 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.