API Reference#
Agent API#
The Agent API is the most ergonomic way to use this library in production. It is designed to maximize your IDE’s ability to autocomplete and type-check your code. Additionally, it is designed to make it easy to modify the arms and the policies of your bandit as your needs change.
|
Agent for a non-contextual (classic) multi-armed bandit problem. |
|
Agent for a contextual multi-armed bandit problem. |
Contextual agent with a shared learner and a configurable design matrix. |
|
|
Single arm of a multi-armed bandit. |
Policy Functions#
|
Policy object for \(\varepsilon\)-greedy selection. |
Policy object for Thompson sampling. |
|
Policy object for Bayesian upper confidence bound. |
|
|
EXP3.A: Average-based anytime variant of EXP3 for adversarial bandits. |
Pipelines#
Pipelines enable the use of sklearn transformers with Bayesian bandits, providing preprocessing capabilities at different levels.
Create a Pipeline that wraps an Agent or ContextualAgent. |
|
|
Pipeline that implements the Learner protocol with generic input type. |
Arm Featurizers#
Arm featurizers enable shared model bandits by transforming context features based on action tokens. They support vectorized operations for efficient multi-arm processing.
Abstract base class for vectorized arm feature transformation. |
|
Appends arm tokens as a column to context features. |
|
Create ArmFeaturizer from a user-provided function. |
Estimators#
These estimators are the underlying models for the arms in a bandit. They
should be passed to the learner argument of the bandit decorator. Each
of these Bayesian estimators can be converted to a recursive estimator by
passing a learning_rate argument to the constructor that is less than 1.
Each of them implement a decay method that uses the learning_rate to
increase the variance of the prior. This is a type of state-space model that
is useful for restless bandits.
|
Bayesian Generalized Linear Model with Laplace approximation. |
|
Intercept-only Dirichlet-Multinomial classifier. |
|
Intercept-only Gamma-Poisson conjugate regression model. |
|
Bayesian linear regression with known noise variance. |
Bayesian linear regression with unknown noise variance. |
Empirical Bayes Estimators#
These estimators automatically tune their hyperparameters via evidence
maximization (MacKay’s update rules). They are drop-in replacements for their
base estimators and are especially useful when hyperparameters are unknown or
when the environment may be non-stationary (pair with learning_rate < 1
for decay as a defensive default).
Dirichlet-Multinomial classifier with empirical Bayes prior tuning. |
|
Gamma-Poisson regressor with empirical Bayes prior tuning. |
|
Bayesian linear regression with empirical Bayes hyperparameter tuning. |
Utilities#
Laplace approximation via iteratively reweighted least squares (IRLS). |