Skip to main content

A Python package for the statistical analysis of A/B tests.

Project description

tea-tasting: statistical analysis of A/B tests

CI Docs Coverage License Version Package Status PyPI Python Versions

tea-tasting is a Python package for the statistical analysis of A/B tests featuring:

  • Student's t-test, Z-test, bootstrap, and quantile metrics out of the box.
  • Extensible API that lets you define and use statistical tests of your choice.
  • Delta method for ratio metrics.
  • Variance reduction using CUPED/CUPAC, which can be combined with the Delta method for ratio metrics.
  • Confidence intervals for both absolute and percentage changes.
  • Checks for sample-ratio mismatches.
  • Power analysis.
  • Multiple hypothesis testing (family-wise error rate and false discovery rate).
  • Simulated experiments, including A/A tests.

tea-tasting calculates statistics directly within data backends such as BigQuery, ClickHouse, DuckDB, PostgreSQL, Snowflake, Spark, and many other backends supported by Ibis. This approach eliminates the need to import granular data into a Python environment.

tea-tasting also accepts dataframes supported by Narwhals: cuDF, Dask, Modin, pandas, Polars, PyArrow.

Installation

uv pip install tea-tasting

Basic example

>>> import tea_tasting as tt

>>> data = tt.make_users_data(seed=42)
>>> experiment = tt.Experiment(
...     sessions_per_user=tt.Mean("sessions"),
...     orders_per_session=tt.RatioOfMeans("orders", "sessions"),
...     orders_per_user=tt.Mean("orders"),
...     revenue_per_user=tt.Mean("revenue"),
... )
>>> result = experiment.analyze(data)
>>> result
            metric control treatment rel_effect_size rel_effect_size_ci pvalue
 sessions_per_user    2.00      1.98          -0.66%      [-3.7%, 2.5%]  0.674
orders_per_session   0.266     0.289            8.8%      [-0.89%, 19%] 0.0762
   orders_per_user   0.530     0.573            8.0%       [-2.0%, 19%]  0.118
  revenue_per_user    5.24      5.73            9.3%       [-2.4%, 22%]  0.123

Learn more in the detailed user guide. Additionally, see the guides on more specific topics:

Examples

The tea-tasting repository includes examples as copies of the guides in the marimo notebook format. You can either download them from GitHub and run in your marimo environment, or you can run them as WASM notebooks in the online playground.

Run in a local marimo environment

To run the examples in your marimo environment, clone the repository and change the directory:

git clone git@github.com:e10v/tea-tasting.git && cd tea-tasting

Install marimo, tea-tasting, and other packages used in the examples:

uv venv && uv pip install marimo tea-tasting polars ibis-framework[duckdb] tqdm

Launch the notebook server:

uv run marimo edit examples

Copy the URL from the console and open it in your browser. Now you can choose and run the example notebooks.

Run in the online playground

To run the examples as WASM notebooks in the online playground, open the following links:

WASM notebooks run entirely in the browser on Pyodide and thus have some limitations. In particular:

Package name

The package name "tea-tasting" is a play on words that refers to two subjects:

  • Lady tasting tea is a famous experiment which was devised by Ronald Fisher. In this experiment, Fisher developed the null hypothesis significance testing framework to analyze a lady's claim that she could discern whether the tea or the milk was added first to the cup.
  • "tea-tasting" phonetically resembles "t-testing", referencing Student's t-test, a statistical method developed by William Gosset.

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

tea_tasting-1.1.0.tar.gz (52.5 kB view details)

Uploaded Source

Built Distribution

tea_tasting-1.1.0-py3-none-any.whl (43.0 kB view details)

Uploaded Python 3

File details

Details for the file tea_tasting-1.1.0.tar.gz.

File metadata

  • Download URL: tea_tasting-1.1.0.tar.gz
  • Upload date:
  • Size: 52.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.7.2

File hashes

Hashes for tea_tasting-1.1.0.tar.gz
Algorithm Hash digest
SHA256 90e0ba5c13a1041186f9f3fb350123bb6379f6d0c623ea283f90dee244a042b1
MD5 090dbc0435602ac97ac27ab0746b5eb7
BLAKE2b-256 d666da99009a9dd2db62eeca56fd2c1e693731d160f913b9618f9511f32d81df

See more details on using hashes here.

File details

Details for the file tea_tasting-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for tea_tasting-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dc5838ca05d69644b0be905aab382a547517e06d673432c5d170152a2ec75454
MD5 5744a249fcb0520b521364dd8c10d969
BLAKE2b-256 05302f8afc05acc42bb93809b283ebca1d4a009f98c614fc0ef62f63e57bff3d

See more details on using hashes here.

Supported by

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