Skip to main content

MonitoredEstimator

Struct MonitoredEstimator 

Source
pub struct MonitoredEstimator<'a, E: IncrementalSupervisedEstimator, F>
where F: FnMut(BatchStats),
{ pub estimator: &'a mut E, pub callback: F, pub step_counter: usize, }
Expand description

A wrapper that attaches a monitoring callback to any supervised incremental model.

Fields§

§estimator: &'a mut E§callback: F§step_counter: usize

Implementations§

Source§

impl<'a, E: IncrementalSupervisedEstimator, F> MonitoredEstimator<'a, E, F>
where F: FnMut(BatchStats),

Source

pub fn new(estimator: &'a mut E, callback: F) -> Self

Examples found in repository?
examples/batch_vs_incremental_comparison.rs (lines 30-32)
7fn main() {
8    println!("===Batch vs. Incremental Convergence Comparison ===");
9
10    let x = Array2::from_shape_vec(
11        (8, 2),
12        vec![
13            1.0, 2.0, 2.0, 1.0, 3.0, 4.0, 5.0, 2.0, 4.0, 1.0, 6.0, 3.0, 7.0, 2.0, 8.0, 5.0,
14        ],
15    )
16    .unwrap();
17    let y = array![-3.5, 1.5, -5.5, 4.5, 5.5, 3.5, 8.5, 1.5];
18
19    let schedule = LearningRateSchedule::InverseScaling {
20        initial_rate: 0.05,
21        decay: 0.01,
22        power: 0.5,
23    };
24
25    let mut model = IncrementalLinearRegression::new(schedule, 0.01);
26
27    println!("Step | Mini-Batch MSE Loss");
28    println!("--------------------------");
29
30    let mut monitored = MonitoredEstimator::new(&mut model, |stats: BatchStats| {
31        println!("{:4} | {:.6}", stats.step, stats.loss);
32    });
33
34    // Run multiple incremental epoch passes over data[cite: 1]
35    for _ in 0..10 {
36        monitored.partial_fit(&x, &y).unwrap();
37    }
38}

Trait Implementations§

Auto Trait Implementations§

§

impl<'a, E, F> !UnwindSafe for MonitoredEstimator<'a, E, F>

§

impl<'a, E, F> Freeze for MonitoredEstimator<'a, E, F>
where F: Freeze,

§

impl<'a, E, F> RefUnwindSafe for MonitoredEstimator<'a, E, F>

§

impl<'a, E, F> Send for MonitoredEstimator<'a, E, F>
where F: Send, E: Send,

§

impl<'a, E, F> Sync for MonitoredEstimator<'a, E, F>
where F: Sync, E: Sync,

§

impl<'a, E, F> Unpin for MonitoredEstimator<'a, E, F>
where F: Unpin,

§

impl<'a, E, F> UnsafeUnpin for MonitoredEstimator<'a, E, F>
where F: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V