---

title: Bandits


keywords: fastai
sidebar: home_sidebar

summary: "Bandit models including beta bandit, and epsilon bandit."
description: "Bandit models including beta bandit, and epsilon bandit."
nb_path: "nbs/models/bandits.ipynb"
---
<!--

#################################################
### THIS FILE WAS AUTOGENERATED! DO NOT EDIT! ###
#################################################
# file to edit: nbs/models/bandits.ipynb
# command to build the docs after a change: nbdev_build_docs

-->

<div class="container" id="notebook-container">
        
    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

<div class="output_wrapper">
<div class="output">

<div class="output_area">


<div class="output_markdown rendered_html output_subarea ">
<h2 id="BetaBandit" class="doc_header"><code>class</code> <code>BetaBandit</code><a href="https://github.com/RecoHut-Projects/recohut/tree/master/recohut/models/bandits.py#L10" class="source_link" style="float:right">[source]</a></h2><blockquote><p><code>BetaBandit</code>(<strong><code>alpha</code></strong>:<code>int</code>=<em><code>0</code></em>, <strong><code>beta</code></strong>:<code>int</code>=<em><code>0</code></em>, <strong><code>alpha_prior</code></strong>:<code>float</code>=<em><code>1.0</code></em>, <strong><code>beta_prior</code></strong>:<code>float</code>=<em><code>1.0</code></em>)</p>
</blockquote>
<p>Bandit class that is used in Thompson sampling.
Attributes:
    alpha: Alpha parameter of the beta distribution (number of positive examples).
    beta: Beta parameter of the beta distribution (number of negative examples).</p>
<p>Methods:
    update: Updates alpha and beta priors of the BetaBandit.
    sample: Samples the BetaBandit's distribution n times.</p>

</div>

</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

<div class="output_wrapper">
<div class="output">

<div class="output_area">


<div class="output_markdown rendered_html output_subarea ">
<h2 id="EpsilonBandit" class="doc_header"><code>class</code> <code>EpsilonBandit</code><a href="https://github.com/RecoHut-Projects/recohut/tree/master/recohut/models/bandits.py#L55" class="source_link" style="float:right">[source]</a></h2><blockquote><p><code>EpsilonBandit</code>(<strong><code>positive_examples</code></strong>:<code>int</code>=<em><code>0</code></em>)</p>
</blockquote>
<p>Bandit class that is used in Epsilon-greedy multi-armed bandits.
Attributes:
    positive_examples: Number of positive examples.</p>
<p>Methods:
    update: Updates the number of positive examples of the EpsilonBandit.
    get_value: Gets the number of positive examples of the EpsilonBandit.</p>

</div>

</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

</div>
 

