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.1.tar.gz
.
File metadata
- Download URL: gadjid-0.0.1.tar.gz
- Upload date:
- Size: 37.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aaf9783e9c55c2909d8730a5f122278ce661837c3965b128b9e7f15a53db535c |
|
MD5 | c62ddd9c3bf6d32b5ee1c88f2e1823c3 |
|
BLAKE2b-256 | 0109d1fb8b763e496ba9776864aa29d8c5fe2ef5965ff222c98650131c7d0c7a |
File details
Details for the file gadjid-0.0.1-pp310-pypy310_pp73-win_amd64.whl
.
File metadata
- Download URL: gadjid-0.0.1-pp310-pypy310_pp73-win_amd64.whl
- Upload date:
- Size: 217.6 kB
- Tags: PyPy, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4efcb4418d58f4b96c723827f24172f6ca5bb3031b7fbae60a2a7b9f4926b82d |
|
MD5 | 8def97bcbf1b99b80fe41df6a5cef426 |
|
BLAKE2b-256 | 4ad3c7c78b50c6b874fdfb171f11f7ccfa39f715acae4e6d3e6c9c9716f57714 |
File details
Details for the file gadjid-0.0.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: gadjid-0.0.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 742.6 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 | 9e6b14664a6f7a3fc5da5f0a46e81a325cfe29b1952f4f437b806f8645503825 |
|
MD5 | 4fc4bf4b98d63162f8db3404d1364564 |
|
BLAKE2b-256 | cc81f808bffa4acebfc0b55c1dc96f2e29aa05c21b65f9d814975743d9e52ba3 |
File details
Details for the file gadjid-0.0.1-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: gadjid-0.0.1-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 744.5 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 | 772b1c2ebee44f9de75e18d3262683ea50d22e612732dfc0fb2293259331d080 |
|
MD5 | 8c2002b6f04f6417143fd2d7f4e3c621 |
|
BLAKE2b-256 | 9683ca2321d2c9939f989b7bb946dc5200e233515f86db1e3ebe5024f89e1e0e |
File details
Details for the file gadjid-0.0.1-pp310-pypy310_pp73-macosx_11_0_arm64.whl
.
File metadata
- Download URL: gadjid-0.0.1-pp310-pypy310_pp73-macosx_11_0_arm64.whl
- Upload date:
- Size: 331.3 kB
- Tags: PyPy, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d06f6be98d38f23281cdd020aa045180b91662fa1f74cddde2ea6681bb02568 |
|
MD5 | e162c8d9b80de9e5303eb475ab55a9ae |
|
BLAKE2b-256 | 11088d7a32be7c504e78ab1c8b254bc2ca9d1aeb185e466e00bdd14e307cb886 |
File details
Details for the file gadjid-0.0.1-pp310-pypy310_pp73-macosx_10_12_x86_64.whl
.
File metadata
- Download URL: gadjid-0.0.1-pp310-pypy310_pp73-macosx_10_12_x86_64.whl
- Upload date:
- Size: 345.5 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 | 48f1816916f1e438048858d16b869667fc259331d262c72ec7d248a8e41b00b1 |
|
MD5 | 0e2f83cd2289d6c6e60138bf6cd8f49e |
|
BLAKE2b-256 | 14d33af083e1e4e49bd46b3b805dd9260511bbd1439d5c5a010c54379a88e51e |
File details
Details for the file gadjid-0.0.1-pp39-pypy39_pp73-win_amd64.whl
.
File metadata
- Download URL: gadjid-0.0.1-pp39-pypy39_pp73-win_amd64.whl
- Upload date:
- Size: 217.5 kB
- Tags: PyPy, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f900bc26db6afcbb04ab2b5c8cb5c133ab00b64cd1aae0684cfaeede95b91705 |
|
MD5 | c779ad1b0d128a10bce04704b22046ed |
|
BLAKE2b-256 | 580ef8475f280b6f9af1d9449ab268821de13b9eea8773cc1da0e7a186b39cd3 |
File details
Details for the file gadjid-0.0.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: gadjid-0.0.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 742.6 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 | 8da6c4743e03aaf3781944c6395a54f43760e4b0cc67a5111c702b283817a775 |
|
MD5 | 7e07d1f2da66cc6762b5aae80eb8560a |
|
BLAKE2b-256 | fbe3124c1c6cbeabe241f2891f86cc010656288b261c0647aacb645e410bc886 |
File details
Details for the file gadjid-0.0.1-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: gadjid-0.0.1-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 744.5 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 | bf20a4327cd630987814c7e92b77ff5c97c0ed6a93f686df090613bf5084a68c |
|
MD5 | 3f42b4d2147210033e4073176fabc4d8 |
|
BLAKE2b-256 | 81232d5f26d6d5f73b7565ac64f5929e927c64e03237101797b1a82a545fcf2c |
File details
Details for the file gadjid-0.0.1-pp39-pypy39_pp73-macosx_11_0_arm64.whl
.
File metadata
- Download URL: gadjid-0.0.1-pp39-pypy39_pp73-macosx_11_0_arm64.whl
- Upload date:
- Size: 331.2 kB
- Tags: PyPy, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2284f9d7b83c4623b3ee34568d5e939d8c6029167a9c23850e0af1b591b8131 |
|
MD5 | d869602fcf521e946cc4698ef397502a |
|
BLAKE2b-256 | 05d4b52c1b11b4a83f7af43a3fe74e81ddc2f6737853418e81ce5691e0634476 |
File details
Details for the file gadjid-0.0.1-pp39-pypy39_pp73-macosx_10_12_x86_64.whl
.
File metadata
- Download URL: gadjid-0.0.1-pp39-pypy39_pp73-macosx_10_12_x86_64.whl
- Upload date:
- Size: 345.4 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 | 23399bc5899daf1de00b7980c195bf11b9e871802d1b1dcce8b6f27055be84e8 |
|
MD5 | 19ca10af19e25af86c4925de4f6da891 |
|
BLAKE2b-256 | de2f8301d4f422aa9f31bd784363f3560511f139f80e33974762ad3c5b2d469b |
File details
Details for the file gadjid-0.0.1-cp38-abi3-win_arm64.whl
.
File metadata
- Download URL: gadjid-0.0.1-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 | c3496d747d137b7dccdcee6e793390288b46b7a552d0b55ae4a743e021fb85b9 |
|
MD5 | 165b8c0c20f0fdcc930cf839dcace9fd |
|
BLAKE2b-256 | 778d981e8c534fe7e71325e51391b8b4eb0638dd38208313fa8c7795f7e05560 |
File details
Details for the file gadjid-0.0.1-cp38-abi3-win_amd64.whl
.
File metadata
- Download URL: gadjid-0.0.1-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 217.9 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 | 556bbeaa88cac71fa63b65a92e48a5d527fe24befebc66c09b16bbfc1a1542a5 |
|
MD5 | a08e0e31b176f7c79c7b49797944998e |
|
BLAKE2b-256 | 820b0101d3c31b00ed7e0adafa3ad8252af8a422c35bb0bbc54271752084f3ab |
File details
Details for the file gadjid-0.0.1-cp38-abi3-musllinux_1_1_x86_64.whl
.
File metadata
- Download URL: gadjid-0.0.1-cp38-abi3-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 909.0 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 | 6596b1d96e22737e45756b44d1f5595bc1e8999af171c74ee106d84ee09558d3 |
|
MD5 | a5dde3323ceaf42b6782e7d562510e7c |
|
BLAKE2b-256 | ad53768492257d7d5d4475861e379842d7dfad7123ad1a72934c99e07dd41ff3 |
File details
Details for the file gadjid-0.0.1-cp38-abi3-musllinux_1_1_aarch64.whl
.
File metadata
- Download URL: gadjid-0.0.1-cp38-abi3-musllinux_1_1_aarch64.whl
- Upload date:
- Size: 916.8 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 | 641336e4e25059212780f5a12b8fa721c69d121a87e75919704d2c721ac8b1ef |
|
MD5 | fa9a4d8beb23b08bfc826a6f17970f34 |
|
BLAKE2b-256 | e9b81e0475a25053d15bbb0090e623fefc31749e70e28af5867e39cb6a9a9f2f |
File details
Details for the file gadjid-0.0.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: gadjid-0.0.1-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 | cfc55a014e5bd8cfa3662fb1f3407a039c3b0beb1b735e8aee2368a18da6159b |
|
MD5 | 23e84a1af17c87b521abf7769e1ba974 |
|
BLAKE2b-256 | 591fa5349f91073baa4808f23d0bec25fc1c29f58e290708d31b0e277fd58824 |
File details
Details for the file gadjid-0.0.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: gadjid-0.0.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 744.8 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 | a2e62f27aed06d831d617a4ee43680932e33a61e8db72efddac118ea3c5d2ee0 |
|
MD5 | e5572419b3f8ffad07fba2c3dc596223 |
|
BLAKE2b-256 | b43e80bd98f8fd62970afe7e00edaa02c0fc625f6bc55ceba8a2487be80d2031 |
File details
Details for the file gadjid-0.0.1-cp38-abi3-macosx_11_0_arm64.whl
.
File metadata
- Download URL: gadjid-0.0.1-cp38-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 331.7 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 | 3a239106b0e02563782049ce3739f00f05e1d4c2f9dc15241bb4585979d3231d |
|
MD5 | 3a3a1d19c30106316b535bd89a7ad782 |
|
BLAKE2b-256 | d496595726b0c2467d309b32ccc5f5e8a618ab81f8108f1355b3da784996f747 |
File details
Details for the file gadjid-0.0.1-cp38-abi3-macosx_10_12_x86_64.whl
.
File metadata
- Download URL: gadjid-0.0.1-cp38-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 346.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 | 56a728b7987dcf5195fde19c78f9bc30a8714539b7f324aa2f0c4db6049ec382 |
|
MD5 | da4e2915248f671a2e4fd823dd7d1f1f |
|
BLAKE2b-256 | e4f5afeeaaac09fa9c6ac36862a6669d0c82ac039f1382f1af2738daee633261 |