ablift 0.5.0a1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ablift-0.5.0a1/LICENSE +21 -0
- ablift-0.5.0a1/PKG-INFO +474 -0
- ablift-0.5.0a1/README.md +445 -0
- ablift-0.5.0a1/ablift/__init__.py +11 -0
- ablift-0.5.0a1/ablift/cli.py +536 -0
- ablift-0.5.0a1/ablift/connectors.py +454 -0
- ablift-0.5.0a1/ablift/engine.py +755 -0
- ablift-0.5.0a1/ablift/models.py +134 -0
- ablift-0.5.0a1/ablift/planning.py +247 -0
- ablift-0.5.0a1/ablift/reporting.py +163 -0
- ablift-0.5.0a1/ablift.egg-info/PKG-INFO +474 -0
- ablift-0.5.0a1/ablift.egg-info/SOURCES.txt +27 -0
- ablift-0.5.0a1/ablift.egg-info/dependency_links.txt +1 -0
- ablift-0.5.0a1/ablift.egg-info/entry_points.txt +2 -0
- ablift-0.5.0a1/ablift.egg-info/requires.txt +3 -0
- ablift-0.5.0a1/ablift.egg-info/top_level.txt +1 -0
- ablift-0.5.0a1/pyproject.toml +85 -0
- ablift-0.5.0a1/setup.cfg +4 -0
- ablift-0.5.0a1/tests/test_cli_analyze.py +176 -0
- ablift-0.5.0a1/tests/test_cli_doctor.py +16 -0
- ablift-0.5.0a1/tests/test_cli_edge_cases.py +596 -0
- ablift-0.5.0a1/tests/test_connectors.py +199 -0
- ablift-0.5.0a1/tests/test_engine.py +317 -0
- ablift-0.5.0a1/tests/test_engine_edge_cases.py +852 -0
- ablift-0.5.0a1/tests/test_inputs_edge_cases.py +603 -0
- ablift-0.5.0a1/tests/test_planning.py +64 -0
- ablift-0.5.0a1/tests/test_release_051.py +164 -0
- ablift-0.5.0a1/tests/test_reporting.py +280 -0
- ablift-0.5.0a1/tests/test_review_regressions.py +174 -0
ablift-0.5.0a1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Fabio-RibeiroB
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
ablift-0.5.0a1/PKG-INFO
ADDED
|
@@ -0,0 +1,474 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ablift
|
|
3
|
+
Version: 0.5.0a1
|
|
4
|
+
Summary: Agent-friendly CLI for Bayesian and sequential A/B/n experiment decisions
|
|
5
|
+
Author-email: Fabio-RibeiroB <bradyfr@proton.me>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/Fabio-RibeiroB/ablift
|
|
8
|
+
Project-URL: Repository, https://github.com/Fabio-RibeiroB/ablift
|
|
9
|
+
Project-URL: Changelog, https://github.com/Fabio-RibeiroB/ablift/blob/main/CHANGELOG.md
|
|
10
|
+
Project-URL: Issues, https://github.com/Fabio-RibeiroB/ablift/issues
|
|
11
|
+
Keywords: ab-testing,experimentation,bayesian,sequential-testing,cli,statistics
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
22
|
+
Requires-Python: >=3.11
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: click>=8.0
|
|
26
|
+
Requires-Dist: numpy>=1.22
|
|
27
|
+
Requires-Dist: openpyxl>=3.1.0
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# ablift
|
|
31
|
+
|
|
32
|
+
[](https://www.python.org/)
|
|
33
|
+
[](https://github.com/astral-sh/uv)
|
|
34
|
+
[](https://github.com/astral-sh/ruff)
|
|
35
|
+
[](https://pre-commit.com/)
|
|
36
|
+
|
|
37
|
+
`ablift` is an agent-friendly CLI for A/B/n decisions.
|
|
38
|
+
|
|
39
|
+
> Early release (alpha): this project is work in progress and not production-hardened yet.
|
|
40
|
+
|
|
41
|
+
It supports:
|
|
42
|
+
- Bayesian conversion-rate decisions (Beta-Binomial)
|
|
43
|
+
- Bayesian ARPU decisions from aggregate revenue statistics (Normal-Inverse-Gamma)
|
|
44
|
+
- Sequential decisions with mSPRT and always-valid confidence intervals: look as often as you like
|
|
45
|
+
- Multi-variant (`A/B/n`) comparisons against one control
|
|
46
|
+
- Guardrail checks (latency, bounce rate, error rate, etc.)
|
|
47
|
+
- SRM detection (sample ratio mismatch) for data quality
|
|
48
|
+
- Test duration planning (sequential, fixed-horizon, Bayesian assurance)
|
|
49
|
+
- Structured JSON output (versioned with `schema_version`) for agents and automations
|
|
50
|
+
- Markdown report generation for human review
|
|
51
|
+
- CSV/XLSX ingestion with positional column layout
|
|
52
|
+
|
|
53
|
+
## Install
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
uv tool install ablift # or: pipx install ablift / pip install ablift
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
This installs `ablift` as a normal CLI tool and exposes the `ablift` command on your `PATH`.
|
|
60
|
+
To install from a checkout instead, run `uv tool install .` in the repo.
|
|
61
|
+
|
|
62
|
+
To work from the repo during development:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
uv sync
|
|
66
|
+
uv run ablift --help
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
If you want an editable install in an existing environment:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
uv pip install -e .
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Quickstart
|
|
76
|
+
|
|
77
|
+
The commands below assume `ablift` is on your `PATH`; from the repo, prefix them with `uv run`.
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
ablift --help
|
|
81
|
+
ablift analyze --help
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Generate a JSON input template and analyze it:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
ablift example-input > input.json
|
|
88
|
+
ablift analyze --input input.json --output output.json --report report.md
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Analyze a CSV (positional columns, see [CSV/XLSX input](#csvxlsx-input)). The Bayesian method is the default; without a decision policy it reports estimates and leaves `recommendation` as `null`:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
ablift analyze --input examples/conversion_multivariant.csv
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Add a Bayesian decision policy to get a recommendation:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
ablift analyze --input examples/conversion_multivariant.csv \
|
|
101
|
+
--enable-recommendation --prob-threshold 0.95 --max-expected-loss 0.001
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Run a sequential (mSPRT) analysis. It always produces a recommendation:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
ablift analyze --input examples/arpu_sequential.csv --method sequential
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Plan how long a test needs to run:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
ablift duration --baseline-rate 0.04 --relative-mde 0.05 --daily-traffic 50000 --n-variants 3
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Command summary
|
|
117
|
+
|
|
118
|
+
- `ablift analyze`: analyze `.json`, `.csv`, `.xlsx`, or `.xlsm` input
|
|
119
|
+
- `ablift duration`: estimate runtime needed for a conversion-rate test
|
|
120
|
+
- `ablift doctor`: verify the environment and required dependencies (`--json-output`, `--strict`)
|
|
121
|
+
- `ablift example-input`: print a starter JSON payload
|
|
122
|
+
|
|
123
|
+
Useful `analyze` flags: `--method {bayesian,sequential}`, `--primary-metric {conversion_rate,arpu}`, `--alpha`, `--sequential-tau`, `--samples`, `--random-seed`, `--enable-recommendation/--no-recommendation`, `--prob-threshold`, `--max-expected-loss`, `--experiment-name`, `--sheet`, `--output`, `--report`. Flags override values in the input file.
|
|
124
|
+
|
|
125
|
+
## Choosing the metric model
|
|
126
|
+
|
|
127
|
+
Use `primary_metric: "conversion_rate"` when each row represents:
|
|
128
|
+
- a denominator count
|
|
129
|
+
- a success count
|
|
130
|
+
- successes that cannot exceed the denominator
|
|
131
|
+
|
|
132
|
+
Examples that fit this model:
|
|
133
|
+
- sessions and click-through sessions
|
|
134
|
+
- users and purchasers
|
|
135
|
+
- emails delivered and openers
|
|
136
|
+
- visits and visits with at least one signup
|
|
137
|
+
|
|
138
|
+
Use `primary_metric: "arpu"` (average revenue per visitor) when you have aggregate revenue statistics per variant:
|
|
139
|
+
- `visitors`
|
|
140
|
+
- `revenue_sum`
|
|
141
|
+
- `revenue_sum_squares` (needed to estimate variance)
|
|
142
|
+
|
|
143
|
+
If your metric can happen multiple times per unit and the count can exceed the denominator, it is not a fit for the `conversion_rate` model. For example:
|
|
144
|
+
- visits and total clicks across all visits
|
|
145
|
+
- users and page views
|
|
146
|
+
- sessions and multiple add-to-cart events
|
|
147
|
+
|
|
148
|
+
In those cases, either:
|
|
149
|
+
- redefine the outcome as binary per unit, such as "visit with at least one click"
|
|
150
|
+
- or use a different metric/model outside the current scope of this tool
|
|
151
|
+
|
|
152
|
+
## Input rules
|
|
153
|
+
|
|
154
|
+
The input contract is strict about semantics, not source column names.
|
|
155
|
+
|
|
156
|
+
`ablift` separates:
|
|
157
|
+
- inference settings: priors, posterior sample count, random seed
|
|
158
|
+
- decision policy: thresholds used to turn Bayesian estimates into actions
|
|
159
|
+
|
|
160
|
+
For Bayesian runs, recommendations are optional. If you do not provide a decision policy, `ablift` reports the posterior estimates but leaves `recommendation` as `null`. Sequential runs always produce a recommendation; the decision policy does not apply to them.
|
|
161
|
+
|
|
162
|
+
For analysis inputs:
|
|
163
|
+
- at least 2 variants are required
|
|
164
|
+
- exactly 1 variant must have `is_control: true`
|
|
165
|
+
- `method` must be `bayesian` or `sequential`
|
|
166
|
+
- `primary_metric` must be `conversion_rate` or `arpu`
|
|
167
|
+
- `visitors` must be a positive integer
|
|
168
|
+
- `conversions` must be a non-negative integer and cannot exceed `visitors`
|
|
169
|
+
- `alpha` must be in `(0, 1)`; `sequential_tau` must be positive
|
|
170
|
+
- for `arpu`, each variant must also include `revenue_sum` and `revenue_sum_squares`
|
|
171
|
+
|
|
172
|
+
Bayesian defaults:
|
|
173
|
+
- posterior sample count defaults to `50000`
|
|
174
|
+
- random seed defaults to `7`
|
|
175
|
+
- conversion-rate prior is `Beta(1, 1)`
|
|
176
|
+
- ARPU prior is a weak `Normal-Inverse-Gamma` prior with `mu0=0`, `kappa0=1e-6`, `alpha0=1`, `beta0=1`
|
|
177
|
+
|
|
178
|
+
Bayesian recommendations require an explicit decision policy, either in the input payload, via `[tool.ablift]` in `pyproject.toml`, or via CLI flags:
|
|
179
|
+
- `--enable-recommendation`
|
|
180
|
+
- `--prob-threshold` (default `0.95`)
|
|
181
|
+
- `--max-expected-loss` (default `0.001`)
|
|
182
|
+
|
|
183
|
+
Sequential defaults:
|
|
184
|
+
- `alpha` defaults to `0.05`
|
|
185
|
+
- `sequential_tau` (CLI `--sequential-tau`) is the mSPRT mixing parameter: the prior standard deviation of the effect on the absolute scale. It defaults to 10% of the control baseline (conversion rate or ARPU). Pass it explicitly if you expect much larger or smaller effects.
|
|
186
|
+
- You may look at results as often as you like: the false-positive rate stays at `alpha`.
|
|
187
|
+
|
|
188
|
+
Internal field meanings:
|
|
189
|
+
- `name`: variant label
|
|
190
|
+
- `visitors`: denominator units exposed to the experiment
|
|
191
|
+
- `conversions`: success units for the primary outcome
|
|
192
|
+
- `is_control`: whether the row is the control variant
|
|
193
|
+
|
|
194
|
+
## JSON input
|
|
195
|
+
|
|
196
|
+
Top-level fields:
|
|
197
|
+
- `experiment_name` (str)
|
|
198
|
+
- `method` (`"bayesian"` or `"sequential"`)
|
|
199
|
+
- `primary_metric` (`"conversion_rate"` or `"arpu"`)
|
|
200
|
+
- `alpha` (float, default `0.05`)
|
|
201
|
+
- `sequential_tau` (optional float, sequential mode; default 10% of the control baseline)
|
|
202
|
+
- `variants` (list): exactly one row must include `"is_control": true`
|
|
203
|
+
- `guardrails` (optional list)
|
|
204
|
+
- `decision_policy` (optional, Bayesian mode):
|
|
205
|
+
- `enabled` (bool)
|
|
206
|
+
- `bayes_prob_beats_control` (default `0.95`)
|
|
207
|
+
- `max_expected_loss` (default `0.001`)
|
|
208
|
+
- `samples` (default `50000`, Bayesian mode)
|
|
209
|
+
- `random_seed` (default `7`)
|
|
210
|
+
|
|
211
|
+
`decision_thresholds` is still accepted as a legacy alias for an enabled `decision_policy`; use `decision_policy` in new inputs.
|
|
212
|
+
|
|
213
|
+
Variant row:
|
|
214
|
+
|
|
215
|
+
```json
|
|
216
|
+
{
|
|
217
|
+
"name": "control",
|
|
218
|
+
"visitors": 100000,
|
|
219
|
+
"conversions": 4000,
|
|
220
|
+
"is_control": true
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
For `primary_metric: "arpu"`, each variant also needs `revenue_sum` and `revenue_sum_squares`.
|
|
225
|
+
|
|
226
|
+
Guardrail row (`ablift example-input` prints a full example):
|
|
227
|
+
|
|
228
|
+
```json
|
|
229
|
+
{"name": "bounce_rate", "control": 0.36, "treatment": 0.365, "direction": "decrease", "max_relative_change": 0.03}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
Bayesian conversion-rate example with a decision policy:
|
|
233
|
+
|
|
234
|
+
```json
|
|
235
|
+
{
|
|
236
|
+
"experiment_name": "homepage_cta",
|
|
237
|
+
"method": "bayesian",
|
|
238
|
+
"primary_metric": "conversion_rate",
|
|
239
|
+
"decision_policy": {
|
|
240
|
+
"enabled": true,
|
|
241
|
+
"bayes_prob_beats_control": 0.95,
|
|
242
|
+
"max_expected_loss": 0.001
|
|
243
|
+
},
|
|
244
|
+
"variants": [
|
|
245
|
+
{"name": "control", "visitors": 50000, "conversions": 2000, "is_control": true},
|
|
246
|
+
{"name": "v1", "visitors": 50000, "conversions": 2080, "is_control": false},
|
|
247
|
+
{"name": "v2", "visitors": 50000, "conversions": 2140, "is_control": false}
|
|
248
|
+
]
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Bayesian ARPU example:
|
|
253
|
+
|
|
254
|
+
```json
|
|
255
|
+
{
|
|
256
|
+
"experiment_name": "pricing_page",
|
|
257
|
+
"method": "bayesian",
|
|
258
|
+
"primary_metric": "arpu",
|
|
259
|
+
"variants": [
|
|
260
|
+
{"name": "control", "visitors": 10000, "conversions": 550, "revenue_sum": 22000, "revenue_sum_squares": 150000, "is_control": true},
|
|
261
|
+
{"name": "v1", "visitors": 10000, "conversions": 570, "revenue_sum": 23500, "revenue_sum_squares": 170000, "is_control": false}
|
|
262
|
+
]
|
|
263
|
+
}
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
Sequential ARPU example (re-run it on cumulative data whenever new data arrives):
|
|
267
|
+
|
|
268
|
+
```json
|
|
269
|
+
{
|
|
270
|
+
"experiment_name": "checkout_flow",
|
|
271
|
+
"method": "sequential",
|
|
272
|
+
"primary_metric": "arpu",
|
|
273
|
+
"alpha": 0.05,
|
|
274
|
+
"sequential_tau": 0.2,
|
|
275
|
+
"variants": [
|
|
276
|
+
{"name": "control", "visitors": 12000, "conversions": 610, "revenue_sum": 21000, "revenue_sum_squares": 150000, "is_control": true},
|
|
277
|
+
{"name": "v1", "visitors": 12000, "conversions": 640, "revenue_sum": 22400, "revenue_sum_squares": 167000, "is_control": false}
|
|
278
|
+
]
|
|
279
|
+
}
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
## CSV/XLSX input
|
|
283
|
+
|
|
284
|
+
`ablift analyze` reads CSV and XLSX files using **positional columns**: column names are ignored, column order determines the role. The first row must be a header row. Use `--sheet` to select a worksheet in `.xlsx`/`.xlsm` files.
|
|
285
|
+
|
|
286
|
+
### Aggregated input (one row per variant)
|
|
287
|
+
|
|
288
|
+
| Columns (in order) | Analysis |
|
|
289
|
+
|--------------------|----------|
|
|
290
|
+
| `name, visitors, conversions [, is_control]` | `conversion_rate` |
|
|
291
|
+
| `name, visitors, revenue_sum, revenue_sum_squares [, is_control]` | `arpu` |
|
|
292
|
+
| `name, visitors, conversions, revenue_sum, revenue_sum_squares [, is_control]` | `arpu` by default; `--primary-metric conversion_rate` uses the conversions column |
|
|
293
|
+
|
|
294
|
+
Notes:
|
|
295
|
+
- `is_control` is an optional boolean column anywhere after column 3. If its header contains "control", values may be `true`/`false`, `yes`/`no` or `1`/`0`. Under any other header it must use words (`true`/`false`, `yes`/`no`), with at least one of each, because a numeric 0/1 column could be a real metric. Without it, the first row is the control.
|
|
296
|
+
- A single revenue column without sum of squares is rejected with a clear error, because variance cannot be estimated. Add `revenue_sum_squares`, or provide row-level data.
|
|
297
|
+
- Any other number of metric columns is an error.
|
|
298
|
+
|
|
299
|
+
### Row-level input (one row per observation)
|
|
300
|
+
|
|
301
|
+
| Col 1 | Col 2 | Col 3 (optional) |
|
|
302
|
+
|-------|-------|-----------------|
|
|
303
|
+
| variant name | outcome | is_control (boolean) |
|
|
304
|
+
|
|
305
|
+
- If outcomes are all 0/1 the analysis is `conversion_rate` (the tool counts visitors and conversions per variant).
|
|
306
|
+
- If outcomes are continuous the analysis is `arpu`, computed exactly from the rows (`revenue_sum` and `revenue_sum_squares` per variant).
|
|
307
|
+
- Rows are detected as row-level when the first column has repeated values.
|
|
308
|
+
- The first variant to appear is the control unless a boolean control column is present.
|
|
309
|
+
|
|
310
|
+
The JSON output records what was detected in `analysis_settings.input_interpretation`:
|
|
311
|
+
|
|
312
|
+
```json
|
|
313
|
+
{
|
|
314
|
+
"source_type": "aggregated",
|
|
315
|
+
"variant_count": 3,
|
|
316
|
+
"column_roles": {
|
|
317
|
+
"variant": "variant_name",
|
|
318
|
+
"visitors": "users",
|
|
319
|
+
"conversions": "orders",
|
|
320
|
+
"is_control": "is_control"
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
### Bundled examples
|
|
326
|
+
|
|
327
|
+
- [examples/conversion_multivariant.csv](examples/conversion_multivariant.csv): 3-variant conversion rate
|
|
328
|
+
- [examples/arpu_bayesian.csv](examples/arpu_bayesian.csv) and [examples/arpu_bayesian.xlsx](examples/arpu_bayesian.xlsx): ARPU from aggregates
|
|
329
|
+
- [examples/arpu_sequential.csv](examples/arpu_sequential.csv): ARPU, use with `--method sequential`
|
|
330
|
+
- [examples/duration_inputs.csv](examples/duration_inputs.csv) and [examples/duration_inputs.xlsx](examples/duration_inputs.xlsx): duration assumptions
|
|
331
|
+
|
|
332
|
+
`make demo` runs all of them end to end and writes outputs to `examples/out/` (git-ignored).
|
|
333
|
+
|
|
334
|
+
## Reusable project config
|
|
335
|
+
|
|
336
|
+
Use `[tool.ablift]` in `pyproject.toml` (read from the current directory) when you want one decision policy and one set of inference settings reused across analyses in the project.
|
|
337
|
+
|
|
338
|
+
```toml
|
|
339
|
+
[tool.ablift]
|
|
340
|
+
method = "bayesian"
|
|
341
|
+
primary_metric = "conversion_rate"
|
|
342
|
+
samples = 50000
|
|
343
|
+
random_seed = 7
|
|
344
|
+
|
|
345
|
+
[tool.ablift.decision_policy]
|
|
346
|
+
enabled = true
|
|
347
|
+
bayes_prob_beats_control = 0.95
|
|
348
|
+
max_expected_loss = 0.001
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
Precedence is:
|
|
352
|
+
- CLI flags
|
|
353
|
+
- input file
|
|
354
|
+
- `pyproject.toml` `[tool.ablift]`
|
|
355
|
+
- built-in defaults
|
|
356
|
+
|
|
357
|
+
## Duration planning
|
|
358
|
+
|
|
359
|
+
```bash
|
|
360
|
+
# Sequential (default): mSPRT sample size
|
|
361
|
+
ablift duration --baseline-rate 0.04 --relative-mde 0.05 --daily-traffic 50000 --n-variants 3
|
|
362
|
+
|
|
363
|
+
# Classic fixed-horizon (only valid if you look once, at the end)
|
|
364
|
+
ablift duration --method fixed --baseline-rate 0.04 --relative-mde 0.05 --daily-traffic 50000 --n-variants 3
|
|
365
|
+
|
|
366
|
+
# Bayesian assurance (simulation-based)
|
|
367
|
+
ablift duration --method bayesian --baseline-rate 0.04 --relative-mde 0.08 --daily-traffic 60000 --max-days 60
|
|
368
|
+
|
|
369
|
+
# From a CSV/XLSX with named columns
|
|
370
|
+
ablift duration --input examples/duration_inputs.csv
|
|
371
|
+
ablift duration --input examples/duration_inputs.xlsx --sheet Sheet1
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
Methods:
|
|
375
|
+
- `sequential` (default): smallest sample size per variant at which the always-valid mSPRT test reaches the target power. This is a conservative upper bound, since the test may stop earlier if the true effect exceeds the MDE. Diagnostics include `fixed_horizon_n_per_variant` and `sequential_inflation` (typically about 2x).
|
|
376
|
+
- `fixed`: classic fixed-horizon two-proportion sample size. Only valid if you analyze once. The output reports `"method": "fixed_horizon"`.
|
|
377
|
+
- `bayesian`: simulation-based assurance, the probability of reaching the Bayesian decision thresholds within `--max-days`.
|
|
378
|
+
|
|
379
|
+
Both `sequential` and `fixed` apply a Bonferroni correction across `n_variants - 1` comparisons.
|
|
380
|
+
|
|
381
|
+
Inputs:
|
|
382
|
+
- `--baseline-rate`, `--relative-mde` and `--daily-traffic` are required, from flags or `--input`. The command never prompts; missing values are a usage error (exit code 2).
|
|
383
|
+
- Optional: `--method`, `--n-variants` (default 2, including control), `--alpha` (0.05), `--power` (0.8), `--sequential-tau`, `--prob-threshold`, `--max-expected-loss`, `--assurance-target`, `--max-days`, `--output`.
|
|
384
|
+
- `--input` takes a CSV/XLSX whose first row has **named** columns: `method`, `baseline_rate`, `relative_mde`, `daily_traffic`, `n_variants`, `alpha`, `power`, `sequential_tau`, `prob_threshold`, `max_expected_loss`, `assurance_target`, `max_days`. Unknown columns are an error. CLI flags override file values.
|
|
385
|
+
- Settings the chosen method does not use are a usage error rather than being silently ignored: `--alpha`, `--power` and `--sequential-tau` do not apply to `bayesian`; `--prob-threshold`, `--max-expected-loss`, `--assurance-target` and `--max-days` apply only to `bayesian`; `--sequential-tau` applies only to `sequential`.
|
|
386
|
+
- Duration planning is conversion-rate only.
|
|
387
|
+
|
|
388
|
+
Example `--input` file:
|
|
389
|
+
|
|
390
|
+
```csv
|
|
391
|
+
method,baseline_rate,relative_mde,daily_traffic,n_variants,alpha,power
|
|
392
|
+
sequential,0.04,0.05,50000,3,0.05,0.8
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
## Statistical methods
|
|
396
|
+
|
|
397
|
+
- **Conversion rate (Bayesian):** Beta-Binomial posterior with a `Beta(1, 1)` prior. Probability to beat control and expected loss come from posterior sampling; `ci_low`/`ci_high` are 95% credible intervals.
|
|
398
|
+
- **ARPU (Bayesian):** Normal-Inverse-Gamma posterior for the mean revenue per visitor, built from `visitors`, `revenue_sum` and `revenue_sum_squares`.
|
|
399
|
+
- **Sequential (mSPRT):** mixture sequential probability ratio test (Johari et al. 2017) on the difference in means, giving an e-value and a Bonferroni-adjusted always-valid p-value `min(1, n_comparisons/e_value)` (so `p_value <= alpha` exactly when `significant`), plus an always-valid confidence interval. A comparison is significant when `e_value >= e_threshold`. The mixing parameter is `sequential_tau`.
|
|
400
|
+
- **Multiple variants:** in sequential mode alpha is Bonferroni-corrected: `alpha_per_comparison = alpha / number_of_treatments` and `e_threshold = 1 / alpha_per_comparison`. Bayesian mode applies no correction. Both are reported in `analysis_settings.multiple_comparisons`.
|
|
401
|
+
- **SRM:** chi-square goodness-of-fit of the visitor counts against an equal split. Failure when `p < 0.001`.
|
|
402
|
+
|
|
403
|
+
## Agent playbook
|
|
404
|
+
|
|
405
|
+
1. Run `ablift analyze --input ...` with a JSON, CSV, or XLSX file.
|
|
406
|
+
2. For CSV/XLSX, format data with positional columns (see CSV/XLSX input).
|
|
407
|
+
3. Read `recommendation.action`, `decision_confidence`, and `risk_flags`.
|
|
408
|
+
4. If `action=continue_collecting_data`, re-run on the cumulative data later. With `--method sequential` this is always safe, however often you look.
|
|
409
|
+
5. If `action=investigate_data_quality`, resolve SRM or tracking issues before deciding to ship.
|
|
410
|
+
6. For planning questions, run `ablift duration`.
|
|
411
|
+
|
|
412
|
+
Exit codes:
|
|
413
|
+
- `0`: success
|
|
414
|
+
- `1`: analysis or input error (a clean `Error: ...` message on stderr, no traceback)
|
|
415
|
+
- `2`: CLI usage error (bad flag value, missing file, missing required duration assumptions)
|
|
416
|
+
|
|
417
|
+
Common errors and fixes:
|
|
418
|
+
- `Exactly one variant must have is_control=true`: mark one and only one control row.
|
|
419
|
+
- `conversions cannot exceed visitors`: the metric is a repeated-event count rather than a binary outcome. Redefine it as binary per unit.
|
|
420
|
+
- `Column '...' looks like revenue, not conversions`: add a `revenue_sum_squares` column (or use row-level data) for ARPU.
|
|
421
|
+
- `Unknown duration column(s)`: use only the named columns listed in Duration planning.
|
|
422
|
+
|
|
423
|
+
## Agent output contract
|
|
424
|
+
|
|
425
|
+
Output JSON starts with `"schema_version": "1"` (for both `analyze` and `duration`).
|
|
426
|
+
|
|
427
|
+
`analysis_settings` includes `multiple_comparisons` (`correction`, `n_comparisons`, and for sequential `alpha_per_comparison`), `sequential_tau`, `priors`, `decision_policy` and `input_interpretation`.
|
|
428
|
+
|
|
429
|
+
Each entry in `comparisons` has:
|
|
430
|
+
- `control_rate`, `treatment_rate`, `absolute_lift`, `relative_lift`
|
|
431
|
+
- `ci_low`, `ci_high`: interval on the **absolute** lift scale. Bayesian: 95% credible interval. Sequential: always-valid confidence interval.
|
|
432
|
+
- Bayesian only: `probability_beats_control`, `expected_loss`, `relative_ci_low`, `relative_ci_high`
|
|
433
|
+
- Sequential only: `p_value` (always-valid and Bonferroni-adjusted, `min(1, n_comparisons/e_value)`; `p_value <= alpha` exactly when `significant`), `e_value`, `e_threshold`, `significant`
|
|
434
|
+
|
|
435
|
+
`recommendation` contains:
|
|
436
|
+
- `action` (`ship_<variant>`, `continue_collecting_data`, `do_not_ship`, `investigate_data_quality`, `stop_and_rollback`)
|
|
437
|
+
- `rationale`
|
|
438
|
+
- `decision_confidence` (0 to 1)
|
|
439
|
+
- `next_best_action`
|
|
440
|
+
- `risk_flags`
|
|
441
|
+
|
|
442
|
+
How the sequential recommendation is chosen:
|
|
443
|
+
- `ship_<variant>`: the best significantly positive variant, even if others are not significant. `decision_confidence = 1 - p_value` of the winner. If another variant is significantly worse, `other_variant_significantly_worse` is added to `risk_flags`.
|
|
444
|
+
- `stop_and_rollback`: only if every treatment is significantly worse. `decision_confidence = 1 - p_value` of the losers (the largest of them).
|
|
445
|
+
- `continue_collecting_data`: otherwise. `decision_confidence = 1 - p_value` of the leading comparison (the smallest adjusted p-value), so higher means closer to significance; it stays below `1 - alpha` until a decision is reached. `some_variants_significantly_worse` is added if at least one variant is significantly worse.
|
|
446
|
+
|
|
447
|
+
Applies to both methods, checked first:
|
|
448
|
+
- SRM failure gives `investigate_data_quality`, flag `srm_detected`, `decision_confidence = 1 - SRM p-value`.
|
|
449
|
+
- Guardrail failure gives `do_not_ship`, flag `guardrail_failure`, `decision_confidence = 1.0` (a deterministic rule, not a statistical test).
|
|
450
|
+
|
|
451
|
+
If no explicit Bayesian decision policy is provided, `recommendation` is `null` and `analysis_settings.decision_policy` shows that no automated decision policy was applied.
|
|
452
|
+
|
|
453
|
+
## Limitations
|
|
454
|
+
|
|
455
|
+
- ARPU uses a normal approximation of the mean. Heavy-tailed revenue may need winsorising upstream.
|
|
456
|
+
- SRM assumes an equal traffic split across variants.
|
|
457
|
+
- mSPRT guarantees assume you re-run the analysis on cumulative data as it arrives. The tool keeps no state between looks.
|
|
458
|
+
- No variance reduction (CUPED) yet.
|
|
459
|
+
- Duration planning is conversion-rate only.
|
|
460
|
+
|
|
461
|
+
## License
|
|
462
|
+
|
|
463
|
+
MIT. See [LICENSE](LICENSE).
|
|
464
|
+
|
|
465
|
+
## Development
|
|
466
|
+
|
|
467
|
+
```bash
|
|
468
|
+
uv sync # installs the test and lint groups
|
|
469
|
+
uv run pytest # test suite
|
|
470
|
+
uv run ruff check . # lint
|
|
471
|
+
uv run ty check # type check
|
|
472
|
+
make demo # run all bundled examples into examples/out/
|
|
473
|
+
uv run ablift doctor # environment check (also --json-output, --strict)
|
|
474
|
+
```
|