การออกแบบการทดลอง: การวิเคราะห์พลังงานสถิติ

A/B Testing ด้วย Python

Moe Lotfy, PhD

Principal Data Science Manager

ขนาดเอฟเฟกต์

  • Cohen's d สำหรับความแตกต่างของค่าเฉลี่ย สูตรขนาดเอฟเฟกต์ Cohen's d
  • Cohen's h สำหรับความแตกต่างของสัดส่วน

สูตรขนาดเอฟเฟกต์ Cohen's h

  • หลักเกณฑ์เบื้องต้น
    • เอฟเฟกต์เล็กน้อย = 0.2
    • เอฟเฟกต์ปานกลาง = 0.5
    • เอฟเฟกต์ขนาดใหญ่ = 0.8
# Calculate standardized effect size
from statsmodels.stats.proportion import proportion_effectsize
effect_size_std = proportion_effectsize(.33, .3)
print(effect_size_std)
0.0645
# Calculate standardized effect size
from statsmodels.stats.proportion import proportion_effectsize
effect_size_std = proportion_effectsize(p_B, p_A)
print(effect_size_std)
0.0716
A/B Testing ด้วย Python

การประมาณขนาดกลุ่มตัวอย่างสำหรับสัดส่วน

# Import power module
from statsmodels.stats import power
# Calculate sample size
sample_size = power.TTestIndPower().solve_power(effect_size=effect_size_std,
                                                power=.80,
                                                alpha=.05,
                                                nobs1=None)
print(sample_size)
3057.547
A/B Testing ด้วย Python

ผลของขนาดกลุ่มตัวอย่างและ MDE ต่อพลังงานสถิติ

# Import t-test power package
from statsmodels.stats.power import TTestIndPower
# Specify parameters for power analysis
sample_sizes = array(range(10, 120))
effect_sizes = array([0.2, 0.5, 0.8])
# Plot power curves
TTestIndPower().plot_power(nobs=sample_sizes, effect_size=effect_sizes)
plt.show()

กราฟเส้นโค้งพลังงานสถิติที่แสดงความสัมพันธ์ระหว่างขนาดกลุ่มตัวอย่าง พลังงานสถิติ และขนาดเอฟเฟกต์

A/B Testing ด้วย Python

การประมาณขนาดกลุ่มตัวอย่างสำหรับค่าเฉลี่ย

# Calculate the baseline mean order value
mean_A = checkout[checkout['checkout_page']=='A']['order_value'].mean()
print(mean_A)
24.9564
std_A = checkout[checkout['checkout_page']=='A']['order_value'].std()
print(std_A)
2.418
# Specify the desired minimum average order value
mean_new = 26
# Calculate the standardized effect size
std_effect_size=(mean_new-mean_A)/std_A
A/B Testing ด้วย Python

การประมาณขนาดกลุ่มตัวอย่างสำหรับค่าเฉลี่ย

sample_size = power.TTestIndPower().solve_power(effect_size=std_effect_size,
                                                power=.80,
                                                alpha=.05,
                                                nobs1=None)
print(sample_size)
85.306
A/B Testing ด้วย Python

มาฝึกกันเถอะ!

A/B Testing ด้วย Python

Preparing Video For Download...