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.3.tar.gz
(24.4 kB
view details)
Built Distribution
File details
Details for the file abtestools-1.1.3.tar.gz
.
File metadata
- Download URL: abtestools-1.1.3.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac4ccc241cdc93ee48c1ed9a4ef21697ac7b639a7182266cdcb18404104a6fc6 |
|
MD5 | 90b0895b900e48a929058c8e380f01a6 |
|
BLAKE2b-256 | 01107db2fe87f9ede5188982b8d6fa275cc54ce803a83a8400725d47885329c7 |
File details
Details for the file abtestools-1.1.3-py3-none-any.whl
.
File metadata
- Download URL: abtestools-1.1.3-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d08e7683b855d256d9323e59762934792b3139776236a6d32ab59a208265dca |
|
MD5 | f5c245d91959a56dd92f5272721a720a |
|
BLAKE2b-256 | 42ceceed3381b3233a53a8f5c6e7745d9d69158da906e1b90c28d7abd0d0d3bf |