Skip to content

Commit 3949c1d

Browse files
kbattocchiCopilot
andauthored
Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Keith Battocchi <kbattocchi@gmail.com>
1 parent 2c68a8f commit 3949c1d

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

econml/dr/_drlearner.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,14 @@ def _compute_trim_mask(self, T_pred):
219219
trim_mask : ndarray of shape (n_samples,), dtype bool
220220
True for samples to keep, False for samples to trim.
221221
"""
222-
# Check for multiple treatments with trimming and bail early
223-
if self._trimming_threshold is not None:
224-
if T_pred.shape[1] > 2:
225-
warn("Sample trimming is currently only supported for binary treatment "
226-
"(single treatment plus control).", UserWarning)
227-
return np.ones(T_pred.shape[0], dtype=bool)
222+
# If no trimming threshold specified, keep all samples
223+
if self._trimming_threshold is None:
224+
return np.ones(T_pred.shape[0], dtype=bool)
228225

229-
elif self._trimming_threshold is None:
226+
# Check for multiple treatments with trimming and bail early
227+
if T_pred.shape[1] > 2:
228+
warn("Sample trimming is currently only supported for binary treatment "
229+
"(single treatment plus control).", UserWarning)
230230
return np.ones(T_pred.shape[0], dtype=bool)
231231

232232
if self._trimming_threshold == 'auto':

econml/tests/test_drlearner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,7 @@ def test_auto_trimming_uniform_propensity_full_range(self):
12961296
Y = T + np.random.randn(n) * 0.5
12971297

12981298
# Use a flexible model that can learn the propensity accurately
1299-
# Gradient boosting can fit the non-linear relationship well
1299+
# The propensity is linear in the feature, so just use LinearRegression as the propensity model even though it's a regressor rather than a classifier.
13001300
est = DRLearner(
13011301
model_propensity=LinearRegression(),
13021302
model_regression=LinearRegression(),
@@ -1331,7 +1331,7 @@ def test_auto_trimming_uniform_propensity_narrow_range(self):
13311331
# Generate outcome
13321332
Y = T + np.random.randn(n) * 0.5
13331333

1334-
# Use a flexible model that can learn the propensity accurately
1334+
# The propensity is linear in the feature, so just use LinearRegression as the propensity model even though it's a regressor rather than a classifier.
13351335
est = DRLearner(
13361336
model_propensity=LinearRegression(),
13371337
model_regression=LinearRegression(),

0 commit comments

Comments
 (0)