CLI Reference#
The causal-ts command provides a full pipeline from the terminal: inspect and generate data, run discovery, evaluate results, and plot graphs.
causal-ts [OPTIONS] COMMAND [ARGS]...
Global options (pass before the subcommand):
Flag |
Default |
Description |
|---|---|---|
|
|
Directory for all saved files |
|
random |
Global random seed |
|
auto |
Compute device ( |
|
off |
Verbose logging |
|
off |
Suppress non-error output |
inspect#
Pre-flight a dataset: measure its health and get a recommended discovery
configuration. Emits a single JSON object to stdout, so it pipes straight into
jq or an agent.
causal-ts inspect DATA.csv [OPTIONS]
Flag |
Default |
Description |
|---|---|---|
|
from file |
Comma-separated variable names |
|
inferred |
Override the suggested max lag |
The report has six blocks:
Key |
Contents |
|---|---|
|
Integer, bumped on breaking changes to this contract |
|
|
|
Linearity fraction, per-column ADF+KPSS (non)stationarity and its |
|
|
|
|
|
Data-health flags (heavy missingness, constant columns, too few rows) |
# Inspect, then run exactly what it recommends
causal-ts inspect data.csv | jq '.recommendation'
The same report is available in Python as
causalts.inspection.inspect_df(), and the pure facts β config step as
causalts.inspection.recommend_config().
discover#
Run causal discovery on a .csv, .parquet/.pq, or .feather file.
Parquet and feather need pip install causalts[parquet].
causal-ts discover DATA.csv [OPTIONS]
Algorithm options#
Flag |
Default |
Description |
|---|---|---|
|
|
|
|
|
CI test β see |
|
|
Maximum time lag |
|
|
Significance level ( |
|
β |
Comma-separated explicit lags, e.g. |
|
from CSV |
Comma-separated variable names |
CDNOTS-specific#
Flag |
Default |
Description |
|---|---|---|
|
on |
Include nonstationarity node C (also applies to CEDAR) |
|
|
C node basis: |
|
off |
Stable skeleton discovery (slower, more robust) |
|
β |
Maximum node degree constraint |
CEDAR-specific#
Flag |
Default |
Description |
|---|---|---|
|
|
Lag importance metric: |
|
|
Lag significance: |
|
|
P-value threshold for lag significance |
|
|
Significance threshold for dependence test (Condition 1). |
|
|
Significance threshold for independence test (Condition 2). |
|
|
|
|
on |
Skip candidates whose dcor asymmetry suggests they are effects |
|
on |
Test all significant lags per pair (vs only the top lag) |
|
|
|
|
β |
Discover causes of one variable only β O(d) tests instead of O(dΒ²) |
|
off |
Skip MCI pruning pass after discovery |
|
β |
Missing-value strategy: |
|
on |
Add autoregressive self-loops |
|
off |
Skip AR order estimation; use standard AR(1) Cond2 for all variables (backward-compatible with original SyPI) |
|
on |
Append a nonstationarity time-index variable C β forces |
|
|
C node basis preset: |
GRACE-specific#
Flag |
Default |
Description |
|---|---|---|
|
|
Minimum gate value to keep an edge |
|
|
Minimum selection frequency (GRACE-SS) |
|
|
Training epochs |
|
auto |
Mini-batch size |
|
|
Early-stopping patience |
|
on |
Include the C node in the CDNOTS/CI skeleton GRACE refines |
|
|
C node basis for that skeleton |
GRACE runs in two stages, and --include-c / --c-preset configure the first:
the CDNOTS (or CI) skeleton. The second stage β the gated neural model β has a
separate, opt-in C of its own; reach it by calling
causalts.grace.gated_discovery.run_cdnots_gated() with
include_C_in_model=True from Python. That option requires a skeleton built
with C, since the skeleton masks the modelβs gates.
Missing data#
Flag |
Default |
Description |
|---|---|---|
|
β |
|
|
β |
Extra imputer kwargs, e.g. |
Output & evaluation#
Flag |
Default |
Description |
|---|---|---|
|
β |
|
|
on |
Save graph plot images |
|
|
|
|
off |
Echo the run summary β including a named edge list and a |
|
off |
Include per-edge p-values (CDNOTS family and CEDAR). Off by default as a memory safeguard on very high-dimensional data; safe to enable at low/moderate |
With --json, the edges list gives {source, target, lag, pvalue} per edge
(pvalue is null unless --pvalues was passed), and diagnostics carries
n_edges, density, self_loops, contemporaneous/lagged,
max_in_degree + hub, and the empty / saturated flags.
Stability check#
Flag |
Default |
Description |
|---|---|---|
|
off |
Re-run discovery on contiguous bootstrap windows and annotate every edge with its |
|
|
Number of bootstrap windows |
|
|
Window size as a fraction of |
Windows are re-run with the same algorithm, CI test, C-node, and imputation
settings as the main run. Persistence measures robustness to sampling, not
correctness β a systematic artifact (a lag-k echo of a true lag-kβ1 edge,
say) recurs in every window and still scores high. Treat >= 0.6 as βnot a
sampling fluke,β not as proof of a causal link.
causal-ts -o out discover data.csv --json --validate --n-bootstrap 30
Example β full pipeline in one command:
causal-ts -s 42 discover data.csv \
--algorithm cdnots \
--ci-test splitkci \
--max-lag 3 \
--alpha 0.05 \
--ground-truth ground_truth.npy \
--plot-format pdf
generate#
Generate synthetic time series with a known causal structure.
causal-ts generate [OPTIONS]
Flag |
Default |
Description |
|---|---|---|
|
β |
Built-in dataset: |
|
|
Number of variables (random generation) |
|
auto |
Number of cross-variable links |
|
|
Maximum lag |
|
|
Time series length |
|
|
|
|
|
Comma-separated dependency functions |
Outputs: data.csv, ground_truth.npy, meta.json
# Load a built-in dataset
causal-ts generate --dataset ex1 -T 1000
# Generate a random 10-variable sparse network
causal-ts generate -n 10 --max-lag 2 -T 500 --density sparse
evaluate#
Compare a discovered graph against ground truth and compute metrics.
causal-ts evaluate GRAPH_TRUE.npy GRAPH_DISCOVERED.npy [OPTIONS]
Flag |
Default |
Description |
|---|---|---|
|
β |
Comma-separated variable names |
|
off |
Exclude auto-dependencies from metrics |
|
on |
Save TP/FP/FN comparison plot |
|
|
|
Metrics reported: TPR, FPR, Precision, Recall, F1, SHD β both edge-level and pair-level.
causal-ts evaluate ground_truth.npy discovered.npy --var-names X0,X1,X2,X3
ci-test-info#
Print a selection guide for CI tests with indicative performance notes.
causal-ts ci-test-info [--test TEST_NAME]
Run without arguments for a full table; pass --test splitkci for details on a single test.
plot#
Visualise a saved causal graph (.npy file produced by discover).
causal-ts plot GRAPH [options]
Option |
Default |
Description |
|---|---|---|
|
|
Plot type: |
|
β |
Path to |
|
β |
Comma-separated variable names |
|
β |
Figure size as |
|
|
Output format: |
|
β |
Custom output filename (without extension) |
install-skill#
Install the packaged causal-ts-discovery agent skill so a coding agent can
drive causal-ts for you: it inspects the data, picks an algorithm and CI test,
checkpoints with you before an expensive run, and reads the resulting graph back
in plain English.
causal-ts install-skill [OPTIONS]
Flag |
Default |
Description |
|---|---|---|
|
off |
Copy the skill instead of symlinking (for environments that reject symlinks) |
|
off |
Replace an existing non-symlink target |
|
off |
Print what would happen without changing anything |
The skill is installed into ~/.claude/skills/ (Claude Code) and
~/.agents/skills/ (Codex and other Agent-Skills harnesses). The default
symlink stays current across pip install -U causalts; --copy pins a static
snapshot. The repository also ships a .claude-plugin/ manifest, so the same
skill can be added as a Claude Code plugin from a checkout.
dowhy β Effect Estimation#
Requires pip install causalts[dowhy]. All subcommands take a saved graph.npy and a CSV data file.
dowhy effect#
Estimate the average treatment effect (ATE) via the backdoor criterion.
causal-ts dowhy effect GRAPH --data data.csv \
--treatment X0 --outcome X2 --lag 1 \
--method backdoor.linear_regression
dowhy fit-scm#
Fit a Structural Causal Model and optionally run a counterfactual query.
causal-ts dowhy fit-scm GRAPH --data data.csv \
--mechanism linear \
--counterfactual-target X2 \
--intervention "X0=0.0"
dowhy root-cause#
Attribute an observed anomaly to root-cause variables using Shapley-based intrinsic causal contribution.
causal-ts dowhy root-cause GRAPH --data data.csv --target X2
dowhy validate#
Falsify the graph structure against data using DoWhyβs falsification tests.
causal-ts dowhy validate GRAPH --data data.csv
dowhy strength#
Compute arrow strength and causal influence for each edge.
causal-ts dowhy strength GRAPH --data data.csv
dowhy drift#
Detect distribution change / mechanism drift over time.
causal-ts dowhy drift GRAPH --data data.csv
Typical Full Workflow#
# 1. Generate data
causal-ts -s 42 -o ./run1 generate --dataset ex1 -T 500
# 2. Run discovery
causal-ts -s 42 -o ./run1 discover run1/generate/data.csv \
--ci-test splitkci --max-lag 3 \
--ground-truth run1/generate/ground_truth.npy
# 3. Evaluate separately (optional)
causal-ts evaluate run1/generate/ground_truth.npy \
run1/discover/graph.npy --var-names X0,X1,X2,X3,X4