Skip to main content

An A/B-testing package

Project description

ABetter

简介

ABetter 是一个在 Jupyter Notebook 中计算 A/B-Testing 效果的简单易用的 Python 工具包,其基于样本统计结果而非样本明细,因此无需导入样本,很适合用于大规模样本实验。

主要功能:

  1. 自适应选择检验方法;
  2. 输出检验表:显著性, 置信区间,MDE,Effect Size,增量效果;
  3. 绘制示意图。

安装

源代码托管在 GitHub,地址: https://github.com/SqRoots/ABetter

您可以使用 pip 命令安装 ABetter。

# PyPI
pip install abetter

使用

检验均值型指标:

import abetter as ab

# 定义均值型指标样本(其中样本量n、样本均值mean、样本标准差std,是3个必要参数,其他为可选参数)
s1 = ab.SampleMean(n=1000000, mean=0.5000, std=0.2000, field_name='订单量', group_name='实验组', group_ratio=0.1)
s2 = ab.SampleMean(n=2000000, mean=0.5005, std=0.2010, field_name='订单量', group_name='空白组', group_ratio=0.2)

# 检验
ss = s1 - s2
ss   # Pandas数据框存储于 ss.data_all
image-20250621105540539

检验比率型指标:

import abetter as ab

# 定义比率型指标样本(其中样本量n、阳性样本量k,是2个必要参数,其他为可选参数)
s1 = ab.SampleProp(n=10000, k=60, field_name='交易人数', group_name='实验组', group_ratio=0.1)
s2 = ab.SampleProp(n=20000, k=50, field_name='交易人数', group_name='空白组', group_ratio=0.2)

# 检验
ss = s1 - s2
ss   # Pandas数据框存储于 ss.data_all
image-20250621105640703

绘制两个样本均值的分布:

import abetter as ab

# 定义均值型指标样本(前3个参数依次是:样本量n、样本均值mean、样本标准差std)
s1 = ab.SampleMean(1000, 0.50, 0.20)
s2 = ab.SampleMean(200, 0.55, 0.21)

# 绘图
fig, ax = ab.plot_two_mean(s1, s2)
fig
image-20250621110055582

绘制两个样本均值之差的分布:

import abetter as ab

# 定义均值型指标样本(前3个参数依次是:样本量n、样本均值mean、样本标准差std)
s1 = ab.SampleMean(1000, 0.50, 0.20)
s2 = ab.SampleMean(200, 0.55, 0.21)

# 绘图
fig, ax = ab.plot_diff_mean(s1 - s2)
fig
image-20250621110204152

todo

  • 功能:评估最小样本量
  • 功能:调研小样本比率检验如何科学的计算置信区间、MDE。
  • 绘图:统计功效
  • 输出:补充__repr____str__
  • 文档:参考文献与相关公式

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

abetter-0.0.1.tar.gz (475.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

abetter-0.0.1-py3-none-any.whl (25.8 kB view details)

Uploaded Python 3

File details

Details for the file abetter-0.0.1.tar.gz.

File metadata

  • Download URL: abetter-0.0.1.tar.gz
  • Upload date:
  • Size: 475.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for abetter-0.0.1.tar.gz
Algorithm Hash digest
SHA256 0d7512d64ef42db86254bd75eca42a459bca74e857c2e2b29858240067d6d51c
MD5 5570cca35ff55e1416ae1229141c88c1
BLAKE2b-256 c835aaa242f70f7a1c2de3d8cf20d59b812e81be71ed0b258c21718ad3f395af

See more details on using hashes here.

File details

Details for the file abetter-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: abetter-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 25.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for abetter-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d2784e6e3658a927e95d1146e94986ea1e4af4510456c02990598a8dc99bc578
MD5 9f1f6797fa0fef2b2217e5f4fae08311
BLAKE2b-256 3909faf0f6c630bc8cb2b67333e04078b8f5d3f6165b65f6bcd6cd9fc0512f32

See more details on using hashes here.

Supported by

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