<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          最近常問候選人的一個案例

          共 6393字,需瀏覽 13分鐘

           ·

          2021-07-19 01:49

          你們好,我是寶器!

          今天分享一個關(guān)于ABtest的案例,這個案例會經(jīng)常出現(xiàn)在我的面試題中來考察一部分候選人。

          業(yè)務(wù)背景

          玩免費游戲,付費的人占比極少(但是卻撐起了游戲的一片天,養(yǎng)肥了很多手機廠商);微信公眾號打賞用戶,付費的人占比極少

          類似此種免費的產(chǎn)品,付費的人都占比極少,活躍用戶的付費,類似如下分布,大量集中在0

          付費是商業(yè)中非常重要的目標,是我們關(guān)心的AB實驗的目標指標。所以如何衡量收入的變化,對我們而言十分的重要。

          目標衡量指標

          一般我們不會使用收入的絕對值來作為目標變量(絕對值不能讓我們了解APP的表現(xiàn),比如總收入可能漲了,但是是大R帶來了,而其他用戶付費不付費或者降低了),而是使用訪問用戶數(shù)的人均付費金額來作為目標變量,也拆解成付費轉(zhuǎn)化率和付費客單價兩個部分進行校驗


          常用的顯著性校驗方法的缺陷

          通常我們是使用Z/T分布來對比AB實驗的結(jié)果,根據(jù)95%的顯著性校驗,來看結(jié)果是否顯著。然而這種極其偏態(tài)的數(shù)據(jù),根據(jù)我的實際經(jīng)驗,是不能夠使用抽樣分布服從正太假設(shè)來做收入校驗的。結(jié)果波動非常大

          偏態(tài)解決方法1:非參數(shù)檢驗法

          • A/B對比:Mann–Whitney U test(曼-惠特尼U檢驗);

          • A/B/N對比:Kruskal-Wallis


          由于非參數(shù)檢驗法對數(shù)據(jù)的分布沒有假設(shè),所以普適性很高,當然得到總有付出,就是它的功效是較差的,可能檢測不出來可能的有效性。

          這種方法根據(jù)樣本數(shù)據(jù)進行排序,實行秩和檢驗,利用中位數(shù)而不是平均值進行樣本之間的對比

          可以使用SPSS、Python來驗證顯著性。

          在實際工作中,我也會同時把用戶進行分層校驗和查看實際結(jié)果(比如分成大中小R這樣來看每一層的影響,人與人之間的差距挺大)

          偏態(tài)解決方法2:貝葉斯A/B測試

          這種方法十分的巧妙,相信以后會使用的越來越廣泛,在python中也有pymc包可以使用。

          傳統(tǒng)統(tǒng)計學中,一般使用95%顯著性校驗,如果結(jié)果是顯著提升的,有的業(yè)務(wù)方可能會問我們
          是不是我們有95%的把握實驗組比對照組好啦?
          可惜,我們回答不了這個問題,因為p-value的含義是以下這樣的:


          而業(yè)務(wù)方的疑問用概率來表達是這樣的:


          這兩者很微妙,卻又有所不同。

          如何回答業(yè)務(wù)方的提問?答案原來可以從貝葉斯中尋找

          貝葉斯A/B測試

          原理

          需要衡量的指標

          每個活躍用戶付費 = 付費轉(zhuǎn)化率 * 付費用戶客單價

          貝葉斯原理



          根據(jù)貝葉斯公式,先選定參數(shù)的先驗分布:

          • 轉(zhuǎn)化率一般可以使用Beta分布作為轉(zhuǎn)化率的先驗分布,然后使用實驗數(shù)據(jù)更新Beta分布作為后驗分布,再使用抽樣的方法計算我們感興趣的提升概率。(最終還可以去看看我們的假設(shè)分布是否合理,如果不合理,還要改變先驗)


          • 客單價使用Gamma分布作為客單價的先驗分布,使用實驗數(shù)據(jù)更新Gamma分布作為后驗分布,再使用抽樣的方法計算我們感興趣的提升概率


          案例

          數(shù)據(jù)集,使用虛擬的數(shù)據(jù),有3列,用戶user_id、所屬實驗組test_group、實際付費pay_amt。

          計算出付費轉(zhuǎn)化率,選擇先驗分布的參數(shù)值,查看概率密度函數(shù)圖


          from scipy.stats import betafig, ax = plt.subplots(1, 1)#這里α、β取值都較小,其中conversion_rate是事前的估計值prior_alpha = round(conversion_rate, 2) + 0.1prior_beta = 0.1 + 1 - round(conversion_rate, 2)#假設(shè)轉(zhuǎn)化率的先驗分布prior = beta(prior_alpha, prior_beta)#看看分布 圖x = np.linspace(0,1,1000)ax.plot(x, prior.pdf(x), label=f'prior Beta({int(round(conversion_rate, 1)*) + 1}, {20 + 1 - int(round(conversion_rate, 1)*20)})')ax.set_xlabel('Conversion Probability')ax.set_ylabel('Density')ax.set_title('Chosen Prior')ax.legend()


          計算實驗組和控制組的轉(zhuǎn)化數(shù)量和人均付費金額:
          results = test_data.groupby('test_group').agg({'imei': pd.Series.nunique, 'pay_amt': [np.count_nonzero ,np.sum]})results.columns = ['sampleSize','converted','pay_amt']results['conversionRate'] = results['converted']/results['sampleSize']results['revenuePerSale'] = results['pay_amt']/results['converted']

          #使用實驗數(shù)據(jù)更新轉(zhuǎn)化率分布control = beta(prior_alpha + results.loc['對照組', 'converted'], prior_beta + results.loc['對照組', 'sampleSize'] - results.loc['對照組', 'converted'])treatment = beta(prior_alpha + results.loc['實驗組', 'converted'], prior_beta + results.loc['實驗組', 'sampleSize'] - results.loc['實驗組', 'converted'])plt.rcParams['font.sans-serif'] = ['SimHei']  # 用來正常顯示中文標簽plt.rcParams['axes.unicode_minus'] = False  # 用來正常顯示負號fig, ax = plt.subplots()x = np.linspace(0,0.05,3000)ax.plot(x, control.pdf(x), label='對照組')ax.plot(x, treatment.pdf(x), label='實驗組')ax.set_xlabel('Conversion Probability')ax.set_ylabel('Density')ax.set_title('Experiment Posteriors')ax.legend()

          從圖中可以看出,實驗組的轉(zhuǎn)化率沒有比控制組更好

          使用抽樣的方法,得到感興趣的指標:
          import decimaldecimal.getcontext().prec = 4control_simulation = np.random.beta(prior_alpha + results.loc['對照組', 'converted'], prior_beta + results.loc['對照組', 'sampleSize'] - results.loc['對照組', 'converted'], size=30000)treatment_simulation = np.random.beta(prior_alpha + results.loc['實驗組', 'converted'], prior_beta + results.loc['實驗組', 'sampleSize'] - results.loc['實驗組', 'converted'], size=30000)treatment_won = [i <= j for i,j in zip(control_simulation, treatment_simulation)]chance_of_beating_control = np.mean(treatment_won)print(f'Chance of treatment beating control is {decimal.getcontext().create_decimal(chance_of_beating_control)}')

          對于人均付費金額,采用同樣的方法:
          from scipy.stats import gammacontrol_rr = gamma(a=(1 + results.loc['對照組', 'converted']), scale=(10/(1 + 0.1 * results.loc['對照組', 'converted']*results.loc['對照組', 'revenuePerSale'])))treatment_rr = gamma(a=(1 + results.loc['實驗組', 'converted']), scale=(10/(1 + 0.1 * results.loc['實驗組', 'converted']*results.loc['實驗組', 'revenuePerSale'])))fig, ax = plt.subplots()x = np.linspace(0,4,5000)ax.plot(x, control_rr.pdf(x), label='對照組')ax.plot(x, treatment_rr.pdf(x), label='實驗組')ax.set_xlabel('Rate Parameter')ax.set_ylabel('Density')ax.set_title('Experiment Posteriors')ax.legend()


          使用抽樣方法得到概率,然后計算我們感興趣的活躍用戶人均付費金額指標
          control_conversion_simulation = np.random.beta(7 + results.loc['對照組', 'converted'], 15 + results.loc['對照組', 'sampleSize'] - results.loc['對照組', 'converted'], size=100000)treatment_conversion_simulation = np.random.beta(7 + results.loc['實驗組', 'converted'], 15 + results.loc['實驗組', 'sampleSize'] - results.loc['實驗組', 'converted'], size=100000)
          control_revenue_simulation = np.random.gamma(shape=(1 + results.loc['對照組', 'converted']), scale=(10/(1 + (0.1)*results.loc['對照組', 'converted']*results.loc['對照組', 'revenuePerSale'])), size=100000)treatment_revenue_simulation = np.random.gamma(shape=(1 + results.loc['實驗組', 'converted']), scale=(10/(1 + (0.1)*results.loc['實驗組', 'converted']*results.loc['實驗組', 'revenuePerSale'])), size=100000)
          control_avg_purchase = [i/j for i,j in zip(control_conversion_simulation, control_revenue_simulation)]treatment_avg_purchase = [i/j for i,j in zip(treatment_conversion_simulation, treatment_revenue_simulation)]
          fig, axx = np.linspace(0,4,1000)ax.hist(control_avg_purchase, density=True, label='對照組', histtype='stepfilled', bins=100)ax.hist(treatment_avg_purchase, density=True, label='實驗組', histtype='stepfilled', bins=100)ax.set_xlabel('Avg Revenue per User')ax.set_ylabel('Density')ax.set_title('Experiment Posteriors')ax.legend()


          嗯,從圖上看來,活躍用戶價值有所提升,但是重合的部分太高了,所以從概率上來看,估計實驗組高于對照組不會太高。
          來看看抽樣數(shù)據(jù)模擬出來是多少:


          從結(jié)果上來看,高于控制組的概率僅有13%

          其他方法:使用python的pymc包來計算以上過程,會更快速有效~

          參考資料:
          1、https://towardsdatascience.com/bayesian-ab-testing-part-ii-revenue-1fbcf04f96cd
          2、https://www.youtube.com/watch?v=VVbJ4jEoOfU
          3、https://twiecki.io/bayesian_pymc3_europy_ab.slides.html
          4、https://medium.com/ni-tech-talk/optimizing-revenue-with-bayesian-a-b-testing-5068e8ac41ea
          5、https://towardsdatascience.com/gamma-distribution-intuition-derivation-and-examples-55f407423840 gamma分布的解釋
          ·················END·················

          推薦閱讀

          1. 我在字節(jié)做了哪些事

          2. 寫給所有數(shù)據(jù)人。

          3. 從留存率業(yè)務(wù)案例談0-1的數(shù)據(jù)指標體系

          4. 數(shù)據(jù)分析師的一周

          5. 超級菜鳥如何入門數(shù)據(jù)分析?


          歡迎長按掃碼關(guān)注「數(shù)據(jù)管道」
          瀏覽 33
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          分享
          舉報
          評論
          圖片
          表情
          推薦
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  久久夜色精品噜噜亚洲AV | 豆花视频综合网 | 日韩成人无码人妻 | 麻豆一区二区99久久久久 | 欧美色图成人影片 |