Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

abtestools

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abtestools

AB Test Framework for Python

  • 1.1.4
  • PyPI
  • Socket score

Maintainers
1

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)

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc