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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: abtestools-1.1.2.tar.gz
  • Upload date:
  • Size: 24.4 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.2.tar.gz
Algorithm Hash digest
SHA256 ebef41741fb6a23efae956cec6ac41bca652eefad5e27c38c368b358115705f2
MD5 ec4da7301f600fbabdaea14a2617eab1
BLAKE2b-256 7b8e6f946f34a82c376f08ff727ba1985191f10f19fba6d31c8af0e627b72838

See more details on using hashes here.

File details

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

File metadata

  • Download URL: abtestools-1.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 75dc02df655e0f273644a4bfb776a4d1134a47f90c9953924f36af33aa8ab822
MD5 8c543c18c129cb2d98da3c47782fd9aa
BLAKE2b-256 8440a3f009a43d3f7bc67d6b5d129728d355738c299f1b80859ec91443b1b5c6

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