How to Get Started with Ambrosia: A Python Library for A/B Testing

Sep 28, 2023 | Data Science

If you’re diving into the world of A/B testing, then you’re in for a treat with Ambrosia. This Python library provides a seamless and efficient way to design, split, and measure the effects of experiments. Whether you’re conducting research or deploying in production environments, Ambrosia is structured to handle it all, utilizing data in both pandas and Spark formats.

Key Functionality of Ambrosia

Ambrosia offers a rich set of functionalities. Here are some of its key features:

  • Pilots design
  • Multi-group split
  • Matching of new control groups to existing pilots
  • Experiments result evaluation based on p-value, point estimate, and confidence intervals
  • Data preprocessing
  • Experiments acceleration

Installation Guide

To get started, you’ll want to install the newest version of Ambrosia. Here’s how you can do it:

pip install ambrosia

From version 0.4.0, if you want to process PySpark data, you can include it during the installation by using extras:

pip install ambrosia[spark]

Usage Overview

Ambrosia consists of several core classes and methods that walk you through the different stages of an experiment. Think of it like a roadmap guiding you through a city—each part has its unique destination but they all lead to successful experimentation.

1. Designer

The Designer class is your initial point of contact for creating your experimental framework. It’s similar to an architect laying down the blueprints for a new building.

from ambrosia.designer import Designer
designer = Designer(dataframe=df, effects=1.2, metrics=portfel_clc) # 20% effect
designer.run(size)

2. Splitter

Once everything is set, the Splitter class takes over, akin to a traffic controller dividing vehicles into lanes to ensure smooth flow.

from ambrosia.splitter import Splitter
splitter = Splitter(dataframe=df, id_column=id) # loaded dataframe df with id column
splitter.run(groups_size=500, method=simple)

3. Tester

Finally, after your experiment runs, the Tester class evaluates the results, much like a jury assessing the evidence presented in court.

from ambrosia.tester import Tester
tester = Tester(dataframe=df, column_groups=group) # loaded dataframe df with groups info
tester.run(metrics=retention, method=theory, criterion=ttest)

Development Setup

If you’re looking to contribute or expand on Ambrosia’s functionality, here’s how to set up your development environment:

make install

Ensure you have Python 3 and Poetry installed. You can also use commands like:

  • Autoformatting: make autoformat
  • Linter check: make lint
  • Run tests: make test
  • Check coverage: make coverage
  • Clean: make clean

Troubleshooting Tips

If you encounter issues during installation or usage, here are a few troubleshooting ideas:

  • Ensure you have all dependencies installed, especially for PySpark.
  • Check the correct usage of data formats (pandas or Spark).
  • Consult the documentation for misunderstandings regarding functions and methods.
  • Look into potential errors in your code syntax that could affect execution.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Conclusion

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox