fast-exp-analytics 0.1.3__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.
- fast_exp_analytics-0.1.3/CHANGELOG.md +40 -0
- fast_exp_analytics-0.1.3/LICENSE +2 -0
- fast_exp_analytics-0.1.3/MANIFEST.in +5 -0
- fast_exp_analytics-0.1.3/PKG-INFO +557 -0
- fast_exp_analytics-0.1.3/README.md +520 -0
- fast_exp_analytics-0.1.3/examples/fast_exp_analytics_example.ipynb +6480 -0
- fast_exp_analytics-0.1.3/fast_exp_analytics/__init__.py +56 -0
- fast_exp_analytics-0.1.3/fast_exp_analytics/ab.py +649 -0
- fast_exp_analytics-0.1.3/fast_exp_analytics/abc.py +460 -0
- fast_exp_analytics-0.1.3/fast_exp_analytics/config.py +49 -0
- fast_exp_analytics-0.1.3/fast_exp_analytics/datasets.py +47 -0
- fast_exp_analytics-0.1.3/fast_exp_analytics/duration.py +669 -0
- fast_exp_analytics-0.1.3/fast_exp_analytics/exporters.py +168 -0
- fast_exp_analytics-0.1.3/fast_exp_analytics/exporters_ab.py +254 -0
- fast_exp_analytics-0.1.3/fast_exp_analytics/exporters_duration.py +375 -0
- fast_exp_analytics-0.1.3/fast_exp_analytics/llm.py +29 -0
- fast_exp_analytics-0.1.3/fast_exp_analytics/messaging.py +47 -0
- fast_exp_analytics-0.1.3/fast_exp_analytics/py.typed +0 -0
- fast_exp_analytics-0.1.3/fast_exp_analytics/reporting.py +313 -0
- fast_exp_analytics-0.1.3/fast_exp_analytics/reporting_ab.py +229 -0
- fast_exp_analytics-0.1.3/fast_exp_analytics.egg-info/PKG-INFO +557 -0
- fast_exp_analytics-0.1.3/fast_exp_analytics.egg-info/SOURCES.txt +28 -0
- fast_exp_analytics-0.1.3/fast_exp_analytics.egg-info/dependency_links.txt +1 -0
- fast_exp_analytics-0.1.3/fast_exp_analytics.egg-info/requires.txt +13 -0
- fast_exp_analytics-0.1.3/fast_exp_analytics.egg-info/top_level.txt +1 -0
- fast_exp_analytics-0.1.3/pyproject.toml +67 -0
- fast_exp_analytics-0.1.3/setup.cfg +10 -0
- fast_exp_analytics-0.1.3/setup.py +3 -0
- fast_exp_analytics-0.1.3/tests/test_imports.py +7 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Все заметные изменения в проекте рекомендуется фиксировать в этом файле
|
|
4
|
+
|
|
5
|
+
## [0.1.3] - 2026-04-12
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
- Мелкие исправления
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## [0.1.2] - 2026-04-12
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
- Обновлена конфигурация
|
|
15
|
+
- Переработан модуль duration: расчёт теперь поддерживает experiment-level агрегации вместо жёсткой привязки к campaign-level
|
|
16
|
+
- `build_campaign_level` заменён на более универсальный `build_experiment_level`, который умеет строить агрегат на уровне любого переданного `unit_id_col` (`user_id`, `campaign_id`, и др.)
|
|
17
|
+
- Обновлены planning-функции duration, чтобы они могли работать в более унифицированной схеме через агрегированный dataframe
|
|
18
|
+
- Обновлена конфигурация дефолтных метрик для duration planning под новый aggregated dataframe context
|
|
19
|
+
- Актуализированы комментарии и docstring'и: вместо campaign-level теперь используется более общее описание aggregated / experiment-level логики
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
- Добавлены новые experiment-level метрики для duration planning:`life_days`, `active_days`, `entities_cnt`
|
|
23
|
+
- Добавлены новые вспомогательные функции для работы с duration planning и MDE на агрегированном уровне
|
|
24
|
+
- Добавлена возможность считать duration planning на уровне любой экспериментальной единицы через `unit_id_col`
|
|
25
|
+
|
|
26
|
+
### Removed
|
|
27
|
+
- Удалён неиспользуемый import в duration-модуле.
|
|
28
|
+
- И еще всякие мелкие касяки
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
## [0.1.1] - 2026-04-12
|
|
32
|
+
|
|
33
|
+
### Changed
|
|
34
|
+
- Обновлена конфигурация
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
## [0.1.0] - 2026-04-12
|
|
38
|
+
|
|
39
|
+
### Added
|
|
40
|
+
- базовая версия
|
|
@@ -0,0 +1,557 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fast_exp_analytics
|
|
3
|
+
Version: 0.1.3
|
|
4
|
+
Summary: Python toolkit for AB/ABC experiment analytics, duration planning, reporting and exports
|
|
5
|
+
Author: Alexey Voronko
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/klipbn/fast_exp_analytics
|
|
8
|
+
Project-URL: Documentation, https://github.com/klipbn/fast_exp_analytics
|
|
9
|
+
Project-URL: Repository, https://github.com/klipbn/fast_exp_analytics
|
|
10
|
+
Project-URL: Issues, https://github.com/klipbn/fast_exp_analytics
|
|
11
|
+
Keywords: ab-test,abc-test,experiment-analysis,mde,voronko,analytics,klipbn
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Intended Audience :: Developers
|
|
18
|
+
Classifier: Intended Audience :: Science/Research
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
20
|
+
Classifier: Operating System :: OS Independent
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: numpy>=1.24
|
|
25
|
+
Requires-Dist: pandas>=2.0
|
|
26
|
+
Requires-Dist: scipy>=1.10
|
|
27
|
+
Requires-Dist: statsmodels>=0.14
|
|
28
|
+
Requires-Dist: requests>=2.0
|
|
29
|
+
Requires-Dist: openpyxl>=3.1
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: build>=1.2.1; extra == "dev"
|
|
32
|
+
Requires-Dist: twine>=5.1.1; extra == "dev"
|
|
33
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
34
|
+
Requires-Dist: ruff>=0.5; extra == "dev"
|
|
35
|
+
Requires-Dist: jupyter>=1.0; extra == "dev"
|
|
36
|
+
Dynamic: license-file
|
|
37
|
+
|
|
38
|
+
# fast_exp_analytics
|
|
39
|
+
|
|
40
|
+
Fast experiment analytics toolkit for A/B and A/B/C tests, MDE estimation, experiment duration planning, reporting, and chat-ready summaries
|
|
41
|
+
|
|
42
|
+
`fast_exp_analytics` is a Python library for analysts and product teams who need to quickly analyze online experiments, calculate experiment metrics, prepare readable summaries, export results to Excel, and estimate the required duration of future tests
|
|
43
|
+
|
|
44
|
+
The library is designed for practical analytics workflows in Jupyter Notebook: prepare data, describe metrics in a simple config, run A/B or A/B/C analysis, generate a styled table, export the result, and prepare a short message for stakeholders
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Examples
|
|
49
|
+
|
|
50
|
+
### Chat-ready experiment summaries
|
|
51
|
+
|
|
52
|
+
<table align="center">
|
|
53
|
+
<tr>
|
|
54
|
+
<td align="center">
|
|
55
|
+
<img src="examples/ab_chat_bot.jpg" alt="A/B test chat summary example" width="340">
|
|
56
|
+
<br>
|
|
57
|
+
<sub>A/B test summary</sub>
|
|
58
|
+
</td>
|
|
59
|
+
<td align="center">
|
|
60
|
+
<img src="examples/abc_chat_bot.jpg" alt="A/B/C test chat summary example" width="340">
|
|
61
|
+
<br>
|
|
62
|
+
<sub>A/B/C test summary</sub>
|
|
63
|
+
</td>
|
|
64
|
+
</tr>
|
|
65
|
+
</table>
|
|
66
|
+
|
|
67
|
+
### Included example notebook and reports
|
|
68
|
+
|
|
69
|
+
The repository contains a full example notebook and several generated report examples:
|
|
70
|
+
|
|
71
|
+
| File | Description |
|
|
72
|
+
|---|---|
|
|
73
|
+
| [`examples/fast_exp_analytics_example.ipynb`](examples/fast_exp_analytics_example.ipynb) | Full notebook with the main workflow: A/B analysis, A/B/C analysis, chat messages, Excel export, MDE and duration planning |
|
|
74
|
+
| [`examples/report_ab_exp_id_4242.xlsx`](examples/report_ab_exp_id_4242.xlsx) | Example Excel report for an A/B test |
|
|
75
|
+
| [`examples/report_abc_id_4242.xlsx`](examples/report_abc_id_4242.xlsx) | Example Excel report for an A/B/C test |
|
|
76
|
+
| [`examples/duration_plan_ab.xlsx`](examples/duration_plan_ab.xlsx) | Example duration planning report |
|
|
77
|
+
| [`examples/duration_plan_ab_custom.xlsx`](examples/duration_plan_ab_custom.xlsx) | Example custom duration planning report |
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## What the library does
|
|
82
|
+
|
|
83
|
+
`fast_exp_analytics` helps with three main tasks:
|
|
84
|
+
|
|
85
|
+
### 1. Experiment result analysis
|
|
86
|
+
|
|
87
|
+
- A/B test analysis
|
|
88
|
+
- A/B/C test analysis
|
|
89
|
+
- Comparison of control and test groups
|
|
90
|
+
- Calculation of absolute and relative metric changes
|
|
91
|
+
- Statistical significance checks
|
|
92
|
+
- Multiple-comparison correction for A/B/C tests
|
|
93
|
+
|
|
94
|
+
### 2. Experiment reporting
|
|
95
|
+
|
|
96
|
+
- Styled result tables for notebooks
|
|
97
|
+
- Short summaries for chats and task comments
|
|
98
|
+
- Excel export with experiment results
|
|
99
|
+
- Optional LLM-based review of experiment results
|
|
100
|
+
- Optional message sending with an attached report
|
|
101
|
+
|
|
102
|
+
### 3. Experiment planning
|
|
103
|
+
|
|
104
|
+
- MDE estimation for different experiment durations
|
|
105
|
+
- Required number of days for target MDE
|
|
106
|
+
- Planning for A/B and A/B/C experiments
|
|
107
|
+
- Support for different rollout shares
|
|
108
|
+
- Aggregation of historical data to experiment-unit level
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Main use cases
|
|
113
|
+
|
|
114
|
+
Use `fast_exp_analytics` when you need to:
|
|
115
|
+
|
|
116
|
+
- quickly calculate A/B test results
|
|
117
|
+
- compare several experiment groups in an A/B/C test
|
|
118
|
+
- prepare a short experiment summary for a manager, product owner, or team chat
|
|
119
|
+
- export experiment results to Excel
|
|
120
|
+
- estimate whether the experiment has enough sensitivity
|
|
121
|
+
- calculate MDE for 7, 14, 21, 28 or more days
|
|
122
|
+
- estimate how many days are needed to detect a target effect
|
|
123
|
+
- reuse the same experiment analysis logic across notebooks and projects
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Installation
|
|
128
|
+
|
|
129
|
+
### From PyPI
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
pip install fast-exp-analytics
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### From GitHub
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
pip install git+https://github.com/your-username/fast_exp_analytics.git
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### For local development
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
git clone https://github.com/your-username/fast_exp_analytics.git
|
|
145
|
+
cd fast_exp_analytics
|
|
146
|
+
|
|
147
|
+
python -m venv venv
|
|
148
|
+
source venv/bin/activate
|
|
149
|
+
|
|
150
|
+
pip install -e ".[dev]"
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## Quick start
|
|
156
|
+
|
|
157
|
+
A full usage example is available in the notebook:
|
|
158
|
+
|
|
159
|
+
```text
|
|
160
|
+
examples/fast_exp_analytics_example.ipynb
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
The notebook shows the main workflow:
|
|
164
|
+
|
|
165
|
+
- loading or generating experiment data
|
|
166
|
+
- configuring metrics
|
|
167
|
+
- running A/B analysis
|
|
168
|
+
- running A/B/C analysis
|
|
169
|
+
- styling result tables
|
|
170
|
+
- building dashboard URLs
|
|
171
|
+
- generating chat messages
|
|
172
|
+
- adding optional LLM review
|
|
173
|
+
- exporting reports to Excel
|
|
174
|
+
- planning experiment duration and MDE
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Basic workflow
|
|
179
|
+
|
|
180
|
+
```python
|
|
181
|
+
import pandas as pd
|
|
182
|
+
|
|
183
|
+
from fast_exp_analytics import (
|
|
184
|
+
run_ab_test,
|
|
185
|
+
style_table_ab,
|
|
186
|
+
build_ab_chat_message,
|
|
187
|
+
export_ab_results_to_excel,
|
|
188
|
+
)
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### 1. Prepare experiment data
|
|
192
|
+
|
|
193
|
+
The input data should usually be aggregated at the experiment unit level
|
|
194
|
+
|
|
195
|
+
Example:
|
|
196
|
+
|
|
197
|
+
| user_id | exp_group | shows | clicks | amount | goals | is_create_ad |
|
|
198
|
+
|--------:|-----------|------:|-------:|-------:|------:|-------------:|
|
|
199
|
+
| 1001 | A | 1200 | 54 | 320.5 | 7 | 1 |
|
|
200
|
+
| 1002 | B | 980 | 41 | 210.0 | 3 | 0 |
|
|
201
|
+
| 1003 | A | 1500 | 73 | 460.7 | 9 | 1 |
|
|
202
|
+
|
|
203
|
+
The library does not force a specific data source. Data can come from SQL, YQL, ClickHouse, CSV, Excel, pandas transformations, or any other pipeline
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
### 2. Describe metrics
|
|
208
|
+
|
|
209
|
+
Metrics are configured with a simple `pandas.DataFrame`
|
|
210
|
+
|
|
211
|
+
```python
|
|
212
|
+
metrics_df = pd.DataFrame.from_dict(
|
|
213
|
+
{
|
|
214
|
+
"shows": ["Shows", "additive", "shows", "shows", "positive"],
|
|
215
|
+
"clicks": ["Clicks", "additive", "clicks", "clicks", "positive"],
|
|
216
|
+
"amount": ["Amount", "additive", "amount", "amount", "positive"],
|
|
217
|
+
"ctr": ["CTR", "ratio", "clicks", "shows", "positive"],
|
|
218
|
+
"cpc": ["CPC", "ratio", "amount", "clicks", "negative"],
|
|
219
|
+
"cpa": ["CPA", "ratio", "amount", "goals", "negative"],
|
|
220
|
+
"cr_created": [
|
|
221
|
+
"Created campaign conversion",
|
|
222
|
+
"share",
|
|
223
|
+
"is_create_ad",
|
|
224
|
+
"is_in_exp",
|
|
225
|
+
"positive",
|
|
226
|
+
],
|
|
227
|
+
},
|
|
228
|
+
orient="index",
|
|
229
|
+
columns=["desc", "type", "num", "den", "direction"],
|
|
230
|
+
)
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Metric config columns:
|
|
234
|
+
|
|
235
|
+
| Column | Meaning |
|
|
236
|
+
|---|---|
|
|
237
|
+
| `desc` | Human-readable metric name |
|
|
238
|
+
| `type` | Metric type: `additive`, `average`, `ratio`, `share` |
|
|
239
|
+
| `num` | Numerator or value column |
|
|
240
|
+
| `den` | Denominator column |
|
|
241
|
+
| `direction` | Direction of improvement: `positive` or `negative` |
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
### 3. Run A/B test
|
|
246
|
+
|
|
247
|
+
```python
|
|
248
|
+
df_result_ab = run_ab_test(
|
|
249
|
+
df=df,
|
|
250
|
+
metrics_df=metrics_df,
|
|
251
|
+
exp_start_date="2026-03-17",
|
|
252
|
+
exp_end_date="2026-03-24",
|
|
253
|
+
group_base="A",
|
|
254
|
+
group_exp="B",
|
|
255
|
+
alpha=0.05,
|
|
256
|
+
power=0.80,
|
|
257
|
+
)
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
### 4. Display result table
|
|
263
|
+
|
|
264
|
+
```python
|
|
265
|
+
style_table_ab(
|
|
266
|
+
df_result_ab,
|
|
267
|
+
comment="Experiment description",
|
|
268
|
+
exp_start_date="2026-03-17",
|
|
269
|
+
exp_end_date="2026-03-24",
|
|
270
|
+
experiment_id=4242,
|
|
271
|
+
)
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
### 5. Export result to Excel
|
|
277
|
+
|
|
278
|
+
```python
|
|
279
|
+
excel_path = export_ab_results_to_excel(
|
|
280
|
+
df_result_ab=df_result_ab,
|
|
281
|
+
output_path="report_ab_exp_id_4242.xlsx",
|
|
282
|
+
experiment_desc="Experiment description",
|
|
283
|
+
exp_id=4242,
|
|
284
|
+
date_from="2026-03-17",
|
|
285
|
+
date_to="2026-03-24",
|
|
286
|
+
)
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
### 6. Build short message
|
|
292
|
+
|
|
293
|
+
```python
|
|
294
|
+
msg = build_ab_chat_message(
|
|
295
|
+
df_result=df_result_ab,
|
|
296
|
+
experiment_desc="Experiment description",
|
|
297
|
+
exp_id=4242,
|
|
298
|
+
date_from="2026-03-17",
|
|
299
|
+
date_to="2026-03-24",
|
|
300
|
+
dashboard_url="https://example.com/dashboard",
|
|
301
|
+
max_metrics=10,
|
|
302
|
+
show_days_more=True,
|
|
303
|
+
)
|
|
304
|
+
|
|
305
|
+
print(msg)
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
Example output:
|
|
309
|
+
|
|
310
|
+
```text
|
|
311
|
+
AB test: Experiment description
|
|
312
|
+
Experiment: 4242
|
|
313
|
+
Period: 2026-03-17 - 2026-03-24
|
|
314
|
+
|
|
315
|
+
🟢 Amount: 1.61M → 8.15M | Δ 405.0% | p=<0.0001
|
|
316
|
+
🔴 CPA: 34.21 → 171.58 | Δ 401.6% | p=<0.0001
|
|
317
|
+
⚪ CTR: 4.969% → 5.010% | Δ 0.8% | p=0.7796
|
|
318
|
+
|
|
319
|
+
Dashboard:
|
|
320
|
+
https://example.com/dashboard
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
## A/B/C analysis
|
|
326
|
+
|
|
327
|
+
For A/B/C experiments, use `run_abc_test`.
|
|
328
|
+
|
|
329
|
+
```python
|
|
330
|
+
from fast_exp_analytics import (
|
|
331
|
+
run_abc_test,
|
|
332
|
+
style_table_abc,
|
|
333
|
+
build_abc_chat_message,
|
|
334
|
+
export_abc_results_to_excel,
|
|
335
|
+
)
|
|
336
|
+
|
|
337
|
+
df_result_abc = run_abc_test(
|
|
338
|
+
df=df,
|
|
339
|
+
metrics_df=metrics_df,
|
|
340
|
+
exp_start_date="2026-03-17",
|
|
341
|
+
exp_end_date="2026-03-24",
|
|
342
|
+
include_bc=True,
|
|
343
|
+
alpha=0.05,
|
|
344
|
+
power=0.80,
|
|
345
|
+
pvalue_adjust_method="holm",
|
|
346
|
+
)
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
Prepare a styled table:
|
|
350
|
+
|
|
351
|
+
```python
|
|
352
|
+
style_table_abc(
|
|
353
|
+
df_result_abc,
|
|
354
|
+
caption="Experiment description: 2026-03-17 — 2026-03-24",
|
|
355
|
+
)
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
Generate a short summary:
|
|
359
|
+
|
|
360
|
+
```python
|
|
361
|
+
msg = build_abc_chat_message(
|
|
362
|
+
df_result=df_result_abc,
|
|
363
|
+
experiment_desc="Experiment description",
|
|
364
|
+
exp_id=4242,
|
|
365
|
+
date_from="2026-03-17",
|
|
366
|
+
date_to="2026-03-24",
|
|
367
|
+
dashboard_url="https://example.com/dashboard",
|
|
368
|
+
alpha=0.05,
|
|
369
|
+
p_adjust_method="Holm",
|
|
370
|
+
use_adjusted=True,
|
|
371
|
+
)
|
|
372
|
+
|
|
373
|
+
print(msg)
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
Export the report:
|
|
377
|
+
|
|
378
|
+
```python
|
|
379
|
+
excel_path = export_abc_results_to_excel(
|
|
380
|
+
df_result_abc=df_result_abc,
|
|
381
|
+
output_path="report_abc_id_4242.xlsx",
|
|
382
|
+
experiment_desc="Experiment description",
|
|
383
|
+
exp_id=4242,
|
|
384
|
+
date_from="2026-03-17",
|
|
385
|
+
date_to="2026-03-24",
|
|
386
|
+
)
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
---
|
|
390
|
+
|
|
391
|
+
## Experiment duration planning
|
|
392
|
+
|
|
393
|
+
The library can also help estimate experiment duration and MDE using historical data.
|
|
394
|
+
|
|
395
|
+
```python
|
|
396
|
+
from fast_exp_analytics import (
|
|
397
|
+
build_experiment_level,
|
|
398
|
+
default_duration_metrics_config,
|
|
399
|
+
mde_table_for_experiment_duration,
|
|
400
|
+
required_days_for_target_mde_table,
|
|
401
|
+
export_duration_results_to_excel,
|
|
402
|
+
)
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
### Aggregate historical data to experiment-unit level
|
|
406
|
+
|
|
407
|
+
```python
|
|
408
|
+
agg_df = build_experiment_level(
|
|
409
|
+
df_raw,
|
|
410
|
+
unit_id_col="user_id",
|
|
411
|
+
date_col="date",
|
|
412
|
+
amount_col="amount",
|
|
413
|
+
shows_col="shows",
|
|
414
|
+
clicks_col="clicks",
|
|
415
|
+
goals_col="main_goals",
|
|
416
|
+
entity_id_col="campaign_id",
|
|
417
|
+
)
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
### Calculate MDE for different durations
|
|
421
|
+
|
|
422
|
+
```python
|
|
423
|
+
metrics_duration_df = default_duration_metrics_config()
|
|
424
|
+
|
|
425
|
+
mde_by_days = mde_table_for_experiment_duration(
|
|
426
|
+
df_raw=df_raw,
|
|
427
|
+
unit_id_col="user_id",
|
|
428
|
+
rollout_pct=0.5,
|
|
429
|
+
exp_days=[7, 14, 21, 28, 35],
|
|
430
|
+
experiment_type="ab",
|
|
431
|
+
metrics_config=metrics_duration_df,
|
|
432
|
+
alpha=0.05,
|
|
433
|
+
power=0.80,
|
|
434
|
+
date_col="date",
|
|
435
|
+
amount_col="amount",
|
|
436
|
+
shows_col="shows",
|
|
437
|
+
clicks_col="clicks",
|
|
438
|
+
goals_col="main_goals",
|
|
439
|
+
entity_id_col="campaign_id",
|
|
440
|
+
)
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
### Estimate required days for target MDE
|
|
444
|
+
|
|
445
|
+
```python
|
|
446
|
+
days_for_target_mde = required_days_for_target_mde_table(
|
|
447
|
+
df_raw=df_raw,
|
|
448
|
+
unit_id_col="user_id",
|
|
449
|
+
rollout_pct=0.5,
|
|
450
|
+
target_mde_pct=[5, 7, 10],
|
|
451
|
+
experiment_type="ab",
|
|
452
|
+
metrics_config=metrics_duration_df,
|
|
453
|
+
alpha=0.05,
|
|
454
|
+
power=0.80,
|
|
455
|
+
date_col="date",
|
|
456
|
+
amount_col="amount",
|
|
457
|
+
shows_col="shows",
|
|
458
|
+
clicks_col="clicks",
|
|
459
|
+
goals_col="main_goals",
|
|
460
|
+
entity_id_col="campaign_id",
|
|
461
|
+
)
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
### Export planning result
|
|
465
|
+
|
|
466
|
+
```python
|
|
467
|
+
excel_path = export_duration_results_to_excel(
|
|
468
|
+
output_path="duration_plan_ab.xlsx",
|
|
469
|
+
mde_by_days_df=mde_by_days,
|
|
470
|
+
days_for_target_mde_df=days_for_target_mde,
|
|
471
|
+
experiment_name="Experiment name",
|
|
472
|
+
experiment_type="ab",
|
|
473
|
+
rollout_pct=50,
|
|
474
|
+
recommended_days=21,
|
|
475
|
+
comment="The estimate is based on historical data at user_id level.",
|
|
476
|
+
)
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
---
|
|
480
|
+
|
|
481
|
+
## Core functions
|
|
482
|
+
|
|
483
|
+
The main public functions are grouped by workflow
|
|
484
|
+
|
|
485
|
+
### A/B tests
|
|
486
|
+
|
|
487
|
+
| Function | Purpose |
|
|
488
|
+
|---|---|
|
|
489
|
+
| `run_ab_test` | Runs A/B test analysis |
|
|
490
|
+
| `style_table_ab` | Builds a styled result table for notebooks |
|
|
491
|
+
| `build_ab_chat_message` | Generates a short text summary |
|
|
492
|
+
| `build_dashboard_url_ab` | Builds a dashboard URL with parameters |
|
|
493
|
+
| `export_ab_results_to_excel` | Exports A/B results to Excel |
|
|
494
|
+
|
|
495
|
+
### A/B/C tests
|
|
496
|
+
|
|
497
|
+
| Function | Purpose |
|
|
498
|
+
|---|---|
|
|
499
|
+
| `run_abc_test` | Runs A/B/C or multi-group analysis |
|
|
500
|
+
| `style_table_abc` | Builds a styled result table for notebooks |
|
|
501
|
+
| `build_abc_chat_message` | Generates a short text summary |
|
|
502
|
+
| `build_dashboard_url_abc` | Builds a dashboard URL with parameters |
|
|
503
|
+
| `export_abc_results_to_excel` | Exports A/B/C results to Excel |
|
|
504
|
+
|
|
505
|
+
### Duration planning
|
|
506
|
+
|
|
507
|
+
| Function | Purpose |
|
|
508
|
+
|---|---|
|
|
509
|
+
| `build_experiment_level` | Aggregates raw historical data to experiment-unit level |
|
|
510
|
+
| `units_per_day_from_raw` | Estimates available units per day from raw data |
|
|
511
|
+
| `default_duration_metrics_config` | Returns default metrics for duration planning |
|
|
512
|
+
| `mde_table_for_experiment_duration` | Calculates MDE for different experiment durations |
|
|
513
|
+
| `required_days_for_target_mde_table` | Estimates required days for target MDE |
|
|
514
|
+
| `duration_plan_summary` | Builds a full duration planning summary |
|
|
515
|
+
| `export_duration_results_to_excel` | Exports duration planning results to Excel |
|
|
516
|
+
|
|
517
|
+
### Optional integrations
|
|
518
|
+
|
|
519
|
+
| Function / Config | Purpose |
|
|
520
|
+
|---|---|
|
|
521
|
+
| `OpenAICompatConfig` | Config for OpenAI-compatible LLM API |
|
|
522
|
+
| `build_llm_review` | Generates optional LLM review of experiment results |
|
|
523
|
+
| `ChatSendConfig` | Config for chat/message API|
|
|
524
|
+
| `send_chat_message` | Sends message and optional file to chat |
|
|
525
|
+
|
|
526
|
+
---
|
|
527
|
+
|
|
528
|
+
## Supported metric types
|
|
529
|
+
|
|
530
|
+
| Type | Description | Examples |
|
|
531
|
+
|---|---|---|
|
|
532
|
+
| `additive` | Sum-based metrics. | revenue, amount, clicks, shows, goals |
|
|
533
|
+
| `average` | Average value per unit. | average amount per user, campaign days |
|
|
534
|
+
| `ratio` | Numerator divided by denominator. | CTR, CPC, CPA, CPM |
|
|
535
|
+
| `share` | Share/conversion metrics. | conversion to action, payer share |
|
|
536
|
+
|
|
537
|
+
---
|
|
538
|
+
|
|
539
|
+
## Project structure
|
|
540
|
+
|
|
541
|
+
```text
|
|
542
|
+
fast_exp_analytics/
|
|
543
|
+
├── fast_exp_analytics/
|
|
544
|
+
├── examples/
|
|
545
|
+
├── tests/
|
|
546
|
+
├── README.md
|
|
547
|
+
├── CHANGELOG.md
|
|
548
|
+
├── pyproject.toml
|
|
549
|
+
├── MANIFEST.in
|
|
550
|
+
└── Makefile
|
|
551
|
+
```
|
|
552
|
+
|
|
553
|
+
---
|
|
554
|
+
|
|
555
|
+
## License
|
|
556
|
+
|
|
557
|
+
MIT © 2026 Alexey Voronko
|