Skip to main content

ABalytics: Advanced A/B Testing Statistical Analytics

ABalytics is a Python package designed for statistical analysis, particularly for assessing the significance of A/B testing results. Its goal is to provide high-quality analysis by selecting the appropriate statistical tests based on the type of variable being analyzed. It offers a suite of tools to perform various significance tests and posthoc analyses on experimental data.

Features

  • Boolean and Numeric Analysis: Supports analysis of both boolean and numeric data types, ensuring the use of correct statistical methods for each.
  • Significance Tests: Includes a variety of significance tests such as Chi-Square, Welch's ANOVA, and Kruskal-Wallis, to accurately determine the significance of results.
  • Posthoc Analysis: Offers posthoc analysis methods like Tukey's HSD, Dunn's test, and Games-Howell, for detailed examination following significance tests.
  • Normality and Homogeneity Checks: Performs checks for Gaussian distribution and homogeneity of variances using Levene's test, which are critical for selecting the right tests.
  • Data Transformation: Provides functionality to convert data from long to wide format, facilitating analysis of dependent groups.
  • Pretty Text Output: Generates a formatted text output with the results of the statistical tests, facilitating interpretation and reporting.

Installation

To install ABalytics, use pip:

pip install abalytics

Usage

Analyzing Results

ABalytics provides two main functions for analyzing A/B testing results: analyze_independent_groups and analyze_dependent_groups.

Independent Groups Analysis

analyze_independent_groups is used for analyzing data where the groups are independent of each other. It takes a pandas DataFrame, the name of the column containing the variable to analyze, the name of the column containing the grouping variable, and optional parameters for p-value threshold and minimum sample size.

Example:

from abalytics import analyze_independent_groups
import pandas as pd

# Load your data into a pandas DataFrame
df = pd.read_csv('your_data.csv')

# Analyze the results
analysis_results = analyze_independent_groups(
    df,
    variable_to_analyze="order_value",
    group_column="ab_test_group",
)

Dependent Groups Analysis

analyze_dependent_groups is used for analyzing data where the groups are dependent, such as repeated measures on the same subjects. It requires data in wide format. If your data is in long format, you can use the convert_long_to_wide function in abalytics.utils to convert it. The analyze_dependent_groups function takes a pandas DataFrame, the names of the columns to compare, and optional parameters for p-value threshold and minimum sample size.

Example:

from abalytics import analyze_dependent_groups
import pandas as pd

# Load your data into a pandas DataFrame
df = pd.read_csv('your_data.csv')

# Analyze the results
analysis_results = analyze_dependent_groups(
    df,
    variables_to_compare=["pre_test_score", "post_test_score"],
)

Data Transformation

The convert_long_to_wide function in abalytics.utils is designed to transform data from long format to wide format, with an option to keep multi-level columns or flatten them. analyze_dependent_groups requires data in wide format to operate correctly.

Example:

from abalytics.utils import convert_long_to_wide
import pandas as pd

# Assuming 'df_long' is your pandas DataFrame in long format
df_wide = convert_long_to_wide(
    df_long,
    index_col="subject_id",
    columns_col="condition",
    flatten_columns=True # Set to False if you wish to keep multi-level columns
)

Generating Pretty Text Output

To get a formatted text output of your results, you can use the utils.format_results_as_table function.

Example:

from abalytics.utils import format_results_as_table
from abalytics import analyze_independent_groups
import pandas as pd

# Load your data into a pandas DataFrame
df = pd.read_csv('your_data.csv')

# Analyze the results
analysis_results = analyze_independent_groups(
    df,
    variable_to_analyze="order_value",
    group_column="ab_test_group",
)

# Generate pretty text output
pretty_text = format_results_as_table(
    abalytics_results=[analysis_results],
    identifiers_list=[{"Test name": "A/B Test 1", "Channel": "Mobile"}],
)
print(pretty_text)

Executing this code will output a neatly formatted table displaying the outcomes of the statistical significance tests. The table includes the sample size and the test results. Optionally, you can set show_details to True to include additional details such as the a priori and posthoc tests used. By default, only the significant results are displayed. This can be changed by setting show_only_significant_results to False.

Example output:

Test name             Channel         n  Result                                              p-value
--------------------  ----------  -----  ------------------------------------------------  ---------
A/B Test 1            Mobile       5009  new_cta_1 (0.16) > new_cta_2 (0.15)                   0.007
A/B Test 1            Tablet       2887  new_cta_1 (0.22) > new_cta_2 (0.20)                   0.000
A/B Test 1            Tablet       2887  new_cta_1 (0.22) > old_implementation (0.20)          0.005
A/B Test 1            Desktop     20014  new_cta_1 (0.18) > new_cta_2 (0.17)                   0.000
A/B Test 1            Desktop     20014  new_cta_1 (0.18) > old_implementation (0.17)          0.000
A/B Test 2            Mobile        268  new_cta_1 (0.10) > new_cta_2 (0.06)                   0.006
A/B Test 2            Mobile        268  new_cta_1 (0.10) > old_implementation (0.06)          0.014
A/B Test 2            Desktop      5609  new_cta_1 (0.13) > new_cta_2 (0.12)                   0.025

Further examples of how to use ABalytics can be found in examples/example.py.

Contributing

Contributions to ABalytics are welcome. If you have suggestions for improvements or find any issues, please open an issue or submit a pull request.

Metadata

Release files for abalytics 4.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for abalytics 4.0.1
File Size Uploaded Provenance
abalytics-4.0.1.tar.gz 25.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for abalytics 4.0.1
File Interpreter ABI Platform
abalytics-4.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 51.4 kB

Release files / abalytics-4.0.1.tar.gz

Download URL abalytics-4.0.1.tar.gz
Size 25.8 kB
Tags Source
SHA-256 checksum
How to use checksums
67febafe061cc34138f1c368466e94147662e357c71cb3890ce7e62d21d8f33d
BLAKE2b-256 checksum
How to use checksums
0203d91e4cb005089029b83fbb255732e1918c2fc4b9ce03f7ea0c5e573ce44e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / abalytics-4.0.1-py3-none-any.whl

Download URL abalytics-4.0.1-py3-none-any.whl
Size 25.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
52f846021360de6ac7b6f692f58701825bd8446b77e0cda485dc2a6ee118c37b
BLAKE2b-256 checksum
How to use checksums
daaf82acf1f3905007c739bd990512416a0b83f64f4ab0256dbea33ebffbdfc7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Security for abalytics 4.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page