offdev / bandit
An A/B/x testing algorithm written in PHP by implementing the solution to the multi armed bandit problem
Installs: 9 990
Dependents: 0
Suggesters: 0
Security: 0
Stars: 17
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- php: >=7
Requires (Dev)
- phpunit/phpunit: ^6.0
- squizlabs/php_codesniffer: 2.*
This package is auto-updated.
Last update: 2024-10-29 04:04:07 UTC
README
An A/B/x testing algorithm written in PHP by implementing the solution to the multi armed bandit problem
Requirements
- PHP >= 7.4
- Composer
Installation
$ composer require offdev/bandit
General Usage
First, you need to set up a machine, and its possible levers. A lever might have already been pulled a few times, and some levers may also have rewarded the lucky person which pulled it, so adjust those numbers accordingly. Example:
use Offdev\Bandit\Lever; use Offdev\Bandit\Machine; $machine = new Machine( new Lever('first-lever', 123, 1), new Lever('second-lever', 108, 3), new Lever('third-lever', 115, 0), );
Now you need a strategy to solve your problem. See this link for more information about strategies, and have a look at the example ones I have included in src/php/Strategies
. Example:
use Offdev\Bandit\Strategies\EpsilonGreedy; $strategy = new EpsilonGreedy(); $winningLever = $strategy->solve($machine);
It is as simple as that :)
TODO
Add more docs :)