pub struct Ftrl { /* private fields */ }Expand description
Follow the Regularized Leader — Proximal (McMahan et al. 2013).
FTRL-Proximal maintains per-feature adaptive learning rates and supports L1 + L2 regularization. L1 induces sparsity: features with |z_i| ≤ l1 are zeroed out, which makes FTRL popular for large-scale sparse models.
Update equations (per coordinate i):
g_i = gradient of logistic loss on this sample
z_i += g_i − (√(n_i + g_i²) − √n_i) / α · w_i
n_i += g_i²
if |z_i| ≤ l1:
w_i = 0
else:
w_i = −(z_i − sign(z_i)·l1) / ((β + √n_i) / α + l2)Implementations§
Source§impl Ftrl
impl Ftrl
Sourcepub fn new(n_features: usize) -> Self
pub fn new(n_features: usize) -> Self
Create a new FTRL learner with n_features dimensions.
Defaults: α = 0.1, β = 1.0, l1 = 0.0, l2 = 0.0.
Sourcepub fn with_alpha(self, alpha: f64) -> Self
pub fn with_alpha(self, alpha: f64) -> Self
Set the learning rate α.
Sourcepub fn with_l1_l2(self, l1: f64, l2: f64) -> Self
pub fn with_l1_l2(self, l1: f64, l2: f64) -> Self
Set L1 and L2 regularization coefficients.
Sourcepub fn stats(&self) -> &OnlineStats
pub fn stats(&self) -> &OnlineStats
Reference to running statistics.
Trait Implementations§
Source§impl OnlineLearner for Ftrl
impl OnlineLearner for Ftrl
Source§fn update(
&mut self,
features: &[f64],
label: f64,
) -> Result<OnlineUpdateResult, OnlineError>
fn update( &mut self, features: &[f64], label: f64, ) -> Result<OnlineUpdateResult, OnlineError>
Update model on a single (features, label) pair. Returns update stats.
Auto Trait Implementations§
impl Freeze for Ftrl
impl RefUnwindSafe for Ftrl
impl Send for Ftrl
impl Sync for Ftrl
impl Unpin for Ftrl
impl UnsafeUnpin for Ftrl
impl UnwindSafe for Ftrl
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more