ICPy
This packages provides a simple python implementation of Invariant Causal Prediction (ICP) [1].
The source code for the actual algorithm resides in ./src/icp/ICP.py.
See also the original implementation in the R package InvariantCausalPrediction.
Installation
pip install ICPy
Usage
import icpy as icpy
import numpy as np
np.random.seed(seed=1)
n = 100
noise = 0.1
E = np.repeat([0, 1, 2], np.ceil(n / 3.0))[0:n] # "Environment"
A = np.random.normal(scale=noise, size=[n]) + np.equal(E, 1) # Node A
B = A + np.random.normal(scale=noise, size=[n]) / 3 + np.equal(E, 2) # Node B
C = B + np.random.normal(scale=noise, size=[n]) # Node C
# /--->---\
# E -> A -> B -> C
icpy.invariant_causal_prediction(X=np.column_stack((A, B)), y=C, z=E) # test if A or B are parents of C
Output
ICP(S_hat=array([1], dtype=int64), # Column 1 = Node B was (correctly) identified as parent of C
p_values=array([ 1.51508232e-01, 4.59577055e-37]), # error levels at which A and B would/are indentied as parent of C
p_value=0.16416488336322549) # p-value for testing against violation of the model assumptions (e.g. a direct effect of E on C)
News
v0.0.003 (2020-05-15)
- fix failing import (thanks to @lgmoneda, #1)
- fix issues when environments are not subsequent whole numbers starting at 0 (thanks to @lgmoneda, #1)
References
[1] J. Peters, P. Bühlmann, N. Meinshausen, Causal inference by using invariant prediction: identification and confidence intervals, J. R. Stat. Soc. Ser. B Stat. Methodol. 78 (2016) 947-1012. doi:10.1111/rssb.12167.
Metadata
Release files for ICPy 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ICPy-0.0.6.tar.gz | 5.6 kB | Without provenance | Details for ICPy-0.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ICPy-0.0.6-py3-none-any.whl | Python 3 | none | any | Details for ICPy-0.0.6-py3-none-any.whl |
Total release size: 10.3 kB
Release files / ICPy-0.0.6.tar.gz
| Download URL | ICPy-0.0.6.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2f65df7f9d9be6f6bd52a77ffc8f0858aaa2c6dd4fc7958a278fb3f15cc2b538
|
|
BLAKE2b-256 checksum How to use checksums |
c225bf3d0b8f852f71d2808c180dbb126c16e2abd00bd5bf8a9cb0fc505e046a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.9.19
|
Release files / ICPy-0.0.6-py3-none-any.whl
| Download URL | ICPy-0.0.6-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e92a09337721b06543af3c3d95ce119c3276aa004c156e19c1cf037bc7c5f83c
|
|
BLAKE2b-256 checksum How to use checksums |
f95de7ca0300393659771690a65437e8ad2321cc6c2da42fa5c87130d164529d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.9.19
|
Security for ICPy 0.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.