Skip to main content

Janus

License2 Python Version Code style: black

Janus is a simple and easy A/B Test Calculator that allows you to run A/B tests and get reports in a few lines of code.

It's developed mainly for website experiments. While many calculators only account for conversion analysis and consider only two variants, Janus allows multivariant tests and measure Conversion, Averge Ticket and Average Revenue Per User (ARPU) over variants, i.e, typical metrics for tests in marketplaces.

The engine name is an analogy to Janus, the god of changes and transitions.

Installation

Janus is distributed in pypi. You can install it by using:

pip install janus-web-ab-testing

You can now run a quick example of a A/B test:

from janus.variant import Variant
from janus.experiment import WebsiteExperiment

variant_A = Variant(
    name="A",
    impressions=1000, 
    conversions=100, 
    revenue=10000
)
variant_B = Variant(
    name="B",
    impressions=1000, 
    conversions=120, 
    revenue=9000
)
variants = [variant_A, variant_B]

experiment = WebsiteExperiment(variants, baseline_variant="A")
experiment.run()
experiment.print_reports()

And you should see:

---------------- Summary ----------------
+-------------+-------------+------------+
|             |           A |          B |
+=============+=============+============+
| impressions |        1000 |       1000 |
+-------------+-------------+------------+
| conversions |         100 |        120 |
+-------------+-------------+------------+
|     revenue | R$10,000.00 | R$9,000.00 |
+-------------+-------------+------------+
|  conversion |         0.1 |       0.12 |
+-------------+-------------+------------+
|  avg_ticket |    R$100.00 |    R$75.00 |
+-------------+-------------+------------+
|        arpu |     R$10.00 |     R$9.00 |
+-------------+-------------+------------+
----------- Conversion Stats -----------
+-----------------+--------+--------+
|                 |      A |      B |
+=================+========+========+
|   expected_loss | 0.0206 | 0.0005 |
+-----------------+--------+--------+
| prob_being_best | 0.0786 | 0.9214 |
+-----------------+--------+--------+
|            lift |    0.0 |    0.2 |
+-----------------+--------+--------+
-------------- ARPU Stats --------------
+-----------------+--------+--------+
|                 |      A |      B |
+=================+========+========+
|   expected_loss | R$0.14 | R$1.15 |
+-----------------+--------+--------+
| prob_being_best | 0.7936 | 0.2064 |
+-----------------+--------+--------+
|            lift |    0.0 |   -0.1 |
+-----------------+--------+--------+

See more in the quickstart notebook. The Average Ticket Statistics is still missing, but will be added soon (it's usually modelled with exponential distribution with gamma as prior)

The Janus Website

My plan is to build a website to showcase the Janus library and to provide a simple interface to run A/B tests. However, only the library is almost ready, and the next steps would be:

  • build a backend with FastAPI using the library
  • build a frontend (JavaScript maybe)
  • deploy the website

Warning The distributed package is from this branch, which will be merged to main in the first release of this project. The main branch uses another previous approach for the calculations (yet correct), and has a streamlit app to showcase the library. In this branch, however, we'll change the whole project towards not only a library, but also for a full stack application, with frontend and backend.

References

Metadata

Release files for janus-web-ab-testing 0.1.6

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

Source distribution (sdist)

Source distribution for janus-web-ab-testing 0.1.6
File Size Uploaded
janus_web_ab_testing-0.1.6.tar.gz 5.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for janus-web-ab-testing 0.1.6
File Interpreter ABI Platform
janus_web_ab_testing-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 12.4 kB

Release files / janus_web_ab_testing-0.1.6.tar.gz

Download URL janus_web_ab_testing-0.1.6.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
4405e6b16a06d4df5e2c4e3c2268a482deab61d2e1fa1301e3ebc492ba3a78d4
BLAKE2b-256 checksum
How to use checksums
12a11a0d9369cb0cdd463023d1c727153e3ef3920777714d6acac59b13164069
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.9.17 Darwin/23.2.0

Release files / janus_web_ab_testing-0.1.6-py3-none-any.whl

Download URL janus_web_ab_testing-0.1.6-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
df97dee2baf081d802ba570133e988a95e13a530c5b0214b11597a589f306e2b
BLAKE2b-256 checksum
How to use checksums
49ae1fd6557ae46792eb51fa64c365049ce320bec6f9f17f2ce06026f09f3d8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.9.17 Darwin/23.2.0

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 release files

0.1.5

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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