Skip to content

Commit 4c73f4c

Browse files
cdhawkemillotp
andauthoredNov 7, 2024··
feat(specs): add estimate path and responses [skip-bc] (#4057)
Co-authored-by: Pierre Millot <pierre.millot@algolia.com>
1 parent 64c5667 commit 4c73f4c

File tree

5 files changed

+140
-4
lines changed

5 files changed

+140
-4
lines changed
 

‎specs/abtesting/common/schemas/ABTest.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,13 @@ MinimumDetectableEffect:
154154
description: |
155155
Smallest difference in an observable metric between variants.
156156
For example, to detect a 10% difference between variants, set this value to 0.1.
157-
effect:
158-
$ref: '#/Effect'
157+
metric:
158+
$ref: '#/EffectMetric'
159+
required:
160+
- size
161+
- metric
159162

160-
Effect:
163+
EffectMetric:
161164
type: string
162165
description: Metric for which you want to detect the smallest relative difference.
163166
enum:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
EstimateABTestResponse:
2+
type: object
3+
properties:
4+
durationDays:
5+
type: integer
6+
format: int64
7+
description: Estimated number of days needed to reach the sample sizes required for detecting the configured effect. This value is based on historical traffic.
8+
example: 21
9+
controlSampleSize:
10+
type: integer
11+
format: int64
12+
description: Number of tracked searches needed to be able to detect the configured effect for the control variant.
13+
example: 23415
14+
experimentSampleSize:
15+
type: integer
16+
format: int64
17+
description: Number of tracked searches needed to be able to detect the configured effect for the experiment variant.
18+
example: 23415

‎specs/abtesting/paths/estimate.yml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
post:
2+
tags:
3+
- abtest
4+
operationId: estimateABTest
5+
x-acl:
6+
- analytics
7+
summary: Estimate the sample size and duration of an A/B test
8+
description: Given the traffic percentage and the expected effect size, this endpoint estimates the sample size and duration of an A/B test based on historical traffic.
9+
requestBody:
10+
required: true
11+
content:
12+
application/json:
13+
schema:
14+
title: estimateABTestRequest
15+
type: object
16+
additionalProperties: false
17+
properties:
18+
configuration:
19+
title: estimateConfiguration
20+
type: object
21+
description: A/B test configuration for estimating the sample size and duration using minimum detectable effect.
22+
properties:
23+
outliers:
24+
$ref: '../common/schemas/ABTest.yml#/Outliers'
25+
emptySearch:
26+
$ref: '../common/schemas/ABTest.yml#/EmptySearch'
27+
minimumDetectableEffect:
28+
$ref: '../common/schemas/ABTest.yml#/MinimumDetectableEffect'
29+
required:
30+
- minimumDetectableEffect
31+
variants:
32+
type: array
33+
description: A/B test variants.
34+
minItems: 2
35+
maxItems: 2
36+
items:
37+
$ref: '../common/schemas/AddABTestsVariant.yml#/AddABTestsVariant'
38+
required:
39+
- configuration
40+
- variants
41+
responses:
42+
'200':
43+
description: OK
44+
headers:
45+
x-ratelimit-limit:
46+
$ref: '../../common/responses/rateLimit.yml#/x-ratelimit-limit'
47+
x-ratelimit-remaining:
48+
$ref: '../../common/responses/rateLimit.yml#/x-ratelimit-remaining'
49+
x-ratelimit-reset:
50+
$ref: '../../common/responses/rateLimit.yml#/x-ratelimit-reset'
51+
content:
52+
application/json:
53+
schema:
54+
$ref: '../common/schemas/EstimateABTestResponse.yml#/EstimateABTestResponse'
55+
'400':
56+
$ref: '../../common/responses/BadRequest.yml'
57+
'402':
58+
$ref: '../../common/responses/FeatureNotEnabled.yml'
59+
'403':
60+
$ref: '../../common/responses/MethodNotAllowed.yml'
61+
'404':
62+
$ref: '../../common/responses/IndexNotFound.yml'

‎specs/abtesting/spec.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ tags:
7979
description: |
8080
Manage A/B tests.
8181
82-
A/B tests are configurations of two indices, usually your production index and an index with different settings that you want to test.
82+
A/B tests are configurations one or more indices, usually your production index and an index with different settings that you want to test.
8383
x-tagGroups:
8484
- name: General
8585
tags:
@@ -99,6 +99,8 @@ paths:
9999
$ref: 'paths/stopABTest.yml'
100100
/2/abtests/schedule:
101101
$ref: 'paths/scheduleABTest.yml'
102+
/2/abtests/estimate:
103+
$ref: 'paths/estimate.yml'
102104

103105
# ###############
104106
# ### Helpers ###
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
[
2+
{
3+
"testName": "estimate AB Test sample size",
4+
"parameters": {
5+
"configuration": {
6+
"emptySearch": {
7+
"exclude": true
8+
},
9+
"minimumDetectableEffect": {
10+
"size": 0.03,
11+
"metric": "conversionRate"
12+
}
13+
},
14+
"variants": [
15+
{
16+
"index": "AB_TEST_1",
17+
"trafficPercentage": 50
18+
},
19+
{
20+
"index": "AB_TEST_2",
21+
"trafficPercentage": 50
22+
}
23+
]
24+
},
25+
"request": {
26+
"path": "/2/abtests/estimate",
27+
"method": "POST",
28+
"body": {
29+
"configuration": {
30+
"emptySearch": {
31+
"exclude": true
32+
},
33+
"minimumDetectableEffect": {
34+
"size": 0.03,
35+
"metric": "conversionRate"
36+
}
37+
},
38+
"variants": [
39+
{
40+
"index": "AB_TEST_1",
41+
"trafficPercentage": 50
42+
},
43+
{
44+
"index": "AB_TEST_2",
45+
"trafficPercentage": 50
46+
}
47+
]
48+
}
49+
}
50+
}
51+
]

0 commit comments

Comments
 (0)
Please sign in to comment.