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

#include <thompson.h>

Inheritance diagram for Brush::MAB::ThompsonSamplingBandit:
Collaboration diagram for Brush::MAB::ThompsonSamplingBandit:

Public Member Functions

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

Additional Inherited Members

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

Detailed Description

Definition at line 11 of file thompson.h.

Constructor & Destructor Documentation

◆ ThompsonSamplingBandit() [1/2]

Brush::MAB::ThompsonSamplingBandit::ThompsonSamplingBandit ( vector< string > arms,
bool dynamic = false )

Definition at line 6 of file thompson.cpp.

Here is the call graph for this function:

◆ ThompsonSamplingBandit() [2/2]

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

Definition at line 16 of file thompson.cpp.

Here is the call graph for this function:

◆ ~ThompsonSamplingBandit()

Brush::MAB::ThompsonSamplingBandit::~ThompsonSamplingBandit ( )
inline

Definition at line 16 of file thompson.h.

Member Function Documentation

◆ choose()

string Brush::MAB::ThompsonSamplingBandit::choose ( )
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.

Definition at line 54 of file thompson.cpp.

Here is the call graph for this function:

◆ sample_probs()

std::map< string, float > Brush::MAB::ThompsonSamplingBandit::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.

Definition at line 27 of file thompson.cpp.

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

◆ update()

void Brush::MAB::ThompsonSamplingBandit::update ( string arm,
float reward )
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.

Definition at line 60 of file thompson.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ alphas

std::map<string, float> Brush::MAB::ThompsonSamplingBandit::alphas
private

Definition at line 25 of file thompson.h.

◆ betas

std::map<string, float> Brush::MAB::ThompsonSamplingBandit::betas
private

Definition at line 26 of file thompson.h.

◆ C

float Brush::MAB::ThompsonSamplingBandit::C = 250
private

Definition at line 23 of file thompson.h.

◆ dynamic_update

bool Brush::MAB::ThompsonSamplingBandit::dynamic_update
private

Definition at line 22 of file thompson.h.


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