CCPFN: Causal Foundation Model for Continuous Treatments
Project description
This is the repository for inference with CCPFN (Continuous Causal Prior-Fitted Network), a causal foundation model for use in domains with a continuous treatment variable. This setting often requires the estimation of a full treatment-response curve, a non-trivial task as illustrated in Figure 1. Observational (historic) data is supplied as context, and queries are passed at inference time. No further training is required. This is the inference repository; the full research reposistory (including training code and our prior) is forthcoming.
Figure 1: Estimating causal effects for continuous treatments (right) is much more challenging than
for binary treatments (left), as multiple treatment-response curves fit the observed data equally well.
Quick Start
Install with pip:
pip install ccpfn
Model weights are available on Hugging Face and will be automatically downloaded on first use.
To install from source, ensure you have Python ≥3.10. Then run the following:
git clone https://github.com/layer6ai-labs/CCPFN-inference.git
cd CCPFN-inference
pip install -e .
Example notebooks on CCPFN usage, including individual treatment-response curve reconstruction tasks, can be found in the notebooks directory. Here is a simple example demonstrating how to run CCPFN for conditional expected potential outcome (CEPO) estimation:
import numpy as np
import torch
from ccpfn import CEPOEstimator
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
# Define true individual treatment-response function
def treatment_response(x, t):
return np.cos(x[..., 0]) + 2 * x[..., 1] * t
# Define treatment assignment function
def treatment(x):
return 1 + np.sin(x[..., 2])
# Create synthetic data - covariates, treatment, outcome
rng = np.random.default_rng(seed=42)
n_samples, n_features = 2048, 3
X = rng.standard_normal((n_samples, n_features))
T = treatment(X)
Y = treatment_response(X, T) + 0.1 * rng.standard_normal((n_samples,))
# Context/query (train/test) split
test_ratio = 0.3
ctx_idx = rng.choice(n_samples, int((1 - test_ratio) * n_samples), replace=False)
qry_idx = np.setdiff1d(np.arange(n_samples), ctx_idx)
X_ctx, X_qry = X[ctx_idx], X[qry_idx]
T_ctx, Y_ctx = T[ctx_idx], Y[ctx_idx]
T_qry = rng.random((X_qry.shape[0],)) # Counterfactual treatments
# CEPO Estimation
estimator = CEPOEstimator(device=device)
estimator.fit(X_ctx, T_ctx, Y_ctx)
cepo_pred = estimator.estimate_cepo(X_qry, T_qry)
# Evaluation and results
cepo_true = treatment_response(X_qry, T_qry)
rmse = np.sqrt(np.mean((cepo_true - cepo_pred) ** 2))
print("Results:")
print(f"RMSE: {rmse:.4f}")
Overview
CCPFN uses in-context learning (ICL) to estimate the effects of a continuously-varying treatment (for example, the dosage of a medication, or the sensitivity of economic outcomes to prices or rates). Specifically, it estimates the conditional expected potential outcome (CEPO), defined as $𝔼[Y(t) \mid X = x]$.
Our model achieves state-of-the-art performance on individual treatment-response curve reconstruction tasks compared to causal models which are trained specifically for those tasks.
Table 1: Comparative evaluation of mean MISE across benchmark test datasets. Columns correspond
to different benchmark datasets; values represent mean MISE ± standard deviation as computed
with 5-fold cross-validation. First place is bold, second place is underlined. Dashes (—) indicate no
meaningful results were obtained. When evaluating TabPFN we apply PCA to reduce the dimension
to 100, due to memory constraints and to match the dimensionality reduction used in CCPFN. DRNet,
VCNet, and EBCT did not produce meaningful results for the MISE metric and hence are omitted.
Figure 2: Predicted individual treatment-response curves (ITRCs) and true ITRC for two randomly selected individuals from the Warfarin benchmark, where the outcome represents the loss between a patient’s administered dose and the optimal dose, as determined by the IWPC pharmacogenetic dosing algorithm.
Citation
title={Causal Foundation Models with Continuous Treatments},
author={Christopher Stith and Medha Barath and Vahid Balazadeh and Jesse C. Cresswell and Rahul G. Krishnan},
year={2026},
eprint={2605.15133},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2605.15133},
}
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
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 ccpfn-0.1.2.tar.gz.
File metadata
- Download URL: ccpfn-0.1.2.tar.gz
- Upload date:
- Size: 602.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f98eab5f583fbcaffc0c79cb17e9ea63a4ca3cec21e281270bc355d473341076
|
|
| MD5 |
fec3a8abcf682f71e924793c54630b16
|
|
| BLAKE2b-256 |
feee60235b32d9c67af4b919f115ee0b977ecd86a00c0edb9c254c75ab399238
|
File details
Details for the file ccpfn-0.1.2-py3-none-any.whl.
File metadata
- Download URL: ccpfn-0.1.2-py3-none-any.whl
- Upload date:
- Size: 20.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
132f1b0c8bcaa9a391551a49206eca815bbbb7f357ee8b0d1d0b9d8ca595b3be
|
|
| MD5 |
0ba83e911041936c75cc9b7678e51daf
|
|
| BLAKE2b-256 |
cc1b64df1434cb68b7921f09bd7007be895e616872031aaa92633b4625b0402d
|