Python causal inference modules
Project description
Pycausal-explorer
Pycausal-explorer is a python module for causal inference and treatment effect estimation. It implements a set of algorithms that supports causal analysis.
Installation Guide
You can install the package through pip:
pip install pycausal-explorer
Basic Usage
All models are inherited from BaseCausalModel, that inherits from scikit-learn BaseEstimator. It uses scikit-learn framework to fit and predict the outcome. It implements predict_ite and predict_ate methods that return the individual treatment effect and the average treatment effect, respectively.
from pycausal_explorer.datasets.synthetic import create_synthetic_data
from pycausal_explorer.meta import XLearner
x, treatment, y = create_synthetic_data()
model = XLearner()
model.fit(x, treatment, y)
treatment_effect = model.predict_ite(x)
Current Implemented Models
This version currently implements propensity score and iptw in the reweight package, linear regression in the linear package, causal forests in forest package and x-learn in meta package.
Using Pipelines
Pycausal-explorer has a Pipeline class inherited from scikit-learn Pipeline. It implements the method predict_ite, so it can be used pro predict treatment effect in a pipeline:
from sklearn.preprocessing import StandardScaler
from pycausal_explorer.datasets.synthetic import create_synthetic_data
from pycausal_explorer.pipeline import Pipeline
from pycausal_explorer.reweight import IPTW
x, w, y = create_synthetic_data()
pipe = Pipeline([("norm", StandardScaler()), ("clf", IPTW())])
pipe.fit(x, y, clf__treatment=w)
treatment_effect = pipe.predict_ite(x)
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 Distribution
Hashes for pycausal_explorer-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7940c6cb08ecd36480ac11149848a2dc72b1cc0f1d6d7638cdb3039375a9f3da |
|
MD5 | 877e48996a3a75d4721ccf0303864f1f |
|
BLAKE2b-256 | 7e2eac1ea3c558624437b5c3ec9c1c26fe3f72908471cdc419aee56f8142032c |