Python implementation of the following paper
Causal Inference and Mechanism Clustering of A Mixture of Additive Noise Models.
Hu, Shoubo, Zhitang Chen, Vahid Partovi Nia, Laiwan Chan, and Yanhui Geng.
Advances in Neural Information Processing Systems. (NeurIPS) 2018.
- numpy
- scipy
- sklearn
We test the code using Anaconda 4.3.30 64-bit for python 2.7 on Windows 10. Any later version should still work perfectly.
After installing all required packages, you can run test.py to see whether ANM-MM() could work normally.
The test code does the following:
- it generates 100 observations (a (100, 2) numpy array) from two exponential functions. The first column is the cause
Xand the second is the effectY. - ANM-MM is applied on the generated data to first conduct clustering and then infer the causal direction.
Import ANM-MM using
from ANMMM import ANMMM_cd, ANMMM_cluApply ANM-MM on your data
# causal inference
direction = ANMMM_cd(data, lda)
# mechanism clustering
labels = ANMMM_clu(data, label, lda)Input of function ANMMM_cd() and ANMMM_clu()
| Argument | Description |
|---|---|
| data | Numpy array with 2 columns and any number of rows. Rows represent i.i.d. samples, The variables in the first and second column are called X and Y, respectively. |
| label | List of true labels of each observation. |
| lda | The parameter λ which controls the importance of HSIC term. |
Output of function ANMMM_cd()
| Argument | Description |
|---|---|
| direction | 1 - the first column is the cause; -1 - the second column is the cause; 0 - can not tell. |
Output of function ANMMM_clu()
| Argument | Description |
|---|---|
| labels | List of estimated clustering labels of each observation. |
- Shoubo Hu - shoubo [dot] sub [at] gmail [dot] com
- Zhitang Chen - chenzhitang2 [at] huawei [dot] com
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE file for details.
- Hat tip to James Hensman for his elegant GP-LVM code.