Skip to content

Commit f32577d

Browse files
committed
apply men/women to male/female
1 parent 26118ad commit f32577d

1 file changed

Lines changed: 44 additions & 44 deletions

File tree

docs/source/tutorials/hillstrom.rst

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -350,12 +350,12 @@ Defining Subgroups
350350
.. code-block:: python
351351
352352
# Define subgroup masks based on purchase history
353-
male_purchasers = (df['mens'] == 1)
354-
female_purchasers = (df['womens'] == 1)
353+
mens_purchasers = (df['mens'] == 1)
354+
womens_purchasers = (df['womens'] == 1)
355355
356-
print(f"Male purchaser segment: {male_purchasers.sum():,} customers")
357-
print(f"Female purchaser segment: {female_purchasers.sum():,} customers")
358-
print(f"Overlap: {(male_purchasers & female_purchasers).sum():,} customers")
356+
print(f"Men's merchandise purchaser segment: {mens_purchasers.sum():,} customers")
357+
print(f"Women's merchandise purchaser segment: {womens_purchasers.sum():,} customers")
358+
print(f"Overlap: {(mens_purchasers & womens_purchasers).sum():,} customers")
359359
360360
Average Treatment Effects by Subgroup
361361
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -366,40 +366,40 @@ Let's first compute the average treatment effects (ATEs) to quantify the overall
366366
367367
# Compute ATEs for each campaign-subgroup combination
368368
# Women's Email Campaign
369-
ate_women_male = (revenue[(D==2) & male_purchasers].mean() -
370-
revenue[(D==0) & male_purchasers].mean())
371-
ate_women_female = (revenue[(D==2) & female_purchasers].mean() -
372-
revenue[(D==0) & female_purchasers].mean())
369+
ate_women_male = (revenue[(D==2) & mens_purchasers].mean() -
370+
revenue[(D==0) & mens_purchasers].mean())
371+
ate_women_female = (revenue[(D==2) & womens_purchasers].mean() -
372+
revenue[(D==0) & womens_purchasers].mean())
373373
374374
# Men's Email Campaign
375-
ate_men_male = (revenue[(D==1) & male_purchasers].mean() -
376-
revenue[(D==0) & male_purchasers].mean())
377-
ate_men_female = (revenue[(D==1) & female_purchasers].mean() -
378-
revenue[(D==0) & female_purchasers].mean())
375+
ate_men_male = (revenue[(D==1) & mens_purchasers].mean() -
376+
revenue[(D==0) & mens_purchasers].mean())
377+
ate_men_female = (revenue[(D==1) & womens_purchasers].mean() -
378+
revenue[(D==0) & womens_purchasers].mean())
379379
380380
print("Average Treatment Effects by Subgroup:")
381381
print("\nWomen's Email Campaign:")
382-
print(f" Male Purchasers: ATE = ${ate_women_male:.4f}")
383-
print(f" Female Purchasers: ATE = ${ate_women_female:.4f}")
382+
print(f" Men's Merch. Purchasers: ATE = ${ate_women_male:.4f}")
383+
print(f" Women's Merch. Purchasers: ATE = ${ate_women_female:.4f}")
384384
print("\nMen's Email Campaign:")
385-
print(f" Male Purchasers: ATE = ${ate_men_male:.4f}")
386-
print(f" Female Purchasers: ATE = ${ate_men_female:.4f}")
385+
print(f" Men's Merch. Purchasers: ATE = ${ate_men_male:.4f}")
386+
print(f" Women's Merch. Purchasers: ATE = ${ate_men_female:.4f}")
387387
388388
Expected output::
389389

390390
Average Treatment Effects by Subgroup:
391391

392392
Women's Email Campaign:
393-
Male Purchasers: ATE = $0.2564
394-
Female Purchasers: ATE = $0.5442
393+
Men's Merch. Purchasers: ATE = $0.2564
394+
Women's Merch. Purchasers: ATE = $0.5442
395395

396396
Men's Email Campaign:
397-
Male Purchasers: ATE = $0.8966
398-
Female Purchasers: ATE = $0.8412
397+
Men's Merch. Purchasers: ATE = $0.8966
398+
Women's Merch. Purchasers: ATE = $0.8412
399399

400400
These results reveal important patterns:
401401

402-
- **Women's Email Campaign**: Shows 2× stronger effect for female purchasers ($0.54) vs male purchasers ($0.26)
402+
- **Women's Email Campaign**: Shows 2× stronger effect for women's merchandise purchasers ($0.54) vs men's merchandise purchasers ($0.26)
403403
- **Men's Email Campaign**: Demonstrates consistent strong effects across both segments ($0.84-$0.89)
404404

405405
While these averages provide a useful summary, they don't tell us *how* customer spending distributions change. The distributional and probability treatment effect analyses that follow reveal the complete picture of campaign effectiveness.
@@ -411,13 +411,13 @@ Beyond the average effects, let's examine how the Women's Email campaign shifts
411411

412412
.. code-block:: python
413413
414-
# Analyze male purchaser segment
414+
# Analyze men's merchandise purchaser segment
415415
estimator_male = dte_adj.SimpleDistributionEstimator()
416-
estimator_male.fit(X[male_purchasers], D[male_purchasers], revenue[male_purchasers])
416+
estimator_male.fit(X[mens_purchasers], D[mens_purchasers], revenue[mens_purchasers])
417417
418-
# Analyze female purchaser segment
418+
# Analyze women's merchandise purchaser segment
419419
estimator_female = dte_adj.SimpleDistributionEstimator()
420-
estimator_female.fit(X[female_purchasers], D[female_purchasers], revenue[female_purchasers])
420+
estimator_female.fit(X[womens_purchasers], D[womens_purchasers], revenue[womens_purchasers])
421421
422422
# Define evaluation points
423423
locations = np.linspace(0, 500, 51)
@@ -441,13 +441,13 @@ Beyond the average effects, let's examine how the Women's Email campaign shifts
441441
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(15, 6))
442442
443443
plot(locations, dte_women_male, lower_women_male, upper_women_male,
444-
title="Women's Email vs Control\nMale Purchaser Segment",
444+
title="Women's Email vs Control\nMen's Merch. Purchasers",
445445
xlabel="Spending ($)", ylabel="Distribution Treatment Effect",
446446
color="purple", ax=ax1)
447447
ax1.axhline(y=0, color='black', linestyle='--', linewidth=0.8, alpha=0.5)
448448
449449
plot(locations, dte_women_female, lower_women_female, upper_women_female,
450-
title="Women's Email vs Control\nFemale Purchaser Segment",
450+
title="Women's Email vs Control\nWomen's Merch. Purchasers",
451451
xlabel="Spending ($)", ylabel="Distribution Treatment Effect",
452452
color="green", ax=ax2)
453453
ax2.axhline(y=0, color='black', linestyle='--', linewidth=0.8, alpha=0.5)
@@ -460,7 +460,7 @@ Beyond the average effects, let's examine how the Women's Email campaign shifts
460460
:width: 800px
461461
:align: center
462462

463-
**Key Finding for Women's Email Campaign**: The distributional treatment effects reveal that women's email campaigns are significantly more effective for the female purchaser segment (right panel) compared to the male purchaser segment (left panel). The DTE curves show that women's emails reduce the probability of low spending levels (negative DTE at lower thresholds) for female purchasers, indicating a shift toward higher spending. In contrast, the male purchaser segment shows minimal or non-significant effects across most of the spending distribution, with confidence intervals overlapping zero.
463+
**Key Finding for Women's Email Campaign**: The distributional treatment effects reveal that women's email campaigns are significantly more effective for the women's merchandise purchaser segment (right panel) compared to the men's merchandise purchaser segment (left panel). The DTE curves show that women's emails reduce the probability of low spending levels (negative DTE at lower thresholds) for women's merchandise purchasers, indicating a shift toward higher spending. In contrast, the men's merchandise purchaser segment shows minimal or non-significant effects across most of the spending distribution, with confidence intervals overlapping zero.
464464

465465
Distribution Treatment Effects: Men's Email Campaign
466466
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -488,13 +488,13 @@ Now let's examine how the Men's Email campaign affects spending distributions:
488488
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(15, 6))
489489
490490
plot(locations, dte_men_male, lower_men_male, upper_men_male,
491-
title="Men's Email vs Control\nMale Purchaser Segment",
491+
title="Men's Email vs Control\nMen's Merch. Purchasers",
492492
xlabel="Spending ($)", ylabel="Distribution Treatment Effect",
493493
color="purple", ax=ax1)
494494
ax1.axhline(y=0, color='black', linestyle='--', linewidth=0.8, alpha=0.5)
495495
496496
plot(locations, dte_men_female, lower_men_female, upper_men_female,
497-
title="Men's Email vs Control\nFemale Purchaser Segment",
497+
title="Men's Email vs Control\nWomen's Merch. Purchasers",
498498
xlabel="Spending ($)", ylabel="Distribution Treatment Effect",
499499
color="green", ax=ax2)
500500
ax2.axhline(y=0, color='black', linestyle='--', linewidth=0.8, alpha=0.5)
@@ -507,7 +507,7 @@ Now let's examine how the Men's Email campaign affects spending distributions:
507507
:width: 800px
508508
:align: center
509509

510-
**Key Finding for Men's Email Campaign**: In contrast to women's email campaigns, men's email campaigns show consistent effectiveness across both purchase history segments. The DTE curves in both panels show similar patterns, with negative values at lower spending levels indicating reduced probability of low spending for both male and female purchasers. This suggests that men's emails have broad appeal regardless of whether customers historically purchased men's or women's merchandise.
510+
**Key Finding for Men's Email Campaign**: In contrast to women's email campaigns, men's email campaigns show consistent effectiveness across both purchase history segments. The DTE curves in both panels show similar patterns, with negative values at lower spending levels indicating reduced probability of low spending for both male and women's merchandise purchasers. This suggests that men's emails have broad appeal regardless of whether customers historically purchased men's or women's merchandise.
511511

512512
Probability Treatment Effects: Women's Email Campaign
513513
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -538,14 +538,14 @@ While DTE shows how cumulative distributions shift, Probability Treatment Effect
538538
539539
plot(locations, pte_women_male, pte_lower_women_male, pte_upper_women_male,
540540
chart_type="bar",
541-
title="Women's Email vs Control\nMale Purchaser Segment",
541+
title="Women's Email vs Control\nMen's Merch. Purchasers",
542542
xlabel="Spending Category ($)", ylabel="Probability Treatment Effect",
543543
color="purple", ax=ax1)
544544
ax1.axhline(y=0, color='black', linestyle='--', linewidth=0.8, alpha=0.5)
545545
546546
plot(locations, pte_women_female, pte_lower_women_female, pte_upper_women_female,
547547
chart_type="bar",
548-
title="Women's Email vs Control\nFemale Purchaser Segment",
548+
title="Women's Email vs Control\nWomen's Merch. Purchasers",
549549
xlabel="Spending Category ($)", ylabel="Probability Treatment Effect",
550550
color="green", ax=ax2)
551551
ax2.axhline(y=0, color='black', linestyle='--', linewidth=0.8, alpha=0.5)
@@ -558,7 +558,7 @@ While DTE shows how cumulative distributions shift, Probability Treatment Effect
558558
:width: 800px
559559
:align: center
560560

561-
**Interval-Specific Insights**: The PTE bar charts reveal the mechanism behind the average treatment effect. For female purchasers (right panel), women's emails significantly reduce the probability of zero spending (non-purchasers converting to purchasers), which is the primary driver of the positive ATE. However, no significant increase in high spending categories is observed. For male purchasers (left panel), the effects are much smaller and less consistent, confirming the limited impact suggested by the ATE and DTE analyses.
561+
**Interval-Specific Insights**: The PTE bar charts reveal the mechanism behind the average treatment effect. For women's merchandise purchasers (right panel), women's emails significantly reduce the probability of zero spending (non-purchasers converting to purchasers), which is the primary driver of the positive ATE. However, no significant increase in high spending categories is observed. For men's merchandise purchasers (left panel), the effects are much smaller and less consistent, confirming the limited impact suggested by the ATE and DTE analyses.
562562

563563
Probability Treatment Effects: Men's Email Campaign
564564
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -587,14 +587,14 @@ Let's examine which spending categories are most affected by men's email campaig
587587
588588
plot(locations, pte_men_male, pte_lower_men_male, pte_upper_men_male,
589589
chart_type="bar",
590-
title="Men's Email vs Control\nMale Purchaser Segment",
590+
title="Men's Email vs Control\nMen's Merch. Purchasers",
591591
xlabel="Spending Category ($)", ylabel="Probability Treatment Effect",
592592
color="purple", ax=ax1)
593593
ax1.axhline(y=0, color='black', linestyle='--', linewidth=0.8, alpha=0.5)
594594
595595
plot(locations, pte_men_female, pte_lower_men_female, pte_upper_men_female,
596596
chart_type="bar",
597-
title="Men's Email vs Control\nFemale Purchaser Segment",
597+
title="Men's Email vs Control\nWomen's Merch. Purchasers",
598598
xlabel="Spending Category ($)", ylabel="Probability Treatment Effect",
599599
color="green", ax=ax2)
600600
ax2.axhline(y=0, color='black', linestyle='--', linewidth=0.8, alpha=0.5)
@@ -607,7 +607,7 @@ Let's examine which spending categories are most affected by men's email campaig
607607
:width: 800px
608608
:align: center
609609

610-
**Interval-Specific Insights**: Men's email campaigns show similar PTE patterns across both segments (left and right panels). The key mechanism is twofold: (1) significant reduction in zero spending probability (converting non-purchasers to purchasers), and (2) increased probability in the $40-100 spending range. This dual effect—both purchase conversion and mid-range spending increases—occurs consistently across both male and female purchaser segments, confirming the broad effectiveness of men's campaigns.
610+
**Interval-Specific Insights**: Men's email campaigns show similar PTE patterns across both segments (left and right panels). The key mechanism is twofold: (1) significant reduction in zero spending probability (converting non-purchasers to purchasers), and (2) increased probability in the $40-100 spending range. This dual effect—both purchase conversion and mid-range spending increases—occurs consistently across both male and women's merchandise purchaser segments, confirming the broad effectiveness of men's campaigns.
611611

612612
Key Insights from Subgroup Analysis
613613
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -616,29 +616,29 @@ Combining Average Treatment Effects (ATE), Distribution Treatment Effects (DTE),
616616

617617
**1. Campaign Targeting Effectiveness (from ATE)**
618618

619-
- Women's email campaigns show 2× stronger average effects for female purchasers ($0.54) vs male purchasers ($0.26)
619+
- Women's email campaigns show 2× stronger average effects for women's merchandise purchasers ($0.54) vs men's merchandise purchasers ($0.26)
620620
- Men's email campaigns demonstrate consistent strong effects across both segments ($0.89-$0.84)
621621
- This suggests women's campaigns benefit from precise targeting, while men's campaigns have broader appeal
622622

623623
**2. Distributional Shifts Beyond Averages (from DTE)**
624624

625-
- For women's emails, the female purchaser segment shows negative DTE at lower spending thresholds, indicating a systematic shift away from low-spending behavior
626-
- Male purchasers show minimal distributional changes from women's emails, with confidence intervals overlapping zero at most thresholds
625+
- For women's emails, the women's merchandise purchaser segment shows negative DTE at lower spending thresholds, indicating a systematic shift away from low-spending behavior
626+
- Men's merchandise purchasers show minimal distributional changes from women's emails, with confidence intervals overlapping zero at most thresholds
627627
- Men's emails produce similar distributional patterns across both segments, confirming broad effectiveness
628628

629629
**3. Spending Category Changes (from PTE)**
630630

631631
- PTE analysis reveals *which specific spending intervals* change in response to campaigns, particularly identifying the mechanisms behind average effects
632-
- **Women's emails**: For female purchasers, the primary effect is converting non-purchasers to purchasers (significant reduction in zero spending probability). No significant increase in high spending categories was observed.
632+
- **Women's emails**: For women's merchandise purchasers, the primary effect is converting non-purchasers to purchasers (significant reduction in zero spending probability). No significant increase in high spending categories was observed.
633633
- **Men's emails**: Show a dual mechanism across both segments: (1) converting non-purchasers to purchasers (zero spending reduction), and (2) increasing purchases in the $40-100 range
634634
- PTE enables identification of behavioral change mechanisms that are invisible in average treatment effects alone—specifically revealing that lift comes primarily from purchase conversion (0→1 effect) rather than spending increases among existing purchasers
635635

636636
**4. Strategic Implications**
637637

638638
Based on these findings, several practical implications emerge:
639639

640-
- **For Women's Campaigns**: Target customers with history of purchasing women's merchandise to maximize ROI. The PTE analysis reveals that effectiveness comes primarily from converting non-purchasers to purchasers among female purchaser segments, rather than increasing spending among existing buyers.
641-
- **For Men's Campaigns**: Deploy broadly as they produce consistent positive effects across diverse customer segments. Both male and female purchasers show both purchase conversion and mid-range spending increases, suggesting broader appeal.
640+
- **For Women's Campaigns**: Target customers with history of purchasing women's merchandise to maximize ROI. The PTE analysis reveals that effectiveness comes primarily from converting non-purchasers to purchasers among women's merchandise purchaser segments, rather than increasing spending among existing buyers.
641+
- **For Men's Campaigns**: Deploy broadly as they produce consistent positive effects across diverse customer segments. Both male and women's merchandise purchasers show both purchase conversion and mid-range spending increases, suggesting broader appeal.
642642
- **Resource Allocation**: One practical implication is to prioritize precise targeting for gender-specific content (women's emails) but invest confidently in broad deployment for broadly appealing content (men's emails).
643643

644644
**5. Methodological Value**

0 commit comments

Comments
 (0)