Skip to main content

Extremely Greedy Equivalence Search

Extremely Greedy Equivalence Search (XGES) is an efficient algorithm for learning the structure of a causal graph from observational data. It improves upon the Greedy Equivalence Search (GES) algorithm with a more accurate search strategy and a more efficient implementation.

The algorithm is described in the paper "Extremely Greedy Equivalence Search" (see citation below)

In this repo, we provide:

  • a pure python implementation of the algorithm in xges/ available with pip install xges.
    • it can optionally use numba for faster execution.
    • examples of usage are available in examples/simple.py.
  • a pure c++ implementation of the algorithm in src-cpp/, which is at least ~10x faster than the python implementation (with numba).
  • code to reproduce the experiments in the paper in evaluation/.
    • an ad-hoc python wrapper calling the cpp executable is available in evaluation/benchmarks.py.
    • a notebook to generate the figures in the paper in evaluation/paper.ipynb.

Using the python package

The python package can be installed with pip:

pip install xges

The package can be used as follows:

from xges import XGES

data = ...
xges = XGES()
pdag = xges.fit(data)  # PDAG object representing the Markov equivalence class (MEC)

# PDAG object with only directed edges, representing an arbitrary DAG in the MEC
a_dag = pdag.get_dag_extension()

# networkx DiGraph object with two edges for undirected PDAG edges
networkx_pdag = pdag.to_networkx()
networkx_dag = a_dag.to_networkx()

adjacency_pdag = pdag.to_adjacency_matrix()
adjacency_dag = a_dag.to_adjacency_matrix()

Reproducing the experiments

The experiments can be reproduced by running the evaluation/benchmarks.py script (after compiling the c++ code in src-cpp). The figures are generated in the notebook evaluation/paper.ipynb.

Building the c++ code

Use the CMakeLists.txt file to build the code.

The code can be run with the following command:

xges --input data.npy --output out.csv --stats stats.csv -v1

The input file should be a numpy file with the data matrix. The output file will contain the CPDAG. The stats file will contain some statistics collected during the execution of the algorithm. -v1 is the verbosity level. It can be set to 0, 1, or 2.

More options can be found by running xges --help.

Citation

If you use this code, please cite the following paper:

@inproceedings{nazaret2021extremely,
  title={Extremely Greedy Equivalence Search},
  author={Nazaret, Achille and Blei, David},
  booktitle={Uncertainty in Artificial Intelligence},
  year={2024}
}

Metadata

Release files for xges 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xges 0.1.6
File Size Uploaded
xges-0.1.6.tar.gz 29.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xges 0.1.6
File Interpreter ABI Platform
xges-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 55.3 kB

Release files / xges-0.1.6.tar.gz

Download URL xges-0.1.6.tar.gz
Size 29.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ab520c88692d050d817486e09bc9f08355bf3bb5dc8b73b3cea4dff803fdbab2
BLAKE2b-256 checksum
How to use checksums
7552c10050fe1f63a6efd9a1f73528b923c605d470728e5644217e75d9f9e8a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.11.5 Darwin/23.2.0

Release files / xges-0.1.6-py3-none-any.whl

Download URL xges-0.1.6-py3-none-any.whl
Size 26.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
22f0de8dd32a274f96c1ed108f60332d4aa92a563f800bd2babada666963bb9c
BLAKE2b-256 checksum
How to use checksums
61b9e84f983ea685b13bb728743630a56a18b40e6dc1f19c249749eb90efd367
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.11.5 Darwin/23.2.0

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page