Brush C++ API
A flexible interpretable machine learning framework
|
A virtual class representing a bandit operator. More...
#include <bandit_operator.h>
Public Member Functions | |
BanditOperator (vector< T > arms) | |
Constructs a BanditOperator object with a vector of arms. | |
BanditOperator (map< T, float > arms_probs) | |
Constructs a BanditOperator object with a map of arms and their probabilities. | |
~BanditOperator () | |
virtual std::map< T, float > | sample_probs (bool update) |
Samples the probabilities of the arms. | |
virtual T | choose (const VectorXf &context) |
Chooses an arm based on the given tree and fitness. Should call sample_probs internally. | |
virtual void | update (T arm, float reward, VectorXf &context) |
Updates the reward for a specific arm. | |
Protected Attributes | |
std::map< T, float > | probabilities |
Private Types | |
using | Iter = tree<Node>::pre_order_iterator |
A virtual class representing a bandit operator.
This class provides functionality for sampling probabilities and updating rewards for different arms. The bandit should somehow behave stocasticaly when called twice in a row without being rewarded, because some mutations may require multiple sampling from the search space. Also, the bandit should have a functionality to return smapling probabilities, instead of just the chosen arm.
T | The type of the arms. |
Definition at line 22 of file bandit_operator.h.
|
private |
Definition at line 24 of file bandit_operator.h.
Brush::MAB::BanditOperator< T >::BanditOperator | ( | vector< T > | arms | ) |
Constructs a BanditOperator object with a vector of arms.
arms | The vector of arms. |
Definition at line 7 of file bandit_operator.cpp.
Brush::MAB::BanditOperator< T >::BanditOperator | ( | map< T, float > | arms_probs | ) |
Constructs a BanditOperator object with a map of arms and their probabilities.
arms_probs | The map of arms and their probabilities. |
Definition at line 19 of file bandit_operator.cpp.
|
inline |
Definition at line 40 of file bandit_operator.h.
|
virtual |
Chooses an arm based on the given tree and fitness. Should call sample_probs internally.
tree | The tree structure used to choose the arm. |
f | The fitness value used to influence the choice. |
Reimplemented in Brush::MAB::DummyBandit< T >, Brush::MAB::LinearThompsonSamplingBandit< T >, and Brush::MAB::ThompsonSamplingBandit< T >.
Definition at line 41 of file bandit_operator.cpp.
|
virtual |
Samples the probabilities of the arms.
update | A boolean indicating whether to update the probabilities. |
Reimplemented in Brush::MAB::DummyBandit< T >, Brush::MAB::LinearThompsonSamplingBandit< T >, and Brush::MAB::ThompsonSamplingBandit< T >.
Definition at line 28 of file bandit_operator.cpp.
|
virtual |
Updates the reward for a specific arm.
arm | The arm for which to update the reward. |
reward | The reward value. |
Reimplemented in Brush::MAB::DummyBandit< T >, Brush::MAB::LinearThompsonSamplingBandit< T >, and Brush::MAB::ThompsonSamplingBandit< T >.
Definition at line 54 of file bandit_operator.cpp.
|
protected |
Definition at line 67 of file bandit_operator.h.