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

#include <linear_thompson.h>

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

Public Member Functions

 LinearThompsonSamplingBandit (vector< T > arms)
 
 LinearThompsonSamplingBandit (map< T, float > arms_probs)
 
 ~LinearThompsonSamplingBandit ()
 
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

int n_arms
 
vector< MatrixXf > B
 
vector< MatrixXf > B_inv
 
vector< MatrixXf > B_inv_sqrt
 
MatrixXf m2_r
 
MatrixXf mean
 
std::map< int, T > arm_index_to_key
 

Additional Inherited Members

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

Detailed Description

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

Definition at line 20 of file linear_thompson.h.

Constructor & Destructor Documentation

◆ LinearThompsonSamplingBandit() [1/2]

Definition at line 7 of file linear_thompson.cpp.

Here is the call graph for this function:

◆ LinearThompsonSamplingBandit() [2/2]

template<typename T>
Brush::MAB::LinearThompsonSamplingBandit< T >::LinearThompsonSamplingBandit ( map< T, float > arms_probs)

Definition at line 27 of file linear_thompson.cpp.

Here is the call graph for this function:

◆ ~LinearThompsonSamplingBandit()

Definition at line 25 of file linear_thompson.h.

Member Function Documentation

◆ choose()

template<typename T>
T Brush::MAB::LinearThompsonSamplingBandit< 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 87 of file linear_thompson.cpp.

◆ sample_probs()

template<typename T>
std::map< T, float > Brush::MAB::LinearThompsonSamplingBandit< 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 47 of file linear_thompson.cpp.

Here is the call graph for this function:

◆ update()

template<typename T>
void Brush::MAB::LinearThompsonSamplingBandit< 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 125 of file linear_thompson.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ arm_index_to_key

template<typename T>
std::map<int, T> Brush::MAB::LinearThompsonSamplingBandit< T >::arm_index_to_key
private

Definition at line 41 of file linear_thompson.h.

◆ B

template<typename T>
vector<MatrixXf> Brush::MAB::LinearThompsonSamplingBandit< T >::B
private

Definition at line 33 of file linear_thompson.h.

◆ B_inv

template<typename T>
vector<MatrixXf> Brush::MAB::LinearThompsonSamplingBandit< T >::B_inv
private

Definition at line 34 of file linear_thompson.h.

◆ B_inv_sqrt

template<typename T>
vector<MatrixXf> Brush::MAB::LinearThompsonSamplingBandit< T >::B_inv_sqrt
private

Definition at line 35 of file linear_thompson.h.

◆ m2_r

template<typename T>
MatrixXf Brush::MAB::LinearThompsonSamplingBandit< T >::m2_r
private

Definition at line 37 of file linear_thompson.h.

◆ mean

template<typename T>
MatrixXf Brush::MAB::LinearThompsonSamplingBandit< T >::mean
private

Definition at line 38 of file linear_thompson.h.

◆ n_arms

template<typename T>
int Brush::MAB::LinearThompsonSamplingBandit< T >::n_arms
private

Definition at line 31 of file linear_thompson.h.


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