Skip to main content

Lightweight toolkit for binary A/B experiment analysis using aggregate counts.

Reason this release was yanked:

Renamed to abtestwise to avoid conflict with an existing XPKit product.

Project description

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 (development)

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.

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xpkit-0.1.0.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xpkit-0.1.0-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file xpkit-0.1.0.tar.gz.

File metadata

  • Download URL: xpkit-0.1.0.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for xpkit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1938e0dd10ad8f075a16cbc3b2f5a80940329402a8db87d162c06aa24092620e
MD5 37fe7356c4f8b63c3facd4bc3f5e0867
BLAKE2b-256 87090066dfb5ef110142da1df64b203ab76547ddb585b674bf978b60d33bdadd

See more details on using hashes here.

File details

Details for the file xpkit-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: xpkit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for xpkit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 91feb05ee3790f4082b7a8ffcd9bd213cac19cf218de61689d406fac2f6b9ff1
MD5 b457c0714ad19c084b97f1545a31c19a
BLAKE2b-256 9e43782328f48c7eac0ac04524fcad4144627468bec4a87715dc893432af40f5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page