BatchContextualLinTSPolicy | R Documentation |
Batch Contextual Thompson Sampling Policy
Batch Contextual Thompson Sampling Policy
Implements Thompson Sampling for linear contextual bandits with batch updates.
- 'initialize(v = 0.2, batch_size = 1)': Constructor, sets variance and batch size. - 'set_parameters(context_params)': Initializes arm-level matrices. - 'get_action(t, context)': Samples from the posterior and selects action. - 'set_reward(t, context, action, reward)': Updates posterior statistics using observed feedback.
cramR::NA
-> BatchContextualLinTSPolicy
sigma
Numeric, posterior variance scale parameter.
batch_size
Integer, size of mini-batches before parameter updates.
A_cc
List of accumulated Gram matrices per arm.
b_cc
List of reward-weighted context sums per arm.
class_name
Internal name of the class.
new()
Constructor for the batch-based Thompson Sampling policy.
BatchContextualLinTSPolicy$new(v = 0.2, batch_size = 1)
v
Numeric. Standard deviation scaling parameter for posterior sampling.
batch_size
Integer. Number of rounds before parameters are updated.
set_parameters()
Initializes per-arm sufficient statistics.
BatchContextualLinTSPolicy$set_parameters(context_params)
context_params
List with entries: 'unique' (feature vector), 'k' (number of arms).
get_action()
Samples from the posterior distribution of expected rewards and selects an action.
BatchContextualLinTSPolicy$get_action(t, context)
t
Integer. Time step.
context
List containing the current context and arm information.
A list with the chosen arm ('choice').
set_reward()
Updates Gram matrix and response vector for the chosen arm. Parameters are refreshed every 'batch_size' rounds.
BatchContextualLinTSPolicy$set_reward(t, context, action, reward)
t
Integer. Time step.
context
Context object containing feature info.
action
Chosen action (arm index).
reward
Observed reward for the action.
Updated internal parameters.
clone()
The objects of this class are cloneable with this method.
BatchContextualLinTSPolicy$clone(deep = FALSE)
deep
Whether to make a deep clone.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.