Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/rueian/gobandit
- Owner: rueian
- Created: 2019-04-14T08:01:11.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-04-15T16:33:18.000Z (over 5 years ago)
- Last Synced: 2024-06-20T13:29:55.387Z (7 months ago)
- Topics: enforcement, golang, multi-armed-bandit, thompson-sampling
- Language: Go
- Size: 6.84 KB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
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 mainimport (
"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
}
}
}
```