pub struct LinUcbFast { /* private fields */ }Available on crate feature
bandit only.Expand description
Preview high-performance LinUCB implementation.
LinUcbFast maintains A^-1 directly with the Sherman-Morrison rank-one
update. Selection and update are O(arm_count * d^2) and O(d^2)
respectively. Its serde state is Preview and is not part of the frozen
LinUcb state schema.
Implementations§
Source§impl LinUcbFast
impl LinUcbFast
Sourcepub fn new(config: LinUcbConfig) -> Result<Self, RillError>
pub fn new(config: LinUcbConfig) -> Result<Self, RillError>
Create an empty fast LinUCB from the same configuration as LinUcb.
Sourcepub fn from_linucb(source: &LinUcb) -> Result<Self, RillError>
pub fn from_linucb(source: &LinUcb) -> Result<Self, RillError>
Convert a stable LinUCB state into the Preview fast representation.
Sourcepub fn inverse_matrix(&self, arm: usize) -> Result<&[Vec<f64>], RillError>
pub fn inverse_matrix(&self, arm: usize) -> Result<&[Vec<f64>], RillError>
Borrow one cached inverse matrix.
Sourcepub const fn state_f64_count(&self) -> usize
pub const fn state_f64_count(&self) -> usize
Number of stored f64 values, excluding allocator metadata.
Sourcepub fn score_arm(
&self,
arm: usize,
context: &[f64],
) -> Result<LinUcbArmScore, RillError>
pub fn score_arm( &self, arm: usize, context: &[f64], ) -> Result<LinUcbArmScore, RillError>
Explain one arm score in O(d^2).
Sourcepub fn score_all(
&self,
context: &[f64],
) -> Result<Vec<LinUcbArmScore>, RillError>
pub fn score_all( &self, context: &[f64], ) -> Result<Vec<LinUcbArmScore>, RillError>
Explain all arm scores in O(arm_count * d^2).
Trait Implementations§
Source§impl Clone for LinUcbFast
impl Clone for LinUcbFast
Source§fn clone(&self) -> LinUcbFast
fn clone(&self) -> LinUcbFast
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl ContextualBandit for LinUcbFast
impl ContextualBandit for LinUcbFast
Source§fn feature_count(&self) -> usize
fn feature_count(&self) -> usize
The number of features in the context vector.
Source§fn samples_seen(&self) -> u64
fn samples_seen(&self) -> u64
How many total samples the bandit has observed.
Source§fn select(
&self,
context: &[f64],
rng: &mut impl Rng,
) -> Result<usize, RillError>
fn select( &self, context: &[f64], rng: &mut impl Rng, ) -> Result<usize, RillError>
Select an arm given the context vector, using the provided RNG. Read more
Source§impl Debug for LinUcbFast
impl Debug for LinUcbFast
Source§impl ValidateState for LinUcbFast
impl ValidateState for LinUcbFast
Auto Trait Implementations§
impl Freeze for LinUcbFast
impl RefUnwindSafe for LinUcbFast
impl Send for LinUcbFast
impl Sync for LinUcbFast
impl Unpin for LinUcbFast
impl UnsafeUnpin for LinUcbFast
impl UnwindSafe for LinUcbFast
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more