[![Latest version](https://badge.fury.io/py/CausalDisco.svg)](https://badge.fury.io/py/CausalDisco)
[![License: BSD](https://img.shields.io/badge/License-BSD-blue.svg)](https://github.com/CausalDisco/CausalDisco/blob/main/LICENSE)
[![Downloads](https://static.pepy.tech/personalized-badge/CausalDisco?period=total&units=international_system&left_color=grey&right_color=green&left_text=Downloads)](https://pepy.tech/project/CausalDisco)
# CausalDisco 🪩
CausalDisco contains baseline algorithms and analytics tools for Causal Discovery. The [package](https://pypi.org/project/CausalDisco/) can be installed by running `pip install CausalDisco`. Additional information can be found in the [documentation](https://causaldisco.github.io/CausalDisco/).
### Baseline Algorithms
Find the following baseline algorithms in __CausalDisco/baselines.py__
- R²-SortnRegress
- Var-SortnRegress
- Random-SortnRegress
### Analytics Tools
Find the following analytics tools in __CausalDisco/analytics.py__
- R²-sortability
- Var-sortability
- order_alignment
### Sources
If you find our algorithms useful please consider citing
- [Beware of the Simulated DAG!](https://proceedings.neurips.cc/paper_files/paper/2021/file/e987eff4a7c7b7e580d659feb6f60c1a-Supplemental.pdf)
- [Simple Sorting Criteria Help Find the Causal Order in Additive Noise Models](https://arxiv.org/abs/2303.18211).
```
@article{reisach2021beware,
title={Beware of the Simulated DAG! Causal Discovery Benchmarks May Be Easy to Game},
author={Reisach, Alexander G. and Seiler, Christof and Weichwald, Sebastian},
journal={Advances in Neural Information Processing Systems},
volume={34},
year={2021}
}
@article{reisach2023simple,
title={Simple Sorting Criteria Help Find the Causal Order in Additive Noise Models},
author={Reisach, Alexander G. and Tami, Myriam and Seiler, Christof and Chambaz, Antoine and Weichwald, Sebastian},
journal={arXiv preprint arXiv:2303.18211},
year={2023}
}
```
### A Simple Example
```python
# --- sample data from a linear SCM:
import numpy as np
from scipy import linalg
from CausalDisco.analytics import var_sortability, r2_sortability
d = 10
W = np.diag(np.ones(d-1), 1)
X = np.random.randn(10000, d).dot(linalg.inv(np.eye(d) - W))
X_std = (X - np.mean(X, axis=0))/np.std(X, axis=0)
# --- run analytics and print results:
from CausalDisco.analytics import (
var_sortability,
r2_sortability,
snr_sortability
)
print(
f'True\n{W}\n'
f'var-sortability={var_sortability(X, W):.2f}\n'
f'R^2-sortability={r2_sortability(X, W):.2f}\n'
f'SNR-sortability={snr_sortability(X, W):.2f}'
)
# --- run baselines and print results:
from CausalDisco.baselines import (
random_sort_regress,
var_sort_regress,
r2_sort_regress
)
print(
f'True\n{W}\n'
'--- randomRegress ---\n'
f'Recovered:\n{1.0*(random_sort_regress(X)!=0)}\n'
f'Recovered standardized:\n{1.0*(random_sort_regress(X_std)!=0)}\n'
'--- varSortnRegress ---\n'
f'Recovered:\n{1.0*(var_sort_regress(X)!=0)}\n'
f'Recovered standardized:\n{1.0*(var_sort_regress(X_std)!=0)}\n'
'--- r2SortnRegress ---\n'
f'Recovered:\n{1.0*(r2_sort_regress(X)!=0)}\n'
f'Recovered standardized:\n{1.0*(r2_sort_regress(X_std)!=0)}\n'
)
```
Raw data
{
"_id": null,
"home_page": "",
"name": "CausalDisco",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "causality,causal discovery",
"author": "Alexander G. Reisach, Sebastian Weichwald",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/5c/4f/0b926c46d22f4348b65b38f28c163bf3f924e850295a36c0a0fda8f64ef4/causaldisco-0.2.0.tar.gz",
"platform": null,
"description": "[![Latest version](https://badge.fury.io/py/CausalDisco.svg)](https://badge.fury.io/py/CausalDisco)\n[![License: BSD](https://img.shields.io/badge/License-BSD-blue.svg)](https://github.com/CausalDisco/CausalDisco/blob/main/LICENSE)\n[![Downloads](https://static.pepy.tech/personalized-badge/CausalDisco?period=total&units=international_system&left_color=grey&right_color=green&left_text=Downloads)](https://pepy.tech/project/CausalDisco)\n\n\n# CausalDisco \ud83e\udea9\n\nCausalDisco contains baseline algorithms and analytics tools for Causal Discovery. The [package](https://pypi.org/project/CausalDisco/) can be installed by running `pip install CausalDisco`. Additional information can be found in the [documentation](https://causaldisco.github.io/CausalDisco/).\n\n### Baseline Algorithms\nFind the following baseline algorithms in __CausalDisco/baselines.py__\n- R\u00b2-SortnRegress\n- Var-SortnRegress\n- Random-SortnRegress\n\n### Analytics Tools\nFind the following analytics tools in __CausalDisco/analytics.py__\n- R\u00b2-sortability\n- Var-sortability\n- order_alignment\n\n### Sources\nIf you find our algorithms useful please consider citing\n- [Beware of the Simulated DAG!](https://proceedings.neurips.cc/paper_files/paper/2021/file/e987eff4a7c7b7e580d659feb6f60c1a-Supplemental.pdf)\n- [Simple Sorting Criteria Help Find the Causal Order in Additive Noise Models](https://arxiv.org/abs/2303.18211).\n```\n@article{reisach2021beware,\n title={Beware of the Simulated DAG! Causal Discovery Benchmarks May Be Easy to Game},\n author={Reisach, Alexander G. and Seiler, Christof and Weichwald, Sebastian},\n journal={Advances in Neural Information Processing Systems},\n volume={34},\n year={2021}\n}\n\n@article{reisach2023simple,\n title={Simple Sorting Criteria Help Find the Causal Order in Additive Noise Models},\n author={Reisach, Alexander G. and Tami, Myriam and Seiler, Christof and Chambaz, Antoine and Weichwald, Sebastian},\n journal={arXiv preprint arXiv:2303.18211},\n year={2023}\n}\n```\n\n### A Simple Example\n```python\n# --- sample data from a linear SCM:\n\nimport numpy as np\nfrom scipy import linalg\nfrom CausalDisco.analytics import var_sortability, r2_sortability\n\nd = 10\nW = np.diag(np.ones(d-1), 1)\nX = np.random.randn(10000, d).dot(linalg.inv(np.eye(d) - W))\nX_std = (X - np.mean(X, axis=0))/np.std(X, axis=0)\n\n# --- run analytics and print results:\n\nfrom CausalDisco.analytics import (\n var_sortability,\n r2_sortability,\n snr_sortability\n)\n\nprint(\n f'True\\n{W}\\n'\n f'var-sortability={var_sortability(X, W):.2f}\\n'\n f'R^2-sortability={r2_sortability(X, W):.2f}\\n'\n f'SNR-sortability={snr_sortability(X, W):.2f}'\n)\n\n# --- run baselines and print results:\n\nfrom CausalDisco.baselines import (\n random_sort_regress,\n var_sort_regress,\n r2_sort_regress\n)\n\nprint(\n f'True\\n{W}\\n'\n '--- randomRegress ---\\n'\n f'Recovered:\\n{1.0*(random_sort_regress(X)!=0)}\\n'\n f'Recovered standardized:\\n{1.0*(random_sort_regress(X_std)!=0)}\\n'\n '--- varSortnRegress ---\\n'\n f'Recovered:\\n{1.0*(var_sort_regress(X)!=0)}\\n'\n f'Recovered standardized:\\n{1.0*(var_sort_regress(X_std)!=0)}\\n'\n '--- r2SortnRegress ---\\n'\n f'Recovered:\\n{1.0*(r2_sort_regress(X)!=0)}\\n'\n f'Recovered standardized:\\n{1.0*(r2_sort_regress(X_std)!=0)}\\n'\n)\n```\n\n",
"bugtrack_url": null,
"license": "",
"summary": "Baseline algorithms and analytics tools for Causal Discovery.",
"version": "0.2.0",
"project_urls": null,
"split_keywords": [
"causality",
"causal discovery"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f165de0c5a284472ad2bfccf3827fb09cd16f9d2c5c700589daa44bf41f72687",
"md5": "db41f693a3c8f41e05f7071dc58ebb5c",
"sha256": "95015817a806595279788645ec37bba5b4e42aace7b9fa9949bace2369c46a43"
},
"downloads": -1,
"filename": "causaldisco-0.2.0-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "db41f693a3c8f41e05f7071dc58ebb5c",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 5569,
"upload_time": "2023-07-19T14:57:09",
"upload_time_iso_8601": "2023-07-19T14:57:09.445515Z",
"url": "https://files.pythonhosted.org/packages/f1/65/de0c5a284472ad2bfccf3827fb09cd16f9d2c5c700589daa44bf41f72687/causaldisco-0.2.0-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5c4f0b926c46d22f4348b65b38f28c163bf3f924e850295a36c0a0fda8f64ef4",
"md5": "e97460588b6063c0b51dfd9cd90c3213",
"sha256": "e1a120b99e4f773f73f26bf2f0de7e840f3224667f82b4e8698aea09c95ae0da"
},
"downloads": -1,
"filename": "causaldisco-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "e97460588b6063c0b51dfd9cd90c3213",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4110,
"upload_time": "2023-07-19T14:57:10",
"upload_time_iso_8601": "2023-07-19T14:57:10.872217Z",
"url": "https://files.pythonhosted.org/packages/5c/4f/0b926c46d22f4348b65b38f28c163bf3f924e850295a36c0a0fda8f64ef4/causaldisco-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-19 14:57:10",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "causaldisco"
}