AB Test Framework for Python
Project description
pyabtesting
An awesome README template to jumpstart your projects!
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
Table of Contents
About The Project
This library provides tools for AB Testing, very useful when working with marketing data
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
-
git clone https://github.com/pablominue/pyabtesting.git
or
pip install abtestools
-
Import main modules
from abtestools import audience, test
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
Release history Release notifications | RSS feed
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.4.tar.gz
(24.6 kB
view details)
Built Distribution
File details
Details for the file abtestools-1.1.4.tar.gz
.
File metadata
- Download URL: abtestools-1.1.4.tar.gz
- Upload date:
- Size: 24.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.0 CPython/3.11.5 Darwin/24.0.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8493b98e8b5f59ddddc3014677cff0e2e0fe0f3eafd9b14ef15d77ffa509fe55 |
|
MD5 | 210e6547042bad0f17f1a5a7739143a8 |
|
BLAKE2b-256 | a9ca8fdcf4af8185c47b59c516671ba82ecbbe9d6225e5686fc544a64d825d75 |
File details
Details for the file abtestools-1.1.4-py3-none-any.whl
.
File metadata
- Download URL: abtestools-1.1.4-py3-none-any.whl
- Upload date:
- Size: 24.1 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | a703d42a29876331651bef3bf53874ffa04a7a93b3f10681b63adddcb8b244fd |
|
MD5 | b3a905295f49f4f0e5f597c8a386f279 |
|
BLAKE2b-256 | 03030a869e320f334bc9c33b01d92508f3dba4940f9f89055681093c52cf0342 |