No project description provided
Project description
Py AB Testing
AB testing library supporting multi-variance testing with a deterministic algorithm not requiring any complex backend or database.
The segmentation logic is maintained in the AB testing client and based itself on a centralized configuration. The cohort assignment logic is deterministic and follows a simple hash pattern based on the crc32c
algorithm (crc32c(userId, crc32c(experimentName)) % 100
)
Installation
pip install py-ab-testing
# or
pipenv install py-ab-testing
Usage
Note: The config
variable holds an dict
with configuration file format that documented here.
from ABTesting import ABTestingController
user_profile = {
'persona': user.persona,
'employee': user.isEmployee,
}
controller = ABTestingController(config, user.id, user_profile)
cohort = controller.get_cohort('experiment-name')
if cohort == 'blue':
do_something()
elif cohort == 'red':
do_something_else()
else:
do_default_behavior()
Protecting Private Information
Similar to the Javascript SDKs, the package comes with an optional util for hashing private information with sha256
.
Prepare config file BEFORE make it public
from ABTesting.utils import hash_dict
config['salt'] = salt
for experiment in config['experiments']:
for cohort in experiment['cohorts']:
cohort['force_include'] = hash_dict(cohort['force_include'], salt)
In runtime
from ABTesting.utils import hash_dict
hashed_user_profile = hash_dict(
{
'persona': user.persona,
'employee': user.isEmployee,
},
salt
)
# Make sure config is hashed with the same salt
controller = ABTestingController(config, user.id, hashed_user_profile)
Credits
Made with ❤️ by Zhang Tao and Simon Boudrias from the App Annie Beijing office.
Available for public use under the MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for py_ab_testing-1.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19e4438aebef6e0fad700f5e288fe4aa7e3c9abc1f44bc19dc2512d55734f08c |
|
MD5 | 65ff4dccbfca0bfc8c968de102cb6a71 |
|
BLAKE2b-256 | 160952e839bc1c7072c391640a8cfe683c4b2ebdb73b166ceda606cd08f915a7 |