Skip to main content

Pythonic AB Experiment Framework

Project description

Framework to define and run AB tests within a python ecosystempy

Documentation Status PyPi Version

Installation

pip install py-ab-experiment to install the library

Usage

You first need a suitable configuration to set up an experiment. You can use one of the sample files provided in src/tests/unit/test_programs, or create your own using the configuration file format (see the documentation for details)

using the splitter_test.pyab definition, which is defined as

def basic_experiment_1{
        //some splitter fields
        splitters: my_id
        if field_1 == 'a'{
                return "Setting 1" weighted 4, "Setting 2" weighted 1
        }
        else{
                return "Setting 1" weighted 1, "Setting 2" weighted 1
        }
}

Dynamic compilation

You can then load an experiment in python by

from pyab_experiment.experiment_evaluator import ExperimentEvaluator
with open(file_name, "r") as fp:
    evaluator = ExperimentEvaluator(fp.read()) # load and compile the experiment code

Experiment execution

Then we run experiments by calling the experiment object with the fields needed

experiment_group = evaluator(my_id=123,field1='a')

The experiment group will return a "cohort" based on the 2 values defined in the configuration file. To Illustrate using the sample configuration defined above, when we repeatedly call experiment with field1='a' we will get on average 'Setting 1' about 80% of the times (as long as my_id is uniformly distributed). If field1 is anything other than 'a' we will get on average a 50/50 split between 'Setting 1' and 'Setting 2'

The determinism comes from the fact that the same my_id will always result in the same group assignment, (in our example, given the same field_1 value)

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

py_ab_experiment-0.3.2.tar.gz (90.5 kB view details)

Uploaded Source

Built Distribution

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

py_ab_experiment-0.3.2-py3-none-any.whl (59.6 kB view details)

Uploaded Python 3

File details

Details for the file py_ab_experiment-0.3.2.tar.gz.

File metadata

  • Download URL: py_ab_experiment-0.3.2.tar.gz
  • Upload date:
  • Size: 90.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.9

File hashes

Hashes for py_ab_experiment-0.3.2.tar.gz
Algorithm Hash digest
SHA256 fc67b8c66c43303d4ca7d5d93bdbcb4af8d6ff24dc7f11f000c8cf68765f64ec
MD5 e9d3c7dbd5d41d163d80e186cece4fb0
BLAKE2b-256 06c0adb43620c0be2e694bb6c0baa811247038c2a4292278ebb41e56fe3dfab5

See more details on using hashes here.

File details

Details for the file py_ab_experiment-0.3.2-py3-none-any.whl.

File metadata

File hashes

Hashes for py_ab_experiment-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 11f72e1454a7ed8fa49986ee8df3a2aa980f33aec25dde7c0d3803e025ea7c47
MD5 4243cb7b752333d6db7d035b0d3d81f2
BLAKE2b-256 1798f9bb3289c6127e7370bcbc56783bd756f99249eb88e5369c70adf31fa52c

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