Skip to main content

codecov Code style: black

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)

Metadata

Release files for pycausal-explorer 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pycausal-explorer 0.2.0
File Size Uploaded
pycausal-explorer-0.2.0.tar.gz 14.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pycausal-explorer 0.2.0
File Interpreter ABI Platform
pycausal_explorer-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 35.4 kB

Release files / pycausal-explorer-0.2.0.tar.gz

Download URL pycausal-explorer-0.2.0.tar.gz
Size 14.4 kB
Tags Source
SHA-256 checksum
How to use checksums
9275638038fbba7e4d8d2ba12aca30cb2ab0ca1dc512d02b133e6dd6a903849a
BLAKE2b-256 checksum
How to use checksums
ffb352255e28f10c640773ddaef6debeeb8c474587233727be3ee5bc12c943a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.12

Release files / pycausal_explorer-0.2.0-py3-none-any.whl

Download URL pycausal_explorer-0.2.0-py3-none-any.whl
Size 21.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d4c2fdfd99958045fbfc5808fa54d7e638d2c33fc1bf3d50f837ac9f7653336f
BLAKE2b-256 checksum
How to use checksums
1577973e7e4c623c92f671f3bbcf5af242775467f5bdff8ebcc7fac581846f58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.12

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page