Skip to content

rlearner_score still requires outcome_learner while its siblings default to LightGBM #1034

Description

@jeongyoonlee

#1030 gave compute_dr_pseudo_outcomes (cate_scoring.py:63), dr_score (:275) and plug_in_t_score (:399) a default LGBMRegressor(num_leaves=64, learning_rate=0.05, n_estimators=300, verbose=-1). rlearner_score (:499) was not touched, so outcome_learner (:506) is still required:

from causalml.metrics import rlearner_score
rlearner_score(df, X=X, outcome_col="y", treatment_col="w")
# AssertionError: Either `y_residual_col`/`w_residual_col` (present in df) or `X` and
# `outcome_learner` (to compute residuals internally) must be provided.

The rationale in #1028 — that the sibling metrics in causalml.metrics default to LightGBM — applies to rlearner_score identically, and after #1030 the module is inconsistent with itself.

Two changes, both in causalml/metrics/cate_scoring.py:

  1. Give outcome_learner (:506) the same signature default as its three siblings.
  2. Replace the bare asserts at :567 and :582 with ValueError. Asserts are stripped under python -O, so the guard silently disappears and the failure resurfaces later as a confusing error inside the residual computation. (dr_score and plug_in_t_score have the same pattern at :350, :364 and :452 — worth converting in the same pass.)

Scope: one module. No behavior change for callers who already pass outcome_learner.

Observed on master (477cd0a).

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions