skcausal
skcausal is a machine learning library for estimating average causal responses from observational data. It uses one consistent fit(X, t, y) contract across categorical, continuous, and multi-column treatments, while letting you plug in familiar scikit-learn models for nuisance regression, density estimation, and final smoothing.
It is built around average potential outcomes and dose-response functions rather than per-unit counterfactual prediction.
Documentation | Continuous treatments | Categorical treatments | Multidimensional treatments
What The Package Includes
- Average causal response estimators for direct, GPS/IPW-style, and doubly robust workflows
- One public interface for categorical, continuous, and multidimensional treatment tables
- Treatment density estimators and density pipelines for nuisance modeling
- Synthetic and semi-synthetic datasets with known truth for benchmarking
- Discovery utilities for listing datasets, density estimators, and causal estimators
- Optional plotting helpers for comparing estimated curves against observed data or ground truth
Installation
Install the base package:
pip install skcausal
Optional extras:
pip install "skcausal[plotting]"
pip install "skcausal[torch]"
pip install "skcausal[optuna]"
pip install "skcausal[skpro]"
Core Contract
Average-response estimators follow the same public workflow:
estimator.fit(X, t, y)
curve = estimator.predict(requested_treatments)
Where:
Xcontains pre-treatment covariatestcontains the observed treatment tableycontains the observed outcome tablerequested_treatmentscontains the intervention levels or grid you want to evaluate
For categorical treatments, requested_treatments is usually a short table of valid levels. For continuous treatments, it is usually a dense treatment grid. Predictions return one average response per requested row, averaging over the covariate sample stored during fit.
Quick Start
The example below fits a continuous-treatment direct regression estimator on a synthetic dataset with known ground truth.
import numpy as np
from sklearn.ensemble import RandomForestRegressor
from skcausal.causal_estimators import DirectRegressor
from skcausal.datasets import SyntheticDataset2
from skcausal.utils.treatment_grid import make_cartesian_treatment_grid
dataset = SyntheticDataset2(n=2000, n_features=6, random_state=0)
X, t, y = dataset.load()
estimator = DirectRegressor(
outcome_regressor=RandomForestRegressor(
n_estimators=200,
min_samples_leaf=5,
random_state=0,
)
)
estimator.fit(X, t, y)
grid = make_cartesian_treatment_grid(t, n_continuous_points=25)
estimated_curve = estimator.predict(grid)
truth_curve = np.asarray(dataset.predict(X, grid)).reshape(-1)
This pattern generalizes across treatment types:
- Fit on aligned
X,t, andy - Create a treatment table that represents the interventions you want to query
- Call
predict(...)on that treatment table - On synthetic datasets, compare against
dataset.predict(X, requested_treatments)when ground truth is available
Choosing A Starting Estimator
| Setting | Good starting points |
|---|---|
| Categorical treatments | CategoricalDoublyRobust, CategoricalDirectMethod, CategoricalInversePropensityWeighting |
| Continuous treatments | DirectRegressor, GPS, DoublyRobustPseudoOutcome |
| Multidimensional treatments | DirectRegressor, GPS, DoublyRobustPseudoOutcome |
| Observational baseline only | DirectNoCovariates |
DirectNoCovariates is useful as a sanity-check baseline, but it does not adjust for confounding.
Discover Available Components
You can inspect the registered public objects programmatically:
from skcausal.utils.lookup import (
all_causal_average_response_estimators,
all_datasets,
all_density_estimators,
)
all_causal_average_response_estimators(
as_dataframe=True,
filter_tags={"capability:t_type": "continuous"},
return_tags=["capability:t_type", "capability:multidimensional_treatment"],
)
This is useful when you want to discover which estimators support a particular treatment type or whether an estimator handles multidimensional treatments.
Main Public Modules
skcausal.causal_estimators: average-response estimators and estimator pipelinesskcausal.density: treatment density estimators and density pipelinesskcausal.datasets: synthetic and semi-synthetic benchmark datasetsskcausal.plotting: optional plotting helpers for response curves and comparisonsskcausal.utils.lookup: object discovery helpers built on top ofskbase.lookup
Documentation
- Getting started
- Estimator contract
- Continuous-treatment workflow
- Categorical-treatment workflow
- Multidimensional-treatment workflow
- Dataset catalog
- Benchmarking notes
Scope
skcausal is designed around average-response estimation from observational data:
- Average potential outcomes for binary or categorical treatments
- Average dose-response functions for continuous treatments
- Average response surfaces for multidimensional treatments
It does not present predict(X_new) as the main API. Instead, prediction is framed around requested intervention tables, and estimators average over the covariate sample seen at fit time.
Metadata
Release files for skcausal 0.1.1
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 | |
|---|---|---|---|---|
| skcausal-0.1.1.tar.gz | 1.4 MB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| skcausal-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.5 MB
Release files / skcausal-0.1.1.tar.gz
| Download URL | skcausal-0.1.1.tar.gz |
|---|---|
| Size | 1.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
28b365554a2db95f26c4417e7c0265cd8ee4826e10b9b8f71a5700357456aa46
|
|
BLAKE2b-256 checksum How to use checksums |
b5df21a2b49474426acc560a6ff6a0d45b40a65a455ef65aaf3796caa4b1bac4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 4, 2026.
Transparency logRelease files / skcausal-0.1.1-py3-none-any.whl
| Download URL | skcausal-0.1.1-py3-none-any.whl |
|---|---|
| Size | 151.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ddeaec6076375bf05fb1cb9af60fbeaeea659ab7c86feeba63e1a1b57ef5b063
|
|
BLAKE2b-256 checksum How to use checksums |
b020a7f858777899b4bb95be493336f2227c809a9710f53c73b27312ad3878c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 4, 2026.
Transparency logSecurity for skcausal 0.1.1
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for skcausal-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 4, 2026.
Transparency logA 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.