Skip to content

Add XGBTClassifier and XGBRClassifier meta-learners (#824)#942

Open
jeongyoonlee wants to merge 1 commit into
masterfrom
feature/824-xgb-classifier-subclasses
Open

Add XGBTClassifier and XGBRClassifier meta-learners (#824)#942
jeongyoonlee wants to merge 1 commit into
masterfrom
feature/824-xgb-classifier-subclasses

Conversation

@jeongyoonlee

Copy link
Copy Markdown
Collaborator

Proposed changes

Add XGBoost-backed classifier variants of the T- and R-learners — XGBTClassifier and XGBRClassifier — mirroring the existing XGBTRegressor / XGBRRegressor, and re-export both from causalml.inference.meta.

  • XGBTClassifier(BaseTClassifier) — builds XGBClassifier outcome models for control and each treatment group.
  • XGBRClassifier(BaseRClassifier) — uses an XGBClassifier outcome model (its predict_proba drives the outcome cross-fit) and an XGBRegressor effect model. It initializes through the grandparent BaseRLearner to bypass BaseRClassifier's both-learners-None guard, since the learners are constructed in fit().

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. XGBoost hyperparameters are passed as dicts (xgb_kwargs for the T-learner; outcome_xgb_kwargs / effect_xgb_kwargs for the R-learner) and forwarded verbatim — no *args / **kwargs in __init__, which would break clone().

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 master under a CLA-clean author, adapted to the BaseEstimator refactor (#912) that merged since.

Types of changes

  • New feature (non-breaking change which adds functionality)

Tests

  • test_XGBTClassifier / test_XGBRClassifier — fit on the synthetic classification data, assert the underlying model types (XGBClassifier outcome, XGBRegressor effect), that xgb_kwargs are forwarded, and normalized AUUC > 0.5.
  • test_xgbt_classifier_clone / test_xgbr_classifier_cloneclone() / get_params() round-trip returning an unfitted estimator.
  • Both classes added to _CLASSIFIER_CONFIGS, so the shared test_fit_returns_self_classifier and test_clone_get_params_classifier cover them too.
  • Full tests/test_meta_learners.py — 74 passed. The new tests fail on master (classes don't exist).

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XGB Classifier for T Learner and R Learner

1 participant