Brush C++ API
A flexible interpretable machine learning framework
Loading...
Searching...
No Matches
Brush::MAB::ThompsonSamplingBandit< T > Class Template Reference

#include <thompson.h>

Inheritance diagram for Brush::MAB::ThompsonSamplingBandit< T >:
Collaboration diagram for Brush::MAB::ThompsonSamplingBandit< T >:

Public Member Functions

 ThompsonSamplingBandit (vector< T > arms, bool dynamic=false)
 
 ThompsonSamplingBandit (map< T, float > arms_probs, bool dynamic=false)
 
 ~ThompsonSamplingBandit ()
 
std::map< T, float > sample_probs (bool update)
 Samples the probabilities of the arms.
 
choose (const VectorXf &context)
 Chooses an arm based on the given tree and fitness. Should call sample_probs internally.
 
void update (T arm, float reward, VectorXf &context)
 Updates the reward for a specific arm.
 
- Public Member Functions inherited from Brush::MAB::BanditOperator< T >
 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 ()
 

Private Attributes

bool dynamic_update
 
float C = 250
 
std::map< T, float > alphas
 
std::map< T, float > betas
 

Additional Inherited Members

- Protected Attributes inherited from Brush::MAB::BanditOperator< T >
std::map< T, float > probabilities
 

Detailed Description

template<typename T>
class Brush::MAB::ThompsonSamplingBandit< T >

Definition at line 20 of file thompson.h.

Constructor & Destructor Documentation

◆ ThompsonSamplingBandit() [1/2]

template<typename T>
Brush::MAB::ThompsonSamplingBandit< T >::ThompsonSamplingBandit ( vector< T > arms,
bool dynamic = false )

Definition at line 7 of file thompson.cpp.

Here is the call graph for this function:

◆ ThompsonSamplingBandit() [2/2]

template<typename T>
Brush::MAB::ThompsonSamplingBandit< T >::ThompsonSamplingBandit ( map< T, float > arms_probs,
bool dynamic = false )

Definition at line 18 of file thompson.cpp.

Here is the call graph for this function:

◆ ~ThompsonSamplingBandit()

template<typename T>
Brush::MAB::ThompsonSamplingBandit< T >::~ThompsonSamplingBandit ( )
inline

Definition at line 25 of file thompson.h.

Member Function Documentation

◆ choose()

template<typename T>
T Brush::MAB::ThompsonSamplingBandit< T >::choose ( const VectorXf & context)
virtual

Chooses an arm based on the given tree and fitness. Should call sample_probs internally.

Parameters
treeThe tree structure used to choose the arm.
fThe fitness value used to influence the choice.
Returns
The arm with highest probability.

Reimplemented from Brush::MAB::BanditOperator< T >.

Definition at line 81 of file thompson.cpp.

Here is the call graph for this function:

◆ sample_probs()

template<typename T>
std::map< T, float > Brush::MAB::ThompsonSamplingBandit< T >::sample_probs ( bool update)
virtual

Samples the probabilities of the arms.

Parameters
updateA boolean indicating whether to update the probabilities.
Returns
A map of arms and their probabilities.

Reimplemented from Brush::MAB::BanditOperator< T >.

Definition at line 30 of file thompson.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update()

template<typename T>
void Brush::MAB::ThompsonSamplingBandit< T >::update ( T arm,
float reward,
VectorXf & context )
virtual

Updates the reward for a specific arm.

Parameters
armThe arm for which to update the reward.
rewardThe reward value.

Reimplemented from Brush::MAB::BanditOperator< T >.

Definition at line 88 of file thompson.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ alphas

template<typename T>
std::map<T, float> Brush::MAB::ThompsonSamplingBandit< T >::alphas
private

Definition at line 34 of file thompson.h.

◆ betas

template<typename T>
std::map<T, float> Brush::MAB::ThompsonSamplingBandit< T >::betas
private

Definition at line 35 of file thompson.h.

◆ C

template<typename T>
float Brush::MAB::ThompsonSamplingBandit< T >::C = 250
private

Definition at line 32 of file thompson.h.

◆ dynamic_update

template<typename T>
bool Brush::MAB::ThompsonSamplingBandit< T >::dynamic_update
private

Definition at line 31 of file thompson.h.


The documentation for this class was generated from the following files: