Skip to content

Commit f54ef49

Browse files
CopilotTomeHirata
andauthored
Replace list+ndarray concatenation with numpy operations in tutorials (#91)
* Initial plan * Replace list+ndarray with np.insert for clearer numpy operations in tutorials Co-authored-by: TomeHirata <33407409+TomeHirata@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: TomeHirata <33407409+TomeHirata@users.noreply.github.com>
1 parent 6bd34a5 commit f54ef49

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

docs/source/tutorials/hillstrom.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,15 @@ Let's also examine how each campaign affects spending in specific intervals usin
142142
pte_women_ctrl, pte_lower_women_ctrl, pte_upper_women_ctrl = simple_estimator.predict_pte(
143143
target_treatment_arm=2, # Women's email
144144
control_treatment_arm=0, # No email control
145-
locations=[-1] + revenue_locations,
145+
locations=np.insert(revenue_locations, 0, -1),
146146
variance_type="moment"
147147
)
148148
149149
# Compute PTE: Men's email vs Control
150150
pte_men_ctrl, pte_lower_men_ctrl, pte_upper_men_ctrl = simple_estimator.predict_pte(
151151
target_treatment_arm=1, # Men's email
152152
control_treatment_arm=0, # No email control
153-
locations=[-1] + revenue_locations,
153+
locations=np.insert(revenue_locations, 0, -1),
154154
variance_type="moment"
155155
)
156156
@@ -272,14 +272,14 @@ Revenue Category Analysis with PTE
272272
pte_simple, pte_lower_simple, pte_upper_simple = simple_estimator.predict_pte(
273273
target_treatment_arm=1, # Women's email
274274
control_treatment_arm=0, # Men's email
275-
locations=[-1] + revenue_locations,
275+
locations=np.insert(revenue_locations, 0, -1),
276276
variance_type="moment"
277277
)
278278
279279
pte_ml, pte_lower_ml, pte_upper_ml = ml_estimator.predict_pte(
280280
target_treatment_arm=1, # Women's email
281281
control_treatment_arm=0, # Men's email
282-
locations=[-1] + revenue_locations,
282+
locations=np.insert(revenue_locations, 0, -1),
283283
variance_type="moment"
284284
)
285285

docs/source/tutorials/oregon.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,13 @@ Cost Analysis with Local PTE
218218
lpte_simple, lpte_lower_simple, lpte_upper_simple = simple_local_estimator.predict_lpte(
219219
target_treatment_arm=1, # Z=1 Selected for treatment (Enrolled)
220220
control_treatment_arm=0, # Z=0 Not selected for treatment (Not enrolled)
221-
locations=[-1] + outcome_ed_costs_locations
221+
locations=np.insert(outcome_ed_costs_locations, 0, -1)
222222
)
223223
224224
lpte_ml, lpte_lower_ml, lpte_upper_ml = ml_local_estimator.predict_lpte(
225225
target_treatment_arm=1, # Z=1 Selected for treatment (Enrolled)
226226
control_treatment_arm=0, # Z=0 Not selected for treatment (Not enrolled)
227-
locations=[-1] + outcome_ed_costs_locations
227+
locations=np.insert(outcome_ed_costs_locations, 0, -1)
228228
)
229229
230230
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(15, 6))
@@ -351,13 +351,13 @@ Visits Analysis with Local PTE
351351
lpte_simple, lpte_lower_simple, lpte_upper_simple = simple_local_estimator.predict_lpte(
352352
target_treatment_arm=1, # Z=1 Selected for treatment (Enrolled)
353353
control_treatment_arm=0, # Z=0 Not selected for treatment (Not enrolled)
354-
locations=[-1] + outcome_ed_visits_locations
354+
locations=np.insert(outcome_ed_visits_locations, 0, -1)
355355
)
356356
357357
lpte_ml, lpte_lower_ml, lpte_upper_ml = ml_local_estimator.predict_lpte(
358358
target_treatment_arm=1, # Z=1 Selected for treatment (Enrolled)
359359
control_treatment_arm=0, # Z=0 Not selected for treatment (Not enrolled)
360-
locations=[-1] + outcome_ed_visits_locations
360+
locations=np.insert(outcome_ed_visits_locations, 0, -1)
361361
)
362362
363363
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(15, 6))

0 commit comments

Comments
 (0)