Crate trashpanda

Source
Expand description

TrashPanda: A Rust library for contextual multi-armed bandits.

This library provides efficient implementations of various multi-armed bandit algorithms, inspired by the Python MABWiser library but designed with Rust’s performance and safety guarantees in mind.

§Quick Start

use trashpanda::Bandit;
use trashpanda::policies::EpsilonGreedy;

// Create a bandit with three arms directly
let mut bandit = Bandit::new(
    vec!["red", "blue", "green"],
    EpsilonGreedy::new(0.1)
).unwrap();

// Or use convenience constructor
let mut bandit = Bandit::epsilon_greedy(
    vec!["red", "blue", "green"],
    0.1
).unwrap();

// Train on historical data
let decisions = vec!["red", "blue", "red"];
let rewards = vec![1.0, 0.5, 0.8];
// bandit.fit(&decisions, &rewards).unwrap();

// Make a prediction
// let mut rng = rand::thread_rng();
// let choice = bandit.predict(&mut rng).unwrap();

Modules§

policies
prelude
Prelude module for convenient imports.

Structs§

Bandit
A multi-armed bandit with a specific policy
IndexSet
A hash set where the iteration order of the values is independent of their hash values.

Enums§

BanditError
Errors that can occur during bandit operations.

Type Aliases§

Result
Result type alias for bandit operations.