Skip to main content

AB Test Framework for Python

Project description

Contributors Forks Stargazers Issues MIT License LinkedIn


Logo

pyabtesting

An awesome README template to jumpstart your projects!
Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage

About The Project

This library provides tools for AB Testing, very useful when working with marketing data

(back to top)

Getting Started

Prerequisites

To develop on this project, you will need to create a poetry environment with the needed dependencies

  • install with Poetry
    poetry install
    

Installation

  1. git clone https://github.com/pablominue/pyabtesting.git
    

    or

    pip install abtestools
    
  2. Import main modules

    from abtestools import audience, test
    

(back to top)

Usage

import datetime

import pandas as pd

from abtestools.audiences import Audience
from abtestools.campaign import Campaign
from abtestools.test import Metric

data = pd.read_csv("tests/cookie_cats.txt", delimiter=",")

audience = Audience(
    users=data["userid"], group_mapping=dict(zip(data["userid"], data["version"]))
)

campaign = Campaign(
    audience=audience,
    metrics=[
        Metric(name="retention_1", type="discrete"),
        Metric(name="retention_7", type="discrete"),
    ],
    date_range=[
        datetime.datetime.today() - datetime.timedelta(days=x) for x in range(10)
    ],
)


def extract_data(date, metric_column: str, convert_bool: bool = True) -> dict:
    # Logic for each date calculation should be added here
    if convert_bool:
        data[metric_column] = data[metric_column].astype(int)
    return dict(zip(data["userid"], data[metric_column]))


for res in campaign.backfill(
    metric=Metric(name="retention_1", type="discrete"),
    extract_data=extract_data,
    metric_column="retention_1",
):
    print(res)

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

abtestools-1.1.1.tar.gz (24.3 kB view details)

Uploaded Source

Built Distribution

abtestools-1.1.1-py3-none-any.whl (23.9 kB view details)

Uploaded Python 3

File details

Details for the file abtestools-1.1.1.tar.gz.

File metadata

  • Download URL: abtestools-1.1.1.tar.gz
  • Upload date:
  • Size: 24.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.0 CPython/3.11.5 Darwin/24.0.0

File hashes

Hashes for abtestools-1.1.1.tar.gz
Algorithm Hash digest
SHA256 977237382eb82be56153c9cd50e29e16b0ab55018e464dd93c44d05120986acf
MD5 d09156090355f2bf3b725845d9c736d3
BLAKE2b-256 3122fa67cdb3fb6216c084e7b1508a1713d20a0b6ad5d99c2e11df4c8945a721

See more details on using hashes here.

File details

Details for the file abtestools-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: abtestools-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 23.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.0 CPython/3.11.5 Darwin/24.0.0

File hashes

Hashes for abtestools-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7b29c74382ea91aa7dd09272b379002c2c16c962d7e12053c21fc0cb43451ecd
MD5 071ec62a152fd2ff1aec9d76441da919
BLAKE2b-256 3b9e1658d25d0e044a0ad45ccbde623d9b97cba3a84ad001c01eb617abe22f33

See more details on using hashes here.

Supported by

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