Learn R Programming

bayesAB (version 1.1.3)

deployBandit: Deploy a bayesBandit object as a JSON API.

Description

Turn your bayesBandit object into an API and serve/update requests through HTTP.

Usage

deployBandit(bandit, port = 8000)

Arguments

bandit

a bayesBandit object

port

port to deploy on

Value

An active http process on some port.

Details

deployBandit turns a Bayesian bandit into a JSON API that accepts curl requests. Two of the five methods of bayesBandit classes are exposed: serveRecipe and setResults. Assuming the API is deployed on localhost this is an example of how it would be hit:

$$curl http://localhost:8000/serveRecipe$$

$$curl --data '{"A":[1, 0, 1, 1], "B":[0, 0, 0, 1]}' http://localhost:8000/setResults$$

Examples

Run this code
# NOT RUN {
A_binom <- rbinom(100, 1, .5)
B_binom <- rbinom(100, 1, .6)

AB1 <- bayesTest(A_binom, B_binom, priors = c('alpha' = 1, 'beta' = 1), distribution = 'bernoulli')

binomialBandit <- banditize(AB1)
# }
# NOT RUN {
deployBandit(binomialBandit)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab