Giter Club home page Giter Club logo

bandit's Introduction

bandit

Build Status Coverage Status

For more information see Multiarmed Bandit

Types

type Variant interface {
    RewardSum() float64 
	RewardSquareSum() float64
	ObservationCount() int
	Observe(reward float64) (Variant, error)
}

All the algorithm implementations operate on an array of variants. An in-memory Variant implementation is provided using bandit.NewVariant(). However you can implement your own persistent variant.

Internally we have implemented persistent variants over Mongodb, Cassandra and Leveldb. We would probably open source those at a later date.

The in-memory variant implementation is immutable, and therefore when calling the Observe method you should re-assign it:

v := bandit.NewVaraint()
v, _ = v.Observe(0.5)

Algorithms and Examples

  • UCB1: Fina the machine that maximizes the rank (mean + confidence bound). Implementation is based on the algorithm presented by Auer et al in "Finite-Time Analysis of the Multiarmed Bandit Problem" (2002).
variants := []Variant{bandit.NewVariant(), bandit.NewVariant(), bandit.NewVariant()}
v, _ := bandit.Ucb1(variants)
  • EpsilonDecreasing: Epsilon decreasing strategy is similar to the epsilon greed but the epsilon value decreases over time. This implementation provides a decreasing e0 / t where e0 is a positive tuning parameter and t the current round index. The epsilon decreasing strategy is analysed in Finite time analysis of the multiarmed bandit problem. by Auer, Cesa-Bianchi and Fisher in Machine Learning (2002).
variants := []Variant{bandit.NewVariant(), bandit.NewVariant(), bandit.NewVariant()}
v, _ := bandit.EpsilonDecreasing(1000,variants)
  • EpsilonGreedy: This is the simplest of strategies. Intuitively it basically always pulls the lever with the highest estimated mean, except when a randome lever is pulled with an epsilon frequency. The function will return nil if len(variants) == 0
variants := []Variant{bandit.NewVariant(), bandit.NewVariant(), bandit.NewVariant()}
v, _ := bandit.EpsilonGreedy(0.1, variants)

Docmentation

Documentation is available on godoc.

bandit's People

Contributors

ghais avatar

Stargazers

 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.