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 causalmlVerified import paths — ran on the pinned version, not inferred.
Generate synthetic data and train a simple meta-learner to estimate uplift.
Use `from sklearn.linear_model import LogisticRegression; SLearner(learner=LogisticRegression())` instead of `SLearner(learner='lr')`
Use `from causalml.inference.forest import UpliftRandomForestClassifier` instead of any import from `causalml.inference.tree`
Replace `from causalml.dataset import synthetic_data` with `from causalml.dataset import make_uplift_classification`
Use importance values for ranking features only, not for hypothesis testing.
Use `pandas.get_dummies()` or `sklearn.preprocessing.OneHotEncoder` before fitting.
Replace `from causalml.inference.meta import USM` with `from causalml.inference.meta import SClassifier`