No project description provided
Project description
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.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file skcausal-0.1.1.tar.gz.
File metadata
- Download URL: skcausal-0.1.1.tar.gz
- Upload date:
- Size: 1.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28b365554a2db95f26c4417e7c0265cd8ee4826e10b9b8f71a5700357456aa46
|
|
| MD5 |
926f0b10d27d0cf80399486fa68bdb8e
|
|
| BLAKE2b-256 |
b5df21a2b49474426acc560a6ff6a0d45b40a65a455ef65aaf3796caa4b1bac4
|
Provenance
The following attestation bundles were made for skcausal-0.1.1.tar.gz:
Publisher:
release.yml on felipeangelimvieira/skcausal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
skcausal-0.1.1.tar.gz -
Subject digest:
28b365554a2db95f26c4417e7c0265cd8ee4826e10b9b8f71a5700357456aa46 - Sigstore transparency entry: 1436456514
- Sigstore integration time:
-
Permalink:
felipeangelimvieira/skcausal@b6ff541f0d38e49e1f7df22061b7a0d24577d865 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/felipeangelimvieira
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b6ff541f0d38e49e1f7df22061b7a0d24577d865 -
Trigger Event:
release
-
Statement type:
File details
Details for the file skcausal-0.1.1-py3-none-any.whl.
File metadata
- Download URL: skcausal-0.1.1-py3-none-any.whl
- Upload date:
- Size: 151.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ddeaec6076375bf05fb1cb9af60fbeaeea659ab7c86feeba63e1a1b57ef5b063
|
|
| MD5 |
8f045cf78fb52a326b6f4d11d206f82f
|
|
| BLAKE2b-256 |
b020a7f858777899b4bb95be493336f2227c809a9710f53c73b27312ad3878c2
|
Provenance
The following attestation bundles were made for skcausal-0.1.1-py3-none-any.whl:
Publisher:
release.yml on felipeangelimvieira/skcausal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
skcausal-0.1.1-py3-none-any.whl -
Subject digest:
ddeaec6076375bf05fb1cb9af60fbeaeea659ab7c86feeba63e1a1b57ef5b063 - Sigstore transparency entry: 1436456544
- Sigstore integration time:
-
Permalink:
felipeangelimvieira/skcausal@b6ff541f0d38e49e1f7df22061b7a0d24577d865 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/felipeangelimvieira
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b6ff541f0d38e49e1f7df22061b7a0d24577d865 -
Trigger Event:
release
-
Statement type: