Skip to content

Commit

Permalink
Implement adaptive clipping switch
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancescMartiEscofetQC committed Jul 10, 2024
1 parent 1580c96 commit 8fa0c10
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions metalearners/drlearner.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ def _pseudo_outcome(
is_oos: bool,
oos_method: OosMethod = OVERALL,
epsilon: float = _EPSILON,
adaptive_clipping: bool = False,
) -> np.ndarray:
"""Compute the DR-Learner pseudo outcome."""
validate_valid_treatment_variant_not_control(treatment_variant, self.n_variants)
Expand Down Expand Up @@ -317,4 +318,12 @@ def _pseudo_outcome(
- y0_estimate
)

if adaptive_clipping:
t_pseudo_outcome = y1_estimate - y0_estimate
pseudo_outcome = np.where(

Check warning on line 323 in metalearners/drlearner.py

View check run for this annotation

Codecov / codecov/patch

metalearners/drlearner.py#L322-L323

Added lines #L322 - L323 were not covered by tests
propensity_estimates.min(axis=1) < epsilon,
t_pseudo_outcome,
pseudo_outcome,
)

return pseudo_outcome

0 comments on commit 8fa0c10

Please sign in to comment.