Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rueian/gobandit

A golang library for solving multi armed bandit problem which can optimize your business choice on the fly without A/B testing
https://github.com/rueian/gobandit

enforcement golang multi-armed-bandit thompson-sampling

Last synced: 3 months ago
JSON representation

A golang library for solving multi armed bandit problem which can optimize your business choice on the fly without A/B testing

Awesome Lists containing this project

README

        

# gobandit

[![CircleCI](https://circleci.com/gh/rueian/gobandit.svg?style=svg)](https://circleci.com/gh/rueian/gobandit)
[![codecov](https://codecov.io/gh/rueian/gobandit/branch/master/graph/badge.svg)](https://codecov.io/gh/rueian/gobandit)

A golang library for solving multi armed bandit problem which can optimize your business choice on the fly without A/B testing.

## Thompson Sampling

```go
package main

import (
"time"

"github.com/rueian/gobandit/thompson"
)

func init() {
thompson.Seed(time.Now().Unix())
}

func main() {
// load your candidate statistics, for example:
candidates := [][2]float64{
{1000, 500}, // candidate 0 => likeCount: 1000, dislikeCount: 500
{500, 1000}, // candidate 1 => likeCount: 500, dislikeCount: 1000
}

for {
// let Thompson Sampling choose a candidate based on the statistics
elected, _ := thompson.Choose(candidates)

// use the elected one, and collect feedback to update the statistic for next choose
if peopleLike(elected) {
candidates[elected][0]++
} else {
candidates[elected][1]++
}

if done() {
break
}
}
}
```