Accelerated

The fastest causal discovery package.

  • Fit time

    1. PC400 variables

      Andrey0.82 s
      causal-learn617 s
      gCastle185 s
    2. GES200 variables

      Andrey1.05 s
      causal-learn584 s
    3. BOSS40 variables

      Andrey0.37 s
      causal-learn81.1 s
    4. DirectLiNGAM200 variables

      Andrey545 s
      causal-learn1,797 s
    5. PCMCI160 variables

      Andrey5.35 s
      tigramite477 s
    6. GIN12 variables

      Andrey5.3 s
      Tetrad805 s
      causal-learn38.1 s
    7. ANM8,000 rows

      Andrey196 s
      causal-learn472 s
  • Why Andrey is fast

    It does many things at once, never computes twice, skips what can't matter, and uses the hardware you have.

    Explore why Andrey is so fast

Accurate

Just as accurate as other popular packages.

  • Errors against the true graph

    1. PC400 variables

      Andrey357
      causal-learn357
      gCastle792.5
    2. GES200 variables

      Andrey199
      causal-learn199
    3. BOSS40 variables

      Andrey7
      causal-learn9
    4. DirectLiNGAM200 variables

      Andrey13
      causal-learn13
    5. PCMCI160 variables

      Andrey2,605
      tigramite2,605
    6. GIN12 variables

      Andrey1
      Tetrad1
      causal-learn1
    7. ANM8,000 rows

      Andrey0
      causal-learn0
  • Tested against the true graphs

    Every release is tested against the graphs that generated the data.

    Release cards

Agentic

A command line that never prompts and answers in JSON, so an agent can run it alone.

All-in-one

50 supported methods for every kind of data, and five kinds of causal graph.

From data to graph

From a table of measurements to its causal graph, in a few lines of Python.

Sachs and colleagues measured 11 proteins and phospholipids in 853 human immune cells. PC finds 8 of the 17 links in the known signaling network, and none outside it.

rafmekplcpip2pip3erkaktpkapkcp38jnk
The recovered graph, drawn with andrey.viz.draw.

More examples

example.py
import andrey
from andrey.data import load_dataset

df = load_dataset("sachs").data
out = andrey.pc(df)
print(out)
example.py
pc  cpdag  |  11 nodes  |  8 edges (6 undirected, 2 directed)

  raf -- mek
  plc -- pip3
  pip2 -- pip3
  erk -- akt
  erk -- pka
  akt -- pka
  p38 -> pkc
  jnk -> pkc

  indep_test: fisherz
  tie_break: rank

Five kinds of causal graph

How much the data can tell decides a graph's kind. Here, four methods learn from data about a lawn, its sprinkler, and the rain.

seasonrainsprinklerwetslippery
DAG, from DirectLiNGAM. One direction for every edge: non-Gaussian noise settles each one.
seasonrainsprinklerwetslippery
CPDAG, from PC. The data cannot say which way the two edges from season point, so they stay plain lines.
seasonrainsprinklerwetslippery
PAG, from FCI. Circles on both ends: either direction, or a hidden common cause, fits the data.
sprinkler(t-1)wet(t-1)rain(t-1)sprinkler(t)wet(t)rain(t)
Graph over time, from VARMA-LiNGAM. Rain wets the lawn the same day; the sprinkler wets it the next day, and a dry lawn turns the sprinkler on the next day.
sprinklerwetrain
Cyclic graph, the same graph with time collapsed. The sprinkler and the lawn drive each other, though every arrow over time points forward.

Graph types

Agent support

andrey --skill prints a guide the agent loads as a skill.

  1. Find a method

    andrey list names all 55 methods, with the graph each returns.

  2. Read its contract

    andrey run pc --help --json gives each parameter's type, default, and meaning as JSON Schema.

  3. Run it

    The run prints the graph as JSON, its nodes named by the data's header row.

$ andrey list | jq -r '.[] | [.name, .output, .status] | @tsv'
pc cpdag supportedfci pag supportedgfci pag supported... 52 more
exit 0
$ andrey run pc --help --json | jq -c '.method.params.properties.alpha | {type, default}'
{"type":"number","default":0.05}
exit 0
$ andrey run pc --data sachs.csv | jq -c '.structure | .labels as $n | .edges[] | [$n[.source], $n[.target], .type]'
["raf","mek","undirected"]["plc","pip3","undirected"]["pip2","pip3","undirected"]["erk","akt","undirected"]["erk","pka","undirected"]["akt","pka","undirected"]["p38","pkc","directed"]["jnk","pkc","directed"]
exit 0
rafmekplcpip2pip3erkaktpkapkcp38jnk
The graph in that JSON, drawn with andrey.viz.draw.

Command-line reference

Documentation