导语


Causal Discovery Toolbox (cdt)是一个应用于图模型和Pyhton >=3.5 版本中的因果推断工具箱。包含了图结构恢复和相关依赖。该工具箱基于以下模块和语言构建:Numpy、Sciki-learn、Pytorch、R。


该工具箱包含了很多基于观测数据进行图结构恢复的算法(诸如 bnlearn、pcalg 算法)。

Leo | 编译

邓一雪 | 编辑


 

文档题目:
Causal Discovery Toolbox Documentation ‒ Causal Discovery Toolbox 0.5.23 documentation
文档链接:
https://fentechsolutions.github.io/CausalDiscoveryToolbox/html/index.html





Docker 镜像




该工具箱提供了Docker镜像,镜像中包含了所有依赖和启动项。


安装


需要版本号不低于 3.5 的Pyhton,以及 requirements.txt 中所列举出的模块。如果需要使用额外的功能则需要安装更多的模块。在安装指南中可以看到最小安装和完全安装的方式。


注意:对于非专业用户而言,(mini/ana) conda 框架有助于管理相关依赖。请查阅官网 http://pytorch.org 获取相关的配置信息。


安装 PyTorch


由于cdt(CausalDiscoveryToolbox)模块模块中的关键算法使用了 PyTorch 模块,所以需要安装PyTorch。


通过 PyPi 安装 CausalDiscoveryToolbox


可通过PyPi安装相关模块:

pip install cdt

也可以通过源代码安装

$ git clone https://github.com/FenTechSolutions/CausalDiscoveryToolbox.git  # Download the package

$ cd CausalDiscoveryToolbox

$ pip install -r requirements.txt  # Install the requirements

$ python setup.py install develop --user


安装完成后就可以导入运行模块。CausalDiscoveryToolbox 中的大多数算法应该都可以使用,不可用的算法会看到警告。


可通过一下方式导入模块:

import cdt

文档中包含了该模块的额外信息:

https://github.com/FenTechSolutions/CausalDiscoveryToolbox/blob/master/documentation.md


R语言与R语言库


如果要在使用 cdt 模块中,使用诸如 nlearn、kpcalg、pcalg 等由 R 语言编写的的算法,就需要安装 R 语言。


travis.yml 文件的预安装部分可以查看基于 Debian 的R语言安装依赖。r-requirements 文件则包含了 cdt 模块所需要的 R 语言包。





文件总览




模块包结构


下图展现了相关的模块与算法包结构


硬件与算法设置


该工具箱有一个SETTING类可用于对硬件进行设置。这些设置是唯一的。默认参数定义于cdt/utils/Settings


可以通过一下代码访问并修改配置

import cdt

cdt.SETTINGS


此外在启动时,可以使用 cdt.utils.Settings.autoset_settings 方法来自动配置硬件参数(例如,GPU,CPU数量,可选软件包的数量)


图类


相关模块用到了两个基于 networkx 的类,分别是:DiGraph 和 Graph。



参考


[1] Wang, S., Nan, B., Rosset, S., & Zhu, J. (2011). Random lasso. The annals of applied statistics, 5(1), 468.

[2] Friedman, J., Hastie, T., & Tibshirani, R. (2008). Sparse inverse covariance estimation with the graphical lasso. Biostatistics, 9(3), 432-441.

[3] Yamada, M., Jitkrittum, W., Sigal, L., Xing, E. P., & Sugiyama, M. (2014). High-dimensional feature selection by feature-wise kernelized lasso. Neural computation, 26(1), 185-207.

[4] Feizi, S., Marbach, D., Médard, M., & Kellis, M. (2013). Network deconvolution as a general method to distinguish direct dependencies in networks. Nature biotechnology, 31(8), 726-733.

[5] Guyon, I., Weston, J., Barnhill, S., & Vapnik, V. (2002). Gene selection for cancer classification using support vector machines. Machine learning, 46(1), 389-422.

[6] Vapnik, V., Golowich, S. E., & Smola, A. J. (1997). Support vector method for function approximation, regression estimation and signal processing. In Advances in neural information processing systems (pp. 281-287).

[7] Kira, K., & Rendell, L. A. (1992, July). The feature selection problem: Traditional methods and a new algorithm. In Aaai (Vol. 2, pp. 129-134).

[8] MacKay, D. J. (1992). Bayesian interpolation. Neural Computation, 4, 415–447.

[9] Neal, R. M. (1996). Bayesian learning for neural networks. No. 118 in Lecture Notes in Statistics. New York: Springer.

[10] Gretton, A., Bousquet, O., Smola, A., & Scholkopf, B. (2005, October). Measuring statistical dependence with Hilbert-Schmidt norms. In ALT (Vol. 16, pp. 63-78).

[11] Vinh, N. X., Epps, J., & Bailey, J. (2010). Information theoretic measures for clusterings comparison: Variants, properties, normalization and correction for chance. Journal of Machine Learning Research, 11(Oct), 2837-2854.

[12] Goudet, O., Kalainathan, D., Caillou, P., Lopez-Paz, D., Guyon, I., Sebag, M., … & Tubaro, P. (2017). Learning functional causal models with generative neural networks. arXiv preprint arXiv:1709.05321.

[13] Spirtes, P., Glymour, C., Scheines, R. (2000). Causation, Prediction, and Search. MIT press.

[14] Hoyer, P. O., Janzing, D., Mooij, J. M., Peters, J., & Schölkopf, B. (2009). Nonlinear causal discovery with additive noise models. In Advances in neural information processing systems (pp. 689-696).

[15] Janzing, D., Mooij, J., Zhang, K., Lemeire, J., Zscheischler, J., Daniušis, P., … & Schölkopf, B. (2012). Information-geometric approach to inferring causal directions. Artificial Intelligence, 182, 1-31.

[16] Lopez-Paz, D., Muandet, K., Schölkopf, B., & Tolstikhin, I. (2015, June). Towards a learning theory of cause-effect inference. In International Conference on Machine Learning (pp. 1452-1461).

[17] Lopez-Paz, D., Nishihara, R., Chintala, S., Schölkopf, B., & Bottou, L. (2017, July). Discovering causal signals in images. In Proceedings of CVPR.

[18] Stegle, O., Janzing, D., Zhang, K., Mooij, J. M., & Schölkopf, B. (2010). Probabilistic latent variable models for distinguishing between cause and effect. In Advances in Neural Information Processing Systems (pp. 1687-1695).

[19] Zhang, K., & Hyvärinen, A. (2009, June). On the identifiability of the post-nonlinear causal model. In Proceedings of the twenty-fifth conference on uncertainty in artificial intelligence (pp. 647-655). AUAI Press.

[20] Fonollosa, J. A. (2016). Conditional distribution variability measures for causality detection. arXiv preprint arXiv:1601.06680.

[21] Gretton, A., Borgwardt, K. M., Rasch, M. J., Schölkopf, B., & Smola, A. (2012). A kernel two-sample test. Journal of Machine Learning Research, 13(Mar), 723-773.

[22] Li, Y., Swersky, K., & Zemel, R. (2015). Generative moment matching networks. In Proceedings of the 32nd International Conference on Machine Learning (ICML-15) (pp. 1718-1727).

[23] Margaritis D (2003). Learning Bayesian Network Model Structure from Data . Ph.D. thesis, School of Computer Science, Carnegie-Mellon University, Pittsburgh, PA. Available as Technical Report CMU-CS-03-153

[24] Tsamardinos I, Aliferis CF, Statnikov A (2003). “Algorithms for Large Scale Markov Blanket Discovery”. In “Proceedings of the Sixteenth International Florida Artificial Intelligence Research Society Conference”, pp. 376-381. AAAI Press.

[25] Tsamardinos I, Aliferis CF, Statnikov A (2003). “Time and Sample Efficient Discovery of Markov Blankets and Direct Causal Relations”. In “KDD ’03: Proceedings of the Ninth ACM SIGKDD International Conference on Knowledge Discovery and Data Mining”, pp. 673-678. ACM. Tsamardinos I, Brown LE, Aliferis CF (2006). “The Max-Min Hill-Climbing Bayesian Network Structure Learning Algorithm”. Machine Learning,65(1), 31-78.

[26] Kalainathan, Diviyan & Goudet, Olivier & Guyon, Isabelle & Lopez-Paz, David & Sebag, Michèle. (2018). SAM: Structural Agnostic Model, Causal Discovery and Penalized Adversarial Learning.

[27] Aragam, B., & Zhou, Q. (2015). Concave penalized estimation of sparse Gaussian Bayesian networks. Journal of Machine Learning Research, 16, 2273-2328.

[28] Bloebaum, P., Janzing, D., Washio, T., Shimizu, S., & Schoelkopf, B. (2018, March). Cause-Effect Inference by Comparing Regression Errors. In International Conference on Artificial Intelligence and Statistics (pp. 900-909).

[29] Structural Intervention Distance (SID) for Evaluating Causal Graphs, Jonas Peters, Peter Bühlmann: https://arxiv.org/abs/1306.1043


(参考文献可上下滑动查看)



因果科学读书会第三季


由智源社区、集智俱乐部联合举办的因果科学与Causal AI读书会第三季将主要面向两类人群:如果你从事计算机相关方向研究,希望为不同领域引入新的计算方法,通过大数据、新算法得到新成果,可以通过读书会各个领域的核心因果问题介绍和论文推荐快速入手;如果你从事其他理工科或人文社科领域研究,也可以通过所属领域的因果研究综述介绍和研讨已有工作的示例代码,在自己的研究中快速开始尝试部署结合因果的算法。读书自2021年10月24日开始,每周日上午 10:00-12:00举办,持续时间预计 2-3 个月。



详情请见:

因果+X:解决多学科领域的因果问题 | 因果科学读书会第三季启动



推荐阅读



点击“阅读原文”,报名读书会