YahooRandomPolicy <- R6::R6Class(
portable = FALSE,
class = FALSE,
inherit = Policy,
public = list(
class_name = "YahooRandomPolicy",
initialize = function() {
super$initialize()
},
set_parameters = function(context_params) {
self$theta_to_arms <- list('n' = 0, 'mean' = 0)
},
get_action = function(t, context) {
action$choice <- sample(context$arms, 1)
action
},
set_reward = function(t, context, action, reward) {
arm <- action$choice
reward <- reward$reward
inc(self$theta$n[[arm]]) <- 1
inc(self$theta$mean[[arm]]) <- (reward - self$theta$mean[[arm]]) / self$theta$n[[arm]]
self$theta
}
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.