Add XGBTClassifier and XGBRClassifier meta-learners (#824)#942
Open
jeongyoonlee wants to merge 1 commit into
Open
Add XGBTClassifier and XGBRClassifier meta-learners (#824)#942jeongyoonlee wants to merge 1 commit into
jeongyoonlee wants to merge 1 commit into
Conversation
Add XGBoost-backed classifier variants of the T- and R-learners, mirroring the existing XGBTRegressor / XGBRRegressor. Both follow the post-#912 scikit-learn BaseEstimator convention: constructor arguments are stored verbatim and the XGBoost models are constructed in fit(), so get_params() / clone() round-trip correctly (verified by clone tests). XGBTClassifier builds XGBClassifier outcome models; XGBRClassifier uses an XGBClassifier outcome model (predict_proba drives the outcome cross-fit) and an XGBRegressor effect model, initializing through the grandparent BaseRLearner to bypass BaseRClassifier's both-learners-None guard. Both are re-exported from causalml.inference.meta. Reimplements the work of @jbbqqf in #899 (CLA-blocked). Closes #824.
jeongyoonlee
requested review from
alexander-pv,
huigangchen,
paullo0106,
ppstacy,
ras44,
t-tte,
vincewu51 and
zhenyuz0500
July 14, 2026 17:34
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
Add XGBoost-backed classifier variants of the T- and R-learners —
XGBTClassifierandXGBRClassifier— mirroring the existingXGBTRegressor/XGBRRegressor, and re-export both fromcausalml.inference.meta.XGBTClassifier(BaseTClassifier)— buildsXGBClassifieroutcome models for control and each treatment group.XGBRClassifier(BaseRClassifier)— uses anXGBClassifieroutcome model (itspredict_probadrives the outcome cross-fit) and anXGBRegressoreffect model. It initializes through the grandparentBaseRLearnerto bypassBaseRClassifier's both-learners-Noneguard, since the learners are constructed infit().Both follow the post-#912 scikit-learn
BaseEstimatorconvention: constructor arguments are stored verbatim and the XGBoost models are constructed infit(), soget_params()/clone()round-trip correctly. XGBoost hyperparameters are passed as dicts (xgb_kwargsfor the T-learner;outcome_xgb_kwargs/effect_xgb_kwargsfor the R-learner) and forwarded verbatim — no*args/**kwargsin__init__, which would breakclone().Fixes #824.
Credit
Reimplements the work of @jbbqqf in #899, which is CLA-blocked and cannot be merged directly. Full credit to @jbbqqf for the original implementation and analysis; this PR re-lands the feature against current
masterunder a CLA-clean author, adapted to theBaseEstimatorrefactor (#912) that merged since.Types of changes
Tests
test_XGBTClassifier/test_XGBRClassifier— fit on the synthetic classification data, assert the underlying model types (XGBClassifieroutcome,XGBRegressoreffect), thatxgb_kwargsare forwarded, and normalized AUUC > 0.5.test_xgbt_classifier_clone/test_xgbr_classifier_clone—clone()/get_params()round-trip returning an unfitted estimator._CLASSIFIER_CONFIGS, so the sharedtest_fit_returns_self_classifierandtest_clone_get_params_classifiercover them too.tests/test_meta_learners.py— 74 passed. The new tests fail onmaster(classes don't exist).