Skip to main content

StreamingFitter

Struct StreamingFitter 

Source
pub struct StreamingFitter<M> { /* private fields */ }
Expand description

Feeds batches from an iterator to a PartialFit model.

This adapter collects batches from an iterator and feeds them to a model that implements PartialFit. Multiple epochs can be specified, causing the batches to be replayed multiple times for convergence.

§Type Parameters

Implementations§

Source§

impl<M> StreamingFitter<M>

Source

pub fn new(model: M) -> Self

Create a new StreamingFitter wrapping the given model.

The default number of epochs is 1 (a single pass over the data).

Source

pub fn n_epochs(self, n_epochs: usize) -> Self

Set the number of epochs (passes over the data).

Each epoch replays all batches in order. More epochs can improve convergence for online learning algorithms.

§Panics

This method does not panic, but fit_batches will return early with the initial model state if n_epochs is 0.

Source

pub fn fit_batches<X, Y, I>(self, batches: I) -> Result<M::FitResult, M::Error>
where M: PartialFit<X, Y>, M::FitResult: PartialFit<X, Y, FitResult = M::FitResult, Error = M::Error>, I: IntoIterator<Item = (X, Y)>,

Feed all batches to the model, returning the fitted result.

The batches are collected into a Vec so they can be replayed across multiple epochs. For a single epoch with a non-cloneable iterator, use fit_batches_single_epoch.

§Errors

Returns the first error encountered during any partial_fit call.

Source

pub fn fit_batches_single_epoch<X, Y, I>( self, batches: I, ) -> Result<M::FitResult, M::Error>
where M: PartialFit<X, Y>, M::FitResult: PartialFit<X, Y, FitResult = M::FitResult, Error = M::Error>, I: IntoIterator<Item = (X, Y)>,

Feed batches from a single-pass iterator to the model.

Unlike fit_batches, this method does not collect the batches, so it only supports a single epoch. The n_epochs setting is ignored.

§Errors

Returns the first error encountered during any partial_fit call.

Auto Trait Implementations§

§

impl<M> Freeze for StreamingFitter<M>
where M: Freeze,

§

impl<M> RefUnwindSafe for StreamingFitter<M>
where M: RefUnwindSafe,

§

impl<M> Send for StreamingFitter<M>
where M: Send,

§

impl<M> Sync for StreamingFitter<M>
where M: Sync,

§

impl<M> Unpin for StreamingFitter<M>
where M: Unpin,

§

impl<M> UnsafeUnpin for StreamingFitter<M>
where M: UnsafeUnpin,

§

impl<M> UnwindSafe for StreamingFitter<M>
where M: UnwindSafe,

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<T> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

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

Source§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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

Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,