Orchestrator
orchestrator
Experiment analysis orchestrator, results compiler, and setup entrypoints.
This module provides the central user-facing API for launching analyses on experimental datasets.
It coordinates the execution of registered metrics, handles multiple testing corrections, manages state
transitions, and constructs the unified AnalysisResult data layer for plotting and reporting.
| CLASS | DESCRIPTION |
|---|---|
AnalysisResult |
Holds results from an experiment analysis and provides summary formatting and plotting interfaces. |
| FUNCTION | DESCRIPTION |
|---|---|
run_analysis |
Executes the statistical analysis across all registered metrics in an Experiment container. |
setup |
Initializes the experimental setup container, serving as the library's primary entrypoint. |
AnalysisResult
AnalysisResult(
raw_results: List[dict],
alpha: float = 0.05,
balance_checker: Optional[Any] = None,
)
Holds results from an experiment analysis and provides summary formatting and plotting interfaces.
This container aggregates the individual metric dictionaries calculated across control and treatment groups. It provides high-level APIs to compile clean summary tables and forward coordinates to the visualization engine.
| ATTRIBUTE | DESCRIPTION |
|---|---|
raw_results |
A list of metric calculation result dictionaries (keys: mean, lift, p_value, etc.).
TYPE:
|
alpha |
Nominal significance level (Type I error rate) used in the analysis. Defaults to 0.05.
TYPE:
|
df_raw |
The raw, unformatted results compiled into a pandas DataFrame.
TYPE:
|
balance_checker |
Fitted balance checker object if covariates were present.
TYPE:
|
| PARAMETER | DESCRIPTION |
|---|---|
raw_results
|
Raw list of metric results.
TYPE:
|
alpha
|
Nominal significance level used.
TYPE:
|
balance_checker
|
Fitted CovariateBalanceChecker if covariates were specified.
TYPE:
|
| METHOD | DESCRIPTION |
|---|---|
love_plot |
Returns the ASCII Love Plot visualization for baseline covariate balance. |
to_dict |
Converts the complete analysis results and metadata to a robust, serializable dictionary. |
to_json |
Converts the analysis results into a standardized, portable JSON string. |
summary |
Returns a summarized, human-readable DataFrame of the analysis. |
plot |
Generates and returns a forest plot of the relative metric lifts and confidence intervals. |
Source code in src\xpyrment\analyze\orchestrator.py
love_plot
Returns the ASCII Love Plot visualization for baseline covariate balance.
| RETURNS | DESCRIPTION |
|---|---|
str
|
An ASCII text-based representation or message.
TYPE:
|
Source code in src\xpyrment\analyze\orchestrator.py
to_dict
Converts the complete analysis results and metadata to a robust, serializable dictionary.
Includes significance thresholds (alpha), raw metric outcomes, and covariate balance diagnostics if present.
| RETURNS | DESCRIPTION |
|---|---|
dict
|
A nested dictionary with native Python types, guaranteed to be JSON serializable.
TYPE:
|
Source code in src\xpyrment\analyze\orchestrator.py
to_json
Converts the analysis results into a standardized, portable JSON string.
| PARAMETER | DESCRIPTION |
|---|---|
indent
|
If provided, formats the JSON string with this indentation level.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
Standardized JSON representation of the analysis results.
TYPE:
|
Source code in src\xpyrment\analyze\orchestrator.py
summary
Returns a summarized, human-readable DataFrame of the analysis.
Formats raw numeric statistics (standard errors, differences, variances) into readable percentage lifts, relative confidence intervals, power indicators, and significance star symbols.
Significance Star Mapping
***: \(p < 0.001\) (Highly significant)**: \(p < 0.01\) (Significant)*: \(p < 0.05\) (Significant)- No star : \(p \ge 0.05\) (Not statistically significant at the nominal level \(\alpha=0.05\))
| PARAMETER | DESCRIPTION |
|---|---|
formatted
|
If True, returns nicely formatted strings for display (with percentage symbols, stars, and bracketed intervals). If False, returns the raw numeric values. Defaults to True.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
pd.DataFrame: A pandas DataFrame containing binned summaries of each analyzed metric. |
Source code in src\xpyrment\analyze\orchestrator.py
plot
Generates and returns a forest plot of the relative metric lifts and confidence intervals.
Forwards coordinates to the visualization module.
| PARAMETER | DESCRIPTION |
|---|---|
**kwargs
|
Plot customization arguments forwarded to
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Any
|
matplotlib.axes.Axes or plotly.graph_objects.Figure: The generated relative lift forest plot. |
Source code in src\xpyrment\analyze\orchestrator.py
run_analysis
run_analysis(
experiment: Experiment,
control: str = "control",
treatment: str = "treatment",
alpha: float = 0.05,
multi_test_correction: Optional[str] = None,
covariates: Optional[List[str]] = None,
) -> AnalysisResult
Executes the statistical analysis across all registered metrics in an Experiment container.
Iterates over each registered metric in the experiment, calculates means, relative lifts, p-values,
confidence intervals, and power. If requested, applies multiple testing corrections across the p-values,
updates the experiment state to ANALYZED, and returns a structured AnalysisResult.
| PARAMETER | DESCRIPTION |
|---|---|
experiment
|
The initialized, pre-registered experiment setup container.
TYPE:
|
control
|
The label of the control variant in the treatment column. Defaults to
TYPE:
|
treatment
|
The label of the treatment variant in the treatment column. Defaults to
TYPE:
|
alpha
|
Significance level (Type I error probability) for confidence intervals. Defaults to 0.05.
TYPE:
|
multi_test_correction
|
Multiple testing correction algorithm to apply across the
registered metrics. Options:
TYPE:
|
covariates
|
List of covariates to check balance and adjust.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
AnalysisResult
|
A rich, summarized results container.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If no metrics have been registered, or if control/treatment labels are missing from the active dataset. |
PhaseOrderError
|
If the experiment is in an invalid state for running analysis. |
Source code in src\xpyrment\analyze\orchestrator.py
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 | |
setup
setup(
data: DataFrame,
treatment_col: str,
id_col: Optional[str] = None,
covariates: Optional[List[str]] = None,
) -> Experiment
Initializes the experimental setup container, serving as the library's primary entrypoint.
Sets up the Experiment object with the target dataset, identifying variant and unit columns,
and locks the state machine to ExperimentState.DESIGNED.
| PARAMETER | DESCRIPTION |
|---|---|
data
|
The main experiment dataset containing exposure logs and outcomes.
TYPE:
|
treatment_col
|
Column name containing variant strings (e.g.,
TYPE:
|
id_col
|
Column name containing unique unit identifiers (e.g.,
TYPE:
|
covariates
|
Optional list of baseline covariates.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Experiment
|
A state-gated
TYPE:
|