A/B テストとは?

Pythonで学ぶA/Bテスト

Moe Lotfy, PhD

Principal Data Science Manager

A/B テスト入門

  • A/B テストとは…

     
    • どのバージョンが優れているかを検証する実験
    • 指標に基づく: サインアップ率、ユーザー当たり平均売上など
    • ランダム割り当てで実施し、結果を分析
Pythonで学ぶA/Bテスト

A/B テストはすべきか?

A/B テストの良い活用例:

  • コンバージョン率の最適化
  • 新機能のリリース
  • 広告の増分効果の評価
  • 臨床試験の効果検証

A/B テストを避けるべき場合:

  • トラフィック不足・サンプルが小さい
  • 論理的な仮説がない
  • 倫理面の懸念
  • 機会費用が高い
Pythonで学ぶA/Bテスト

A/B テストの基本手順

  1. 目的とデザイン/体験を定義
  2. 受験者をランダムサンプリング
  3. 受験者をランダムに割り当てる:
    • コントロール: 現状
    • テスト群: 新デザイン
  4. 行動を記録し、指標を算出
  5. 統計的有意差を検定

A/B テストの手順

Pythonで学ぶA/Bテスト

ランダム化の価値

  • 一般化可能性と代表性
  • グループ間のバイアス最小化
  • 処置効果を分離し因果関係を確立

 

ランダムサンプリングとランダム割り当ての図解

1 https://www.statology.org/random-selection-vs-random-assignment/
Pythonで学ぶA/Bテスト

ランダム割り当ての Python 例

checkout.info()
RangeIndex: 9000 entries, 0 to 8999
Data columns (total 6 columns):
 #   Column         Non-Null Count  Dtype  
 0   user_id        9000 non-null   int64  
 1   checkout_page  9000 non-null   object 
 2   order_value    7605 non-null   float64
 3   purchased      9000 non-null   float64
 4   gender         9000 non-null   object 
 5   browser        9000 non-null   object 
dtypes: float64(2), int64(1), object(3)
memory usage: 422.0+ KB
Pythonで学ぶA/Bテスト

ランダム割り当ての Python 例

checkout['gender'].value_counts(normalize=True)
F    0.507556
M    0.492444
Name: gender, dtype: float64
sample_df = checkout.sample(n=3000)
sample_df['gender'].value_counts(normalize=True)
M    0.506333
F    0.493667
Name: gender, dtype: float64
Pythonで学ぶA/Bテスト

ランダム割り当ての Python 例

checkout.groupby('checkout_page')['gender'].value_counts(normalize=True)
checkout_page  gender
A              M         0.505000
               F         0.495000
B              F         0.507333
               M         0.492667
C              F         0.520333
               M         0.479667
Name: gender, dtype: float64
Pythonで学ぶA/Bテスト

¡Vamos a practicar!

Pythonで学ぶA/Bテスト

Preparing Video For Download...