GithubHelp home page GithubHelp logo

ab_testing's Introduction

A/B Testing

This repo is a fully-featured proof-of-concept for creating an API endpoint for a machine learning model.

Features

  • A/B testing (control/variation)
  • Load testing
  • Caching of group assignments
  • API and model metrics with visualization

Introduction to A/B Testing

A/B testing, also known as split testing, is used to compare two versions of something to see which performs better. Typically used for testing two versions of landing or sales pages, we can use it to test different versions of machine learning (ML) models, or compare the results of an ML model to the current state of affairs.

A/B testing works as follows:

  1. Select a control. The control is usually what is currently in place.
  2. Create a variation.
  3. As consumers are served either the control or variation, engagement is measured and collected.
  4. Run the test until there is enough data to gain statistical significance.
  5. End the test and analyze the results.

From a technical viewpoint, the testing flow looks like this:

  1. Consumer hits an API end point.
  2. Consumer is assigned to a group (control or variation).
  3. API responds with the control or variation.
  4. The results are stored in a data store.

To help ensure we can achieve statistical significance in an experiment we:

  1. Evenly divide consumers into the two groups.
  2. Keep API groups mutually exclusive.
  3. Keep a consumer in their assigned group.

Requirements

  • Docker

What's In The Box?

  • Flask: a microframework for Python based on Werkzeug, Jinja 2 and good intentions.
  • Gunicorn: a Python WSGI HTTP Server for UNIX. All of the APIs run using gunicorn.
  • Locust: an open source load testing tool.
  • Redis: for caching
  • Elasticsearch: logs and metric storage
  • Logstash: transfers logs into Elasticsearch
  • Kibana: log and metric visualization
  • MySQL: storing non-log data

The entire stack is run in Docker containers.

Usage: Three Easy Steps!

  1. Launch the stack: docker-compose up --build --force-recreate -d
  2. Open your browser and go to the Locust UI at http://127.0.0.1:8089
  3. Run your load tests.

Usage for Real Life

  1. Create a machine learning model with scikit-learn and save it to disk using joblib.
  2. Update the api.env file in ml_api/api.env with the path to the model.
  3. Add code to retrieve the features your model needs.
  4. Launch the API.

If using a different model library, you can update the project to load pickled models instead.

ab_testing's People

Contributors

rdempsey avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.