附件包含两个文件:第一个文件是我自己整理的Google 的 ab test课程的笔记,第二个是根据设计一个ab test,面试可能会涉及的知识点以及坑
文字版如下,因为新手不能发图片,note里有大量截图无法上传,推荐直接下载附件。欢迎进群和准备数据分析面试的小伙伴一起讨论,进群方式在这里. 1point 3 acres
AB Testing
Introduction
What you cannot do with ab testing
e.g. add premium service- users need to opt-in to the service, cannot do randomly assigning (the willing in control and test group need to be the same)
referral- will take too long. .и
update logo – surprisingly emotional, user need some time to get used to it
Business Example
Goal – if change the start button’s color
Metric – click-through-probability (measure impact) instead of CTR (measure usage)
Distribution – Binomial
Hypothesis testing – H0:P control = P experiment , cut-off=0.05. 1point 3 acres
..
pick significant boundary-. check 1point3acres for more.
practically significant(business) vs statistically significant (repeatedly)
medicine 10~15% change, for online world, 2% is important
statistical power- Size vs power trade off -baidu 1point3acres
Two types of checks
• Invariant checking: Metrics that shouldn’t change between your test and control. 1point3acres.com
• Evaluation: High level business metrics, user experience with the product
How do we go about making a definition of a metric (for sanity checking)?
1. High level concept of metrics (e.g active users, CTR)
2. Details (e.g. how do you define user activity)-baidu 1point3acres
3. Take a set of metrics and summarize them into a single metric (e.g. overall evaluation criterion (OEC))
High-level concept for metrics
some metrics may be difficult to measure. In such case, we can compare with external data or use internal data. With internal data, we can do. 1point 3acres
• Retrospective analysis: Look at historic data to look at changes and see the evaluation.google и
• Surveys and User experience research: This helps you develop ideas on what you want to research
You can gather additional data by
1. User Experience Research (UER) - high depth on a few users. This is good for brainstorming. You can also use special equipment in a UER (e.g. eye movement camera) that you cannot use on your website. You may want to validate the results using retrospective analysis. Waral dи,
2. Focus groups: Medium depth and # of participants. Get feedback on hypotheticals, but may run into the issue of groupthink
3. Surveys have low depth but high # of participants: Useful for metrics you cannot directly measure. Can’t directly compare with other metrics since population for survey and internal metrics may be different.
Define the metric
.--
Filter the traffic and Segment
The goal is to filter out those bots and crawler traffic. To avoid bias, we need to find the baseline. we can do slicing by country, or other categories, and look at the pattern week by week or day by day.
Summary Metrics
4 categories of metrics
• Sums and counts (e.g. # of users who visited a page)
• Distributional metrics - means, medians, percentiles (do a retrospective analysis, if normal distribution, then mean or median, if skewed distribution, percentiles).
• Probabilities and rates.1point3acres
• Ratios (e.g. revenue/click)
Sensitivity and Robustness
e.g. mean is sensitive to outliers, median is robust but not sensitive to changes to small group of users.
This can be measured by using prior experiments
(assume the videos are comparable)
Another alternative is to do A/A tests to see if the metric picks up any spurious differences
(assume 5 has the highest resolution)
Absolute vs Relative
The simplest way to compare metrics for test and control is to take a difference.
If you are running a lot of experiments you want to use the relative difference i.e the percentage change. The main advantage of computing the percentage change is that you only have to choose one practical significance boundary to get stability over time. If you are running a lot of experiments over time, your metrics are probably changing over time. Using relative difference helps here by having to use one practical significance boundary rather than change it as the system changes. The main disadvantage is variability, relative differences such as ratios are not as well behaved as absolute differences
Calculating variability
To calculate the confidence interval, you need
• Variance (or standard deviation)
• Distribution
At Google, it was observed that the analytical estimates of variance was often under-estimated, and therefore they have resorted to use empirical measurements based on A/A test to evaluate variance. If you see a lot of variability in a metric in an A/A test, it is probably too sensitive to be used. Rather than do several multiple A/A tests, one way is to do a large A/A test, and then do bootstrap to generate small groups and test the variability.
With A/A tests, we can
• Compare result to what you expect (sanity check).--
• Estimate variance empirically and use your assumption about the distribution to calculate confidence
• Directly estimate confidence interval without making any assumption of the data
Designing an Experiment
Choose subject (unit of diversion). .и
User id.google и
Anonymous id(cookie)
Event
Device id.--
IP address
1)User consistence –users visibility or Measure learning effect (if load is slower, will users use less, need to see across time)
2)Ethical consideration.--
3)variability – empirical variability may be much higher than analytical variability.
Because when unit of analysis (the denominator of metrics) is different from unit of diversion. E.g. unit of analysis is pageview and unit of diversion is cookie.
When you’re doing event-based diversion, every single event is different random draw. When you’re using cookie- based diversion, they are correlated,which increase the variability.
Choose population: What population are you going to use (US only?). 1point3acres.com
.
Size - unit of diversion 不同,size 不同
. From 1point 3acres bbs
Targeting the experiment to the appropriate traffic can reduce the size of experiment
But we need a pilot first to determine which cohort will be impacted mostly
. Χ
Duration
How long to run the experiment, when run
Analyzing result
Sanity check : invariant .1point3acres
Single Metric:CTR
Because CTR distribution is more like poisson other than binomial, we use empirical SE
Confidence interval is 0.022~0.038 .1point3acres
. 1point3acres.com
Simpson’s paradox
..
从结果看,control的CTR比exp高,但是分别看new user 和experienced user,都是exp组更高,这是因为new user的CTR比较高,而更多的new user在control组
Multiple Metrics. 1point 3 acres
The more things you test, the more likely you are to see significant difference just by chance. This is a problem, but since it is not repeatable for the same metric across multiple attempts, there is a way out. One can do multiple runs of the experiment, or alternately bootstrap. There is another technique called multiple comparison that adjusts your significance levels that accounts for how many metrics or tests you are doing.. 1point3acres.com
. Waral dи,
Final project
Choosing invariant metric—not impact by the test ..
Choosing evaluation metrics – from high level (company’s goal define metrics)
Calculating standard deviation – you need to know the dis.1point3acres
Calculating number of page –
影响样本量的4点. 1point3acres.com
我们把第一类错误出现的概率用α表示。这个α,就是Significance Level。.
第二类错误(Type II error),用β表示。根据条件概率的定义,可以计算出β = 1 – power
第一类错误α(false positive)不超过5%。也就是说,Significance Level = 5%。
第二类错误β(false negative)不超过20%。也就是说,Statistical Power = 1 -β = 80%。
Baseline Rate-当baseline很大(接近1)或者很小(接近0)的时候,实验更容易检测出差别(power变大),如果保持power不变,那么所需要的样本数量变小。
Minimum Detectable Effect-参数越大(比如10%),说明我们期望实验能够检测出10%的差别即可。检测这么大的差别当然比较容易(power变大),所以保持power不变的情况下,所需要的样本量会变小。
Choosing duration and exposure –
如果一周有起伏,起码要持续一周,population or cohort?
.1point3acres
Sanity check –
Invariant metrics
what to test in ads industry?
• targeting – customer segment
• frequency - impression#
• flighting – when to scheduling the ads
• channel . 1point 3acres
• content
design an experiment
1. have clear objective
2. define the metric (invariant checking vs evaluation)
2.1. High level concept of metrics (e.g active users, 结合公司目标)
2.2. Details (e.g. how do you define user activity-DAU…)
2.3. Measurement
2.3.1. Sums and counts (e.g. # of users who visited a page)
2.3.2. Distributional metrics - means, medians, percentiles (do a retrospective analysis, if normal distribution, then mean or median, if skewed distribution, percentiles)
2.3.3. Probabilities and rates
2.3.4. Ratios (e.g. revenue/click)
2.4 one metric or a suite of metrics (The more things you test, the more likely you are to see significant difference just by chance. There is another technique called multiple comparison that adjusts your significance levels that accounts for how many metrics or tests you are doing)
a. Long-term use short-term proxy
b. Invariant is for sanity check
c. Think about how spam/bots would influence your metric. .и
d. Sensitivity and Robustness- when choosing metrics, make sure the directional change of the metric is in line with your expectation and the change is unlikely due to bot behavior and it would not take too long to evaluate.
e.g. mean is sensitive to outliers, median is robust but not sensitive to changes to small group of users. can use a/a test to measure the robustness
Calculating variability – 统计学or estimate the variance empirically with a/a test.
如果样本量够大:n*p>=5 and n*(1-p)>=5
近似normal distribution
. 1point 3acres
3. Choose population
Inter-user (两组用户)
Intra-user (一组用户,前后实验)
Control variables (demographic, behavior in the past…)
US only?
4. check unit of diversion – consistent experience, user visibility. 1point3acres.com
User id
Anonymous id(cookie)
Event. ----
Device id
IP address
1)User consistence –users visibility or Measure learning effect (if load is slower, will users use less, need to see across time)
2)Ethical consideration
3)variability – empirical variability may be much higher than analytical variability. . 1point 3 acres
Because when unit of analysis (the denominator of metrics) is different from unit of diversion. E.g. unit of analysis is pageview and unit of diversion is cookie.
When you’re doing event-based diversion, every single event is different random draw. When you’re using cookie- based diversion, they are correlated,which increase the variability.
.
5. Control variables
. check 1point3acres for more.
randomized experiment,
when volume is high enough volume to avoid bias
in web traffic experiment. because you cannot control what traffic will come in,
可以后期过滤 如过滤新用户
Matched pair experiment. From 1point 3acres bbs
List potential variables
Is the data available?
Logical connection between control and target variables
Test correlation between control and target variables
Test correlation between control variables and delete repeated ones
8. analyze the result
. From 1point 3acres bbs
Sanity check (make sure test and control are comparable, e.g. test of mean for invariant variables with t test)
9. Make suggestion
a. Do I have statistical/practical significance?
b. Do I understand the change? Who is going to be impacted?.--
c. Is it worth it? Cost vs benefit?
.
广告业
measurement metrics
• lift = (actual conversion-baseline)/baseline
• ROAS (return on ad spend) = revenue / cost
Example: post an ad on facebook. check 1point3acres for more.
Randomized control trial (RCT) . 1point 3 acres
Step 1 Randomization check: control group and test group
User age, gender, married, length of time using FB, # of friends, # of FB uses in last 7 days/28 days
. ----
Step 2 serve ghost ads. ----
if control group should get the ads, show them the second ads. If they shouldn’t get the ads, show them the original ads
. check 1point3acres for more.
.--
With A/A test, we can
1. Test sensitivity and robustness: if there is lots of variability, to sensitive
2. Compare result to what you expect (sanity check)
3. Estimate variance empirically and use your assumption about the distribution to calculate confidence
4. Directly estimate confidence interval without making any assumption of the data
5. a/b test duration. Χ
pitfalls
1. interaction: 两组互相影响,比如uber 司机乘客,facebook friends
解决方法:选取完全隔绝的两组(network, geo) then match comparable market in pairs ..
2. novelty effect
解决方法:only select new users. check 1point3acres for more.
3. 需要较长时间才知道结果,如subscription retention
解决方法:use model to find short metrics can move the long term one. ----
4. selection bias
解决方法:exact matching
5. test win but not launch it –labor cost, risk and bug
6. 多个metrics一起实验,容易出现significant
7. learning effect
8. 看到p value significant 就停止实验
9. Seasonal effect in experiments – airbnb traveling season. 1point 3acres
10. Cannibalization – because of the potential interaction of people within each experiment group.