Experiment Management
Classes for orchestrating and managing AB test experiments.
AbobaExperiment
AbobaExperiment
Context for conducting and displaying AB tests results.
Results are displayed on a figure with confidence levels. By specifying number of columns, you can generate nice comparisons
Examples:
# First create tests
value_column = 'value'
size = 100
splitter = splitters.GroupSplitter(
column='b_group',
size=size,
)
cuped_preprocess = processing.CupedProcessor(...)
test_cuped = tests.AbsoluteIndependentTTest(
preprocess=cuped_preprocess,
data_splitter=splitter,
value_column=value_column,
)
test_regular = tests.AbsoluteIndependentTTest(
preprocess=None,
data_splitter=splitter,
value_column=value_column,
)
# Next create an experiment with relevant name.
# You can also generate several columns
experiment = AbobaExperiment(experiment_name="CUPED vs regular", draw_cols=2)
regular_aa_group = experiment.group("AA, regular")
regular_aa_group.run(test_regular, n_iter=n_iter)
regular_ab_group = experiment.group("AB, regular")
regular_ab_group.run(test_regular, synthetic_effect=effect, n_iter=n_iter)
cuped_aa_group = experiment.group("AA, cuped")
cuped_aa_group.run(test_cuped, n_iter=n_iter)
cuped_ab_group = experiment.group("AB, cuped")
cuped_ab_group.run(test_cuped, synthetic_effect=effect, n_iter=n_iter)
# Get results from each group
ab_results = cuped_ab_group.get_data()
Source code in aboba/experiment/aboba_experiment.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 | |
__init__
__init__(alpha=0.05, experiment_name: Optional[str] = 'AB experiment', visualization_method: Optional[Callable[[Dict[str, ExperimentData], Dict[str, Any]], tuple[Figure, Any]]] = default_visualization_method, language: Language = 'eng', **visualization_kwargs)
Create a new experiment. Refer to the class description for more information.
| PARAMETER | DESCRIPTION |
|---|---|
alpha
|
Significance level for statistical tests.
TYPE:
|
experiment_name
|
Name of the experiment to display.
TYPE:
|
visualization_method
|
Visualization function used to draw experiment results.
TYPE:
|
language
|
Default language for plot labels and titles.
TYPE:
|
**visualization_kwargs
|
Additional arguments for the visualization.
DEFAULT:
|
Source code in aboba/experiment/aboba_experiment.py
group
group(name: str, test: BaseTest, data: Union[DataFrame, List[DataFrame]], data_pipeline: Pipeline, synthetic_effect: Optional[EffectModifier] = None, n_iter: int = 1, joblib_kwargs: Optional[dict] = None) -> ExperimentGroup
Creates new context for experiment with specified name.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
Name to use for this experiment subset.
TYPE:
|
test
|
Statistical test to run.
TYPE:
|
data
|
Input data for the experiment.
TYPE:
|
data_pipeline
|
Pipeline used to prepare data before testing.
TYPE:
|
synthetic_effect
|
Synthetic effect applied before test execution.
TYPE:
|
n_iter
|
Number of repeated test runs.
TYPE:
|
joblib_kwargs
|
Additional keyword arguments for parallel execution.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ExperimentGroup
|
Registered experiment group.
TYPE:
|
Source code in aboba/experiment/aboba_experiment.py
draw
draw(groups: Optional[List[str]] = None, group_configs: Optional[Dict[str, GroupVisualizationConfig]] = None, lang: Language = None, figsize: Optional[Tuple[float, float]] = None, filter_empty: bool = True, **kwargs) -> Tuple[Optional[Figure], Any]
Draw visualization in the fixed 3-panel AA layout
- Top: confidence interval for alpha
- Bottom-left: p-value histogram
- Bottom-right: ECDF of p-values
This is the only supported layout now.
| PARAMETER | DESCRIPTION |
|---|---|
groups
|
List of group names to visualize (None = all groups)
TYPE:
|
group_configs
|
Per-group configuration (e.g., color)
TYPE:
|
lang
|
Language for labels ('en' or 'ru')
TYPE:
|
figsize
|
Custom figure size
TYPE:
|
filter_empty
|
Skip empty groups
TYPE:
|
**kwargs
|
Passed to draw_aa_experiment_layout
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
Tuple[Optional[Figure], Any]
|
Tuple of (Figure, axes_array) where axes_array[i] = [ax_interval, ax_hist, ax_ecdf] |
Source code in aboba/experiment/aboba_experiment.py
draw_comparison
draw_comparison(group_pairs: List[Tuple[str, str]], separate_pairs: bool = False, **kwargs) -> Tuple[Optional[Figure], Any]
Draw side-by-side comparison of group pairs.
| PARAMETER | DESCRIPTION |
|---|---|
group_pairs
|
List of (group1, group2) tuples
TYPE:
|
separate_pairs
|
If True, groups are arranged in pairs (g1, g2, g1, g2, ...) If False, duplicates are removed
TYPE:
|
**kwargs
|
Additional draw arguments
DEFAULT:
|
Source code in aboba/experiment/aboba_experiment.py
quick_summary
Get DataFrame with summary statistics for all groups.
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
DataFrame with columns: group_name, n_iterations, n_errors, |
DataFrame
|
real_alpha, ci_left, ci_right, rejection_rate |
Example
summary = experiment.quick_summary() print(summary.sort_values('real_alpha'))
Source code in aboba/experiment/aboba_experiment.py
draw_power_curve
draw_power_curve(effect_grid: Optional[List[float]] = None, effect_type: Literal['absolute', 'relative'] = 'absolute', n_iter: int = 500, target_power: float = 0.8, groups: Optional[List[str]] = None, group_configs: Optional[Dict[str, GroupVisualizationConfig]] = None, group_col: str = None, lang: Language = None, figsize: Tuple[float, float] = (9, 6), alpha_line_on: bool = True, **kwargs) -> Tuple[plt.Figure, plt.Axes]
Draw power curves: statistical power vs effect size for one or more groups using simulation.
Uses the specified groups' test, pipeline, and data as templates.
For each group, it runs n_iter simulations for each effect size in effect_grid
and estimates the proportion of rejections (power) with confidence intervals.
Curves are plotted on the same axes for comparison.
Parameters
effect_grid : List[float], optional
Grid of effect values used to simulate power.
Interpretation depends on effect_type:
- "absolute": additive effect applied to test group values (value + effect);
- "relative": multiplicative effect applied to test group values as (value * (1 + effect)).
For ratio tests (e.g. DeltaRatioTtest), the effect is applied to the numerator column only.
If None:
- for "absolute": defaults to np.linspace(0.0, 0.6, 20)
- for "relative": defaults to np.linspace(0.0, 0.6, 20)
effect_type : Literal["absolute", "relative"], default "absolute"
Type of effect application for the test group:
- "absolute": additive shift;
- "relative": relative change via factor 1 + effect.
n_iter : int, default 500
Number of simulations per effect size per group (trade-off: speed vs precision).
target_power : float, default 0.8
Horizontal line indicating desired power level.
groups : List[str], optional
Names of groups to include in the power analysis. If None, defaults to all groups.
group_configs : Dict[str, GroupVisualizationConfig], optional
Per-group configuration for styling (e.g., color, linestyle).
Falls back to default if not provided for a group.
lang : str, default "en"
Language for labels ('en' or 'ru').
figsize: Tuple[float, float], default (9, 6)
Figure size.
alpha_line_on : bool, default True
Whether to draw the horizontal line for the significance level (alpha).
**kwargs : dict
Passed to simulate_power_for_effect.
Returns
fig : matplotlib.figure.Figure ax : matplotlib.axes.Axes
Source code in aboba/experiment/aboba_experiment.py
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 | |
ExperimentGroup
ExperimentGroup
Manages experiment subset.
Handles running tests multiple times, applying synthetic effects, and collecting results from the pipeline and test.
Source code in aboba/experiment/experiment_group.py
run
Run test multiple times in parallel and store results in currently activated experiment group.
| RETURNS | DESCRIPTION |
|---|---|
self
|
For method chaining |