Skip to main content

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:

  • X contains pre-treatment covariates
  • t contains the observed treatment table
  • y contains the observed outcome table
  • requested_treatments contains 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, and y
  • 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 pipelines
  • skcausal.density: treatment density estimators and density pipelines
  • skcausal.datasets: synthetic and semi-synthetic benchmark datasets
  • skcausal.plotting: optional plotting helpers for response curves and comparisons
  • skcausal.utils.lookup: object discovery helpers built on top of skbase.lookup

Documentation

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

skcausal-0.1.1.tar.gz (1.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

skcausal-0.1.1-py3-none-any.whl (151.6 kB view details)

Uploaded Python 3

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

Hashes for skcausal-0.1.1.tar.gz
Algorithm Hash digest
SHA256 28b365554a2db95f26c4417e7c0265cd8ee4826e10b9b8f71a5700357456aa46
MD5 926f0b10d27d0cf80399486fa68bdb8e
BLAKE2b-256 b5df21a2b49474426acc560a6ff6a0d45b40a65a455ef65aaf3796caa4b1bac4

See more details on using hashes here.

Provenance

The following attestation bundles were made for skcausal-0.1.1.tar.gz:

Publisher: release.yml on felipeangelimvieira/skcausal

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for skcausal-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ddeaec6076375bf05fb1cb9af60fbeaeea659ab7c86feeba63e1a1b57ef5b063
MD5 8f045cf78fb52a326b6f4d11d206f82f
BLAKE2b-256 b020a7f858777899b4bb95be493336f2227c809a9710f53c73b27312ad3878c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for skcausal-0.1.1-py3-none-any.whl:

Publisher: release.yml on felipeangelimvieira/skcausal

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page