Skip to main content
Yanked

This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.
Reason given by maintainers: Renamed to abtestwise to avoid conflict with an existing XPKit product.

xpkit

A lightweight Python toolkit for binary A/B experiment analysis using aggregate count data. Version 0.1 combines frequentist and Bayesian summaries for binary proportions.

Install

Install from PyPI:

pip install xpkit

Development install

To work on the package locally (with the test dependencies):

pip install -e ".[dev]"

Quickstart

from xpkit import BinaryABTest

test = BinaryABTest.from_counts(
    control_successes=120,
    control_total=1000,
    treatment_successes=145,
    treatment_total=1000,
    prior_alpha=1,
    prior_beta=1,
    n_simulations=100_000,
    credible_interval=0.95,
    seed=42,
)

result = test.run()

print(result.summary())
print(result.prob_lift_above(0.01))

prob_lift_above(0.01) gives the posterior probability that Treatment B improves the metric by more than 1 percentage point.

Do-no-harm checks

prob_no_harm(margin) gives the posterior probability that Treatment B is not worse than Control A by more than margin (in raw decimal units, so 0.005 means 0.5 percentage points). prob_harm_above(margin) is its complement.

result.prob_no_harm(0.005)     # P(lift >= -0.005): B is not worse by more than 0.5pp
result.prob_harm_above(0.005)  # P(lift <  -0.005): B is worse by more than 0.5pp

Raw result values are also available:

result.to_dict()

Plotting

import matplotlib.pyplot as plt

result.plot_lift_distribution()
result.plot_probability_bar()

plt.show()

The lift distribution plot shows posterior lift in percentage points.

The probability bar plot shows:

P(Treatment B > Control A)
P(Control A > Treatment B)

Groups and sign convention

In product A/B testing terms:

  • Control (A) is the baseline group.
  • Treatment (B) is the test group or variant B.
  • Lift is always Treatment B - Control A.
  • Positive lift means Treatment B is better than Control A.
  • Negative lift means Control A is better than Treatment B.

Scope (v0.1)

  • Binary proportions only.
  • Aggregate counts only.
  • Two groups only.
  • Frequentist: two-sided pooled two-proportion z-test.
  • Bayesian: beta-binomial posterior simulation with default prior Beta(1, 1).
  • Equal-tailed credible interval.
  • Expected loss.
  • Practical lift thresholds.
  • Simple plots.

Development

Run tests with:

python -m pytest -q

Metadata

Release files for xpkit 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xpkit 0.1.1
File Size Uploaded
xpkit-0.1.1.tar.gz 36.1 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for xpkit 0.1.1
File Interpreter ABI Platform
xpkit-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 36.1 MB

Release files / xpkit-0.1.1.tar.gz

Download URL xpkit-0.1.1.tar.gz
Size 36.1 MB
Tags Source
SHA-256 checksum
How to use checksums
1bc7d3ebd4230aef24ac05f788b0f719aa21e564681ed07b95800b175d168160
BLAKE2b-256 checksum
How to use checksums
6a377135749259900e1ef57a5a9408aeed8f07d32e20fc87083e62650f21a514
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.3

Release files / xpkit-0.1.1-py3-none-any.whl

Download URL xpkit-0.1.1-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2e70791fd0a1a2c0a7875efe591b0a374c1dc788943b36f8449fc34746011197
BLAKE2b-256 checksum
How to use checksums
7131c47b7d7b0f28e11bd34498e7a9102c83edb483dec8e564716da1abc89fd0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.3

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page