Registry / ai-ml / causalml

causalml

JSON →
library0.16.0pypypiunverified

CausalML is a Python package for uplift modeling and causal inference with machine learning algorithms. It provides a variety of methods for causal inference in both experimental and observational settings, including meta-learners (S-Learner, T-Learner, X-Learner, R-Learner), tree-based methods (Causal Forest, Uplift Random Forest), and deep learning models. Current version: 0.16.0. Release cadence: irregular, with major updates approximately annually.

pip install causalml
INSTALL
IMPORT
SIG · CAUSALML
C
causalml
ai-mlpythonv0.16.0
Install
37.0s avg
Import
Disk
1459MB
Pass rate
4/ 10
Env Coverage4 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.15.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✕ build_error
✓ 36.6s
py 3.11
✕ build_error
✓ 35.05s
py 3.12
✕ build_error
✓ 35.6s
py 3.13
✕ build_error
✕ build_error
py 3.9
✕ build_error
✓ 40.7s
1459MB installed
● package 1459MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SLearner
from causalml.inference.meta import SLearner
from causalml.meta import SLearner
Since v0.12, meta-learners moved to causalml.inference.meta
CausalForest
from causalml.inference.forest import CausalForest
from causalml.forest import CausalForest
In v0.14, forest module moved to causalml.inference.forest
set_rfub
from causalml.propensity import set_rfub
from causalml.ufb import set_rfub
Propensity score utilities moved to causalml.propensity in v0.13

Generate synthetic data and train a simple meta-learner to estimate uplift.

import pandas as pd import numpy as np from causalml.dataset import make_uplift_classification from causalml.inference.meta import LRSLearner # Generate synthetic uplift data np.random.seed(42) df, x_names = make_uplift_classification(n_samples=1000, treatment_name=['treatment', 'control'], y_name='y', random_seed=42) # Train S-learner with logistic regression learner = LRSLearner() learner.fit(df[x_names].values, df['treatment'].values, df['y'].values) # Predict uplift for each sample uplift = learner.predict(df[x_names].values) uplift[:5]
Debug
Known issues
breakingIn v0.14, the causalml.inference.meta module was restructured. BaseLearner subclasses like SLearner, TLearner, XLearner no longer accept string params for model constructors; pass model objects directly.
fix
Use `from sklearn.linear_model import LogisticRegression; SLearner(learner=LogisticRegression())` instead of `SLearner(learner='lr')`
affects: >=0.14
breakingThe `causalml.inference.tree` module was removed in v0.15. Uplift tree models are now in `causalml.inference.forest` or should be imported from the forest module.
fix
Use `from causalml.inference.forest import UpliftRandomForestClassifier` instead of any import from `causalml.inference.tree`
affects: >=0.15
deprecatedThe function `causalml.dataset.synthetic_data` is deprecated in favor of `causalml.dataset.make_uplift_classification`.
fix
Replace `from causalml.dataset import synthetic_data` with `from causalml.dataset import make_uplift_classification`
affects: >=0.13
gotchaCausalML's feature importance methods (e.g., `plot_importance()`) may produce different scales than sklearn's built-in importance. Interpretation is relative, not absolute.
fix
Use importance values for ranking features only, not for hypothesis testing.
affects: all
gotchaWhen using S-Learner or T-Learner with categorical features, ensure you one-hot encode them first. The underlying models may not handle cat codes correctly.
fix
Use `pandas.get_dummies()` or `sklearn.preprocessing.OneHotEncoder` before fitting.
affects: all
deprecatedThe `causalml.inference.meta.USM` (Uplift S-Model) class is deprecated as of v0.16. Use `SClassifier` or `SRegressor` instead.
fix
Replace `from causalml.inference.meta import USM` with `from causalml.inference.meta import SClassifier`
affects: >=0.16
Upgrade
Version history
0.16.0latest on PyPI · released Feb 6, 2026
Audit
Dependencies
scikit-learnrequiredCore dependency for model training and evaluation
xgboostrequiredRequired for gradient-boosted tree models
lightgbmoptionalAlternative boosting backend
tensorflowoptionalRequired for neural network models (CEVAE, DragonNet)
Agent activity
29 hits · last 30 days
node
26
OpenAI (training)
1
Resources
causalml — pip install causalml · libregistry