Skip to main content

IncrementalLinearRegression

Struct IncrementalLinearRegression 

Source
pub struct IncrementalLinearRegression { /* private fields */ }

Implementations§

Source§

impl IncrementalLinearRegression

Source

pub fn new(schedule: LearningRateSchedule, l2_penalty: f64) -> Self

Examples found in repository?
examples/batch_vs_incremental_comparison.rs (line 25)
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§

Source§

impl Debug for IncrementalLinearRegression

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl IncrementalSupervisedEstimator for IncrementalLinearRegression

Source§

fn partial_fit( &mut self, batch_x: &Array2<f64>, batch_y: &Array1<f64>, ) -> Result<(), IncrementalError>

Source§

fn predict(&self, x: &Array2<f64>) -> Result<Array1<f64>, IncrementalError>

Auto Trait Implementations§

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