UCBBanditAgent<T>

Models & Types · AiDotNet.ReinforcementLearning.Agents.Bandits

Upper Confidence Bound (UCB) Multi-Armed Bandit agent.

Inheritance: ReinforcementLearningAgentBase<T> → UCBBanditAgent<T>

For Beginners

UCB balances exploration and exploitation mathematically. For each action, it calculates an optimistic estimate: average reward + confidence bonus. The confidence bonus is larger for actions tried fewer times, ensuring under-explored actions get a fair chance. Think of it as “optimism in the face of uncertainty” - if you are not sure about an action, assume it could be great until proven otherwise. No epsilon parameter needed; exploration happens automatically.

Example

// Create a UCB bandit agent for optimistic exploration
var options = new UCBBanditOptions<double> { NumArms = 10, ExplorationParameter = 2.0 };
var agent = new UCBBanditAgent<double>(options);
            
// Select an arm using upper confidence bound
var state = new Vector<double>(new double[] { 1.0 });
var action = agent.SelectAction(state);

Constructors

Constructor Summary
UCBBanditAgent()
UCBBanditAgent(UCBBanditOptions<T> options)

Properties

Property Summary
int FeatureCount { get; }

Methods

Method Summary
Dictionary<string, T> GetMetrics()
ModelMetadata<T> GetModelMetadata()
T Train()
Task TrainAsync()
Task<Vector<T>> PredictAsync(Vector<T> input)
Vector<T> Predict(Vector<T> input)
Vector<T> SelectAction(Vector<T> state, bool training)
byte[] Serialize() Auto-generated common model serialization surface.
void Deserialize(byte[] data) Auto-generated common model deserialization surface.
void LoadModel(string filepath)
void ResetEpisode()
void SaveModel(string filepath)
void StoreExperience(Vector<T> state, Vector<T> action, T reward, Vector<T> nextState, bool done)