Adjustment Identification Distance: A ๐๐๐๐๐๐ for Causal Structure Learning
Project description
Adjustment Identification Distance: A ๐๐๐๐๐๐ for Causal Structure Learning
This is an early release of ๐๐๐๐๐๐ ๐ฅ and feedback is very welcome! Just open an issue on our github repository.
If you publish research using ๐๐๐๐๐๐, please cite our article
@article{henckel2024adjustment,
title = {{Adjustment Identification Distance: A gadjid for Causal Structure Learning}},
author = {Leonard Henckel and Theo Wรผrtzen and Sebastian Weichwald},
journal = {{arXiv preprint arXiv:2402.08616}},
year = {2024},
doi = {10.48550/arXiv.2402.08616},
}
Get Started Real Quick ๐ โ Introductory Example
Just pip install gadjid
to install the latest release of ๐๐๐๐๐๐
and run python -c "import gadjid; help(gadjid)"
to get started
(or see install alternatives).
import gadjid
from gadjid import example, ancestor_aid, oset_aid, parent_aid, shd
import numpy as np
help(gadjid)
example.run_parent_aid()
Gtrue = np.array([
[0, 1, 1, 1, 1],
[0, 0, 1, 1, 1],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0]
], dtype=np.int8)
Gguess = np.array([
[0, 0, 1, 1, 1],
[1, 0, 1, 1, 1],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0]
], dtype=np.int8)
print(ancestor_aid(Gtrue, Gguess))
print(shd(Gtrue, Gguess))
๐๐๐๐๐๐ is implemented in Rust and can conveniently be called from Python via our Python wrapper (implemented using maturin and PyO3).
Evaluating graphs learned by causal discovery algorithms is difficult: The number of edges that differ between two graphs does not reflect how the graphs differ with respect to the identifying formulas they suggest for causal effects. We introduce a framework for developing causal distances between graphs which includes the structural intervention distance for directed acyclic graphs as a special case. We use this framework to develop improved adjustment-based distances as well as extensions to completed partially directed acyclic graphs and causal orders. We develop polynomial-time reachability algorithms to compute the distances efficiently. In our package ๐๐๐๐๐๐, we provide implementations of our distances; they are orders of magnitude faster than the structural intervention distance and thereby provide a success metric for causal discovery that scales to graph sizes that were previously prohibitive.
Implemented Distances
ancestor_aid(Gtrue, Gguess)
oset_aid(Gtrue, Gguess)
parent_aid(Gtrue, Gguess)
- for convenience, the following distances are implemented, too
shd(Gtrue, Gguess)
sid(Gtrue, Gguess)
โ only for DAGs!
where Gtrue and Gguess are adjacency matrices of a DAG or CPDAG.
The functions are not symmetric in their input:
To calculate a distance,
identifying formulas for causal effects are inferred in the graph Gguess
and verified against the graph Gtrue
.
Distances return a tuple (normalised_distance, mistake_count)
of the fraction of causal effects inferred in Gguess that are wrong relative to Gtrue, normalised_distance
,
and the number of wrongly inferred causal effects, mistake_count
.
There are $p(p-1)$ pairwise causal effects to infer in graphs with $p$ nodes
and we define normalisation as normalised_distance = mistake_count / p(p-1)
.
All graphs are assumed simple, that is, at most one edge is allowed between any two nodes.
An adjacency matrix for a DAG may only contain 0s and 1s;
a 1
in row s
and column t
codes a directed edge Xโ โ Xโ
;
DAG inputs are validated for acyclicity.
An adjacency matrix for a CPDAG may only contain 0s, 1s and 2s;
a 2
in row s
and column t
codes a undirected edge Xโ โ Xโ
(an additional 2
in row t
and column s
is ignored; only one of the two entries is required to code an undirected edge);
CPDAG inputs are not validated and the user needs to ensure the adjacency matrix indeed codes a valid CPDAG (instead of just a PDAG).
You may also calculate the SID between DAGs via parent_aid(DAGtrue, DAGguess)
,
but we recommend ancestor_aid
and oset_aid
and for CPDAG inputs our parent_aid
does not coincide with the SID
(see also our accompanying article).
Empirical Runtime Analysis
Experiments run on a laptop with 8 GB RAM and 4-core i5-8365U processor. Here, for a graph with $p$ nodes, sparse graphs have $10p$ edges in expectation, dense graphs have $0.3p(p-1)/2$ edges in expectation, and sparse graphs have $0.75p$ edges in expectation.
Maximum graph size feasible within 1 minute
Method | sparse | dense |
---|---|---|
Parent-AID | 13005 | 960 |
Ancestor-AID | 8200 | 932 |
Oset-AID | 546 | 250 |
SID in R | 255 | 239 |
Average runtime
Method | x-sparse ($p=1000$) | sparse ($p=256$) | dense ($p=239$) |
---|---|---|---|
Parent-AID | 6.3 ms | 22.8 ms | 189 ms |
Ancestor-AID | 2.7 ms | 38.7 ms | 226 ms |
Oset-AID | 3.2 ms | 4.69 s | 47.3 s |
SID in R | ~1โ2 h | ~60 s | ~60 s |
LICENSE
๐๐๐๐๐๐ is available in source code form at https://github.com/CausalDisco/gadjid.
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
See also the MPL-2.0 FAQ.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file gadjid-0.0.1rc2.tar.gz
.
File metadata
- Download URL: gadjid-0.0.1rc2.tar.gz
- Upload date:
- Size: 37.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36e162e7acc77832b5177f6c678c6f613c4d65eff774779f14b0c1ae1e2d0ed4 |
|
MD5 | 21afc13459328371b7df411167114a04 |
|
BLAKE2b-256 | 1c5fa0ea4e5328c64b493f8a265b1095f7006de047e5dd7c45572fada5916c94 |
File details
Details for the file gadjid-0.0.1rc2-pp310-pypy310_pp73-win_amd64.whl
.
File metadata
- Download URL: gadjid-0.0.1rc2-pp310-pypy310_pp73-win_amd64.whl
- Upload date:
- Size: 217.4 kB
- Tags: PyPy, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b64e19533824bc135ccfb62511bac56b051c87009d8997e91844d138d81f30c |
|
MD5 | 7f5db67426b426ad545e0d601aa62270 |
|
BLAKE2b-256 | 5b7924de6890aa4f2c7627bc3d5379fac1371b1f979afb3a1ca132a9ee200d59 |
File details
Details for the file gadjid-0.0.1rc2-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: gadjid-0.0.1rc2-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 742.5 kB
- Tags: PyPy, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 284f8e02ebcf6085068f47415f3dc35139823461801419006cf7fe5779959464 |
|
MD5 | 88a5824592bb4a2ac6136f2b7d0c8633 |
|
BLAKE2b-256 | d5cc54afd1e609985dc99f8a493ed74bd64bbf800c0ec166cd6b0a166882c2a2 |
File details
Details for the file gadjid-0.0.1rc2-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: gadjid-0.0.1rc2-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 744.7 kB
- Tags: PyPy, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40f17752181f6234cf8135fcf16741bc21655b8c7bcb5d2b3baed553f41df01c |
|
MD5 | df6ddc273a85bce1cec0b7527a6589bb |
|
BLAKE2b-256 | b9154e628ab875d68003198ecc6a6b78ac617f5fdf0a2007b096c49c4dcf4e5b |
File details
Details for the file gadjid-0.0.1rc2-pp310-pypy310_pp73-macosx_11_0_arm64.whl
.
File metadata
- Download URL: gadjid-0.0.1rc2-pp310-pypy310_pp73-macosx_11_0_arm64.whl
- Upload date:
- Size: 330.7 kB
- Tags: PyPy, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4712b9fda721c2aaab2e783263df7c3da71525e2dc4477412cebe03f32423633 |
|
MD5 | bc7144e66b5d53001f5661610f552b64 |
|
BLAKE2b-256 | b611a7941bb2ff53a50a79d3dd71278e9dde69e172a1cf811805167ab74db6f9 |
File details
Details for the file gadjid-0.0.1rc2-pp310-pypy310_pp73-macosx_10_12_x86_64.whl
.
File metadata
- Download URL: gadjid-0.0.1rc2-pp310-pypy310_pp73-macosx_10_12_x86_64.whl
- Upload date:
- Size: 343.6 kB
- Tags: PyPy, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99dff68c29773f7e1ced4e614794c5bd467f5292ce335f5c91fb79b7f2080b19 |
|
MD5 | 125ef5c6aef4291049959c7218708b45 |
|
BLAKE2b-256 | 826f011973ba87596d88fbec80b2b543027886ca8e9ad68e54baec9b5214405e |
File details
Details for the file gadjid-0.0.1rc2-pp39-pypy39_pp73-win_amd64.whl
.
File metadata
- Download URL: gadjid-0.0.1rc2-pp39-pypy39_pp73-win_amd64.whl
- Upload date:
- Size: 217.4 kB
- Tags: PyPy, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cab2cd2f4cc2c5180186d312b1dec8d79dd6db226e884bc7693a13dd16de9da7 |
|
MD5 | 430caef77fab457157e50360c1b29246 |
|
BLAKE2b-256 | ac2f1b9d39d030af284c886e11bd54d18334f6ae5a5a0d702a6a5525b90245c1 |
File details
Details for the file gadjid-0.0.1rc2-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: gadjid-0.0.1rc2-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 742.5 kB
- Tags: PyPy, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5bd40f3fd4f91ecc4e8ca1b73b148336b2a22d7e7dfe4035a8b12b9453e04abf |
|
MD5 | dcab098884f084dfc5b59f4b742384d8 |
|
BLAKE2b-256 | b29b3bdb49e7fac15e4d43366fcb049351ee56f8c57a3f7045678df4194a4f18 |
File details
Details for the file gadjid-0.0.1rc2-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: gadjid-0.0.1rc2-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 744.7 kB
- Tags: PyPy, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c392b8f1cec8b5b0f7b91598faf2103df1f10662f92eaea803f1f20a5b8837d0 |
|
MD5 | 2048dee377e0a6e2d2a75442741ca858 |
|
BLAKE2b-256 | 2105a3d69fed08b346d248244de1728e6de8aa21bd9110e8976bef2a1c5e0a4f |
File details
Details for the file gadjid-0.0.1rc2-pp39-pypy39_pp73-macosx_11_0_arm64.whl
.
File metadata
- Download URL: gadjid-0.0.1rc2-pp39-pypy39_pp73-macosx_11_0_arm64.whl
- Upload date:
- Size: 330.7 kB
- Tags: PyPy, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77ef9c08f94b5ab2819c343ec66b817587204bd2a87da624569cdc53e59d241e |
|
MD5 | 1c11a3bc01721f6c0a60c10bf355c1d8 |
|
BLAKE2b-256 | 3be54c3af232156d8a26b8789afd56fb4180c816ddbe709d5260685d5522ed38 |
File details
Details for the file gadjid-0.0.1rc2-pp39-pypy39_pp73-macosx_10_12_x86_64.whl
.
File metadata
- Download URL: gadjid-0.0.1rc2-pp39-pypy39_pp73-macosx_10_12_x86_64.whl
- Upload date:
- Size: 343.6 kB
- Tags: PyPy, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c135bda8f192215a2dadf540fd49acb49c1bf06eb32c2541c7446eb3643d86f1 |
|
MD5 | 42ec380e22d8695dbbcf68208ecbb739 |
|
BLAKE2b-256 | e920d5f46a9f6476518a50049df5c3a29febc4ebf9cb02cbf1f7d2a89133daac |
File details
Details for the file gadjid-0.0.1rc2-cp38-abi3-win_arm64.whl
.
File metadata
- Download URL: gadjid-0.0.1rc2-cp38-abi3-win_arm64.whl
- Upload date:
- Size: 203.8 kB
- Tags: CPython 3.8+, Windows ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1a1d2ec8ef4b8eaf7c3c47ab5f0449123c0f20a0419af5ac60a506f2c487a8f |
|
MD5 | dee5c469cd35607a8988a2fbfec059ca |
|
BLAKE2b-256 | c7d0613eeec972f9d26b46edebe5cd3d4f780b8bc7314d5d9ad9212eab74bdf6 |
File details
Details for the file gadjid-0.0.1rc2-cp38-abi3-win_amd64.whl
.
File metadata
- Download URL: gadjid-0.0.1rc2-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 217.5 kB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca928d01a67ae5dbde94bb9d0e57ed246d6bcb1b80aaca690c38236495fef0a2 |
|
MD5 | fb80859a7f7c90c35b45561a25bb3acd |
|
BLAKE2b-256 | aeb2baabbe7e74f4202ae49b28f6efd127b4216645bf5f1aa3697943a40884c5 |
File details
Details for the file gadjid-0.0.1rc2-cp38-abi3-musllinux_1_1_x86_64.whl
.
File metadata
- Download URL: gadjid-0.0.1rc2-cp38-abi3-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 909.2 kB
- Tags: CPython 3.8+, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 832398dd38877da1eeacf4c1760fa6f85617c173601faa6a8d695e4005fcc8fe |
|
MD5 | a2ca4bb094c0ecca9ff761fc08a6944e |
|
BLAKE2b-256 | a8af4ae2e07548d057d95bf8e5166161d2bb32ec84c317bc18c2c47a7529741a |
File details
Details for the file gadjid-0.0.1rc2-cp38-abi3-musllinux_1_1_aarch64.whl
.
File metadata
- Download URL: gadjid-0.0.1rc2-cp38-abi3-musllinux_1_1_aarch64.whl
- Upload date:
- Size: 916.7 kB
- Tags: CPython 3.8+, musllinux: musl 1.1+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f028be9d3c652a970718a3b33ce2d2e15e4f19eced813a1a795744e1c2f571c |
|
MD5 | 70faed07c00c074ce7f7531fa3d0e8d8 |
|
BLAKE2b-256 | 8121f4800bbbbc08c5a3916ace4e8bdd6d1818df3f5fd80aa37523a6867d776a |
File details
Details for the file gadjid-0.0.1rc2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: gadjid-0.0.1rc2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 742.8 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7fa78c3c48362002811c6c7caebe83121b37bb0566fd6dfca0454667fc8952d2 |
|
MD5 | ca34654632de152a6e45cd25a4fcc186 |
|
BLAKE2b-256 | 0406be881ea973616f56444ec9d38491f73f324485d34e928dc85332eb0f0df5 |
File details
Details for the file gadjid-0.0.1rc2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: gadjid-0.0.1rc2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 745.4 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c50fa44ac377489c6f73b736c819c0da6bdaeabd8ef4dd4d1b61e9f09cb269e5 |
|
MD5 | 04e593114b09de1ea0ce4cbd043b6c5c |
|
BLAKE2b-256 | ee001b7b393630d7f80b4d323e445be040aba790294befea5a83f814c8d6eeb9 |
File details
Details for the file gadjid-0.0.1rc2-cp38-abi3-macosx_11_0_arm64.whl
.
File metadata
- Download URL: gadjid-0.0.1rc2-cp38-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 331.1 kB
- Tags: CPython 3.8+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d4548ed6e0a9a94ab8dd96ee00ed178d5337005ed3ace4768188a88d9262c11 |
|
MD5 | bef2891c2a87f410f29a51d5faf22d66 |
|
BLAKE2b-256 | e5d599f159b5e7bf581ec037d75a9ed1e3bd3e6d5e264e8f6fc2f3efa35da04e |
File details
Details for the file gadjid-0.0.1rc2-cp38-abi3-macosx_10_12_x86_64.whl
.
File metadata
- Download URL: gadjid-0.0.1rc2-cp38-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 344.0 kB
- Tags: CPython 3.8+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f55f2de8db76de45333866626104a7267b1d5e38ebbfcea385030009adb897c4 |
|
MD5 | 978ca8abab4919407ee37a9082afba52 |
|
BLAKE2b-256 | 9df4287a77ca38f75170faae3d992f5e4607b9bbae2e84ec15c862437e4607b5 |