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 Package Status Version PyPI Python Versions

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

  • Welch's and Student's t-tests, z-test, proportion tests, bootstrap, quantile, and other 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.
  • Pretty representation of analysis results: rounding to significant digits, rendering in terminals, Jupyter/IPython, and marimo notebooks, serialization to Markdown, and conversion to pandas and Polars DataFrames.

tea-tasting calculates statistics directly within data backends such as BigQuery, ClickHouse, PostgreSQL, Snowflake, Trino, 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, Daft, Dask, DuckDB, Modin, pandas, Polars, PyArrow, PySpark.

Installation

Install with uv:

uv add tea-tasting

Or with pip:

pip install tea-tasting

To use Ibis data backends, install Ibis with the extra for your backend, such as:

uv add 'ibis-framework[duckdb]'

Basic example

>>> import tea_tasting as tt

>>> data = tt.make_users_data(rng=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 local environment, or you can run them as WASM notebooks in the online playground.

Run in a local environment

To run the examples in your local environment, clone the repository and change to the project directory:

git clone https://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]'

Launch the notebook server:

uv run marimo edit examples

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:

  • Tables and dataframes render less attractively because Pyodide doesn't always include the latest package versions.
  • You can't simulate experiments in parallel because Pyodide currently doesn't support multiprocessing.
  • Other unpredictable issues may arise, such as the inability to use duckdb with ibis.

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-2.0.0.tar.gz (64.1 kB view details)

Uploaded Source

Built Distribution

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

tea_tasting-2.0.0-py3-none-any.whl (51.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tea_tasting-2.0.0.tar.gz
  • Upload date:
  • Size: 64.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for tea_tasting-2.0.0.tar.gz
Algorithm Hash digest
SHA256 ff43538d217b38ff0cc9b929f503839ce65458574d945adea4470590f727f706
MD5 6a98de0693bc1c0047f31803fa94b88c
BLAKE2b-256 8905d64de596715b0453bf69ef0ec25f7a35d1814d2011aa692278fafea86267

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tea_tasting-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 51.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for tea_tasting-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 29d237501b0e8c21502f2d5e2145cb1931fd9841d4c9d1644bfa761df6005489
MD5 d7b2911033337ab1bb7c4a7a1121548b
BLAKE2b-256 e4f13ad13615676d05d12352055f29bfda527dd28be13d167be6fd944b147a9a

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