banditize {bayesAB} | R Documentation |
Create a multi-armed Bayesian bandit object.
Description
Fit a multi-armed bandit object based on a bayesTest which can serve recommendations and adapt to new data.
Usage
banditize(bT, param, higher_is_better = TRUE)
Arguments
bT |
a bayesTest object |
param |
which model parameter (posterior) to evaluate; defaults to first param |
higher_is_better |
is a higher value of 'param' equivalent to a better choice? |
Details
banditize
is an 'object-oriented' implementation of multi-armed bandits in bayesAB
. It is useful in
conjunction with a Shiny app or Plumber deployment. The object itself is mutable and can adapt/learn from new data without having to
re-assign the variable.
Comes with 5 methods:
-
serveRecipe()
: serves a recipe to show your user based on samples from both posteriors. -
setResults(results)
: set results for one or more recipes for one or more instances of feedback. Used to update bandit. -
getBayesTest()
: returns most updatedbayesTest
object. -
getOriginalTest()
: returns originalbayesTest
object without any updates. -
getUpdates()
: returns a summarized version of all updates this bandit has processed.
Value
A bayesBandit object.
Examples
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)
binomialBandit$serveRecipe()
binomialBandit$setResults(list('A' = c(1, 0, 1, 0, 0), 'B' = c(0, 0, 0, 0, 1)))