pub struct IterativeImputer<F> { /* private fields */ }Expand description
An unfitted iterative imputer.
Calling Fit::fit learns the imputation model and returns a
FittedIterativeImputer that can impute missing values in new data.
§Parameters
max_iter— maximum number of imputation rounds (default 10).tol— convergence tolerance on the total change in imputed values (default 1e-3).initial_strategy— strategy for the initial fill (defaultMean).
§Examples
use ferrolearn_preprocess::iterative_imputer::{IterativeImputer, InitialStrategy};
use ferrolearn_core::traits::{Fit, Transform};
use ndarray::array;
let imputer = IterativeImputer::<f64>::new(10, 1e-3, InitialStrategy::Mean);
let x = array![[1.0, 2.0], [3.0, f64::NAN], [f64::NAN, 6.0]];
let fitted = imputer.fit(&x, &()).unwrap();
let out = fitted.transform(&x).unwrap();
assert!(!out[[1, 1]].is_nan());
assert!(!out[[2, 0]].is_nan());Implementations§
Source§impl<F: Float + Send + Sync + 'static> IterativeImputer<F>
impl<F: Float + Send + Sync + 'static> IterativeImputer<F>
Sourcepub fn new(max_iter: usize, tol: F, initial_strategy: InitialStrategy) -> Self
pub fn new(max_iter: usize, tol: F, initial_strategy: InitialStrategy) -> Self
Create a new IterativeImputer with the given parameters.
Sourcepub fn initial_strategy(&self) -> InitialStrategy
pub fn initial_strategy(&self) -> InitialStrategy
Return the initial imputation strategy.
Trait Implementations§
Source§impl<F: Clone> Clone for IterativeImputer<F>
impl<F: Clone> Clone for IterativeImputer<F>
Source§fn clone(&self) -> IterativeImputer<F>
fn clone(&self) -> IterativeImputer<F>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<F: Debug> Debug for IterativeImputer<F>
impl<F: Debug> Debug for IterativeImputer<F>
Source§impl<F: Float + Send + Sync + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ()> for IterativeImputer<F>
impl<F: Float + Send + Sync + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ()> for IterativeImputer<F>
Source§fn fit(
&self,
x: &Array2<F>,
_y: &(),
) -> Result<FittedIterativeImputer<F>, FerroError>
fn fit( &self, x: &Array2<F>, _y: &(), ) -> Result<FittedIterativeImputer<F>, FerroError>
Fit the iterative imputer by performing round-robin Ridge regression.
§Errors
FerroError::InsufficientSamplesif the input has zero rows.FerroError::InvalidParameterifmax_iteris zero.
Source§type Fitted = FittedIterativeImputer<F>
type Fitted = FittedIterativeImputer<F>
The fitted model type returned by
fit.Source§type Error = FerroError
type Error = FerroError
The error type returned by
fit.Source§impl<F: Float + Send + Sync + 'static> FitTransform<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>> for IterativeImputer<F>
impl<F: Float + Send + Sync + 'static> FitTransform<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>> for IterativeImputer<F>
Source§fn fit_transform(&self, x: &Array2<F>) -> Result<Array2<F>, FerroError>
fn fit_transform(&self, x: &Array2<F>) -> Result<Array2<F>, FerroError>
Fit the imputer on x and return the imputed output in one step.
§Errors
Returns an error if fitting fails.
Source§type FitError = FerroError
type FitError = FerroError
The error type for the combined fit-transform operation.
Auto Trait Implementations§
impl<F> Freeze for IterativeImputer<F>where
F: Freeze,
impl<F> RefUnwindSafe for IterativeImputer<F>where
F: RefUnwindSafe,
impl<F> Send for IterativeImputer<F>where
F: Send,
impl<F> Sync for IterativeImputer<F>where
F: Sync,
impl<F> Unpin for IterativeImputer<F>where
F: Unpin,
impl<F> UnsafeUnpin for IterativeImputer<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for IterativeImputer<F>where
F: UnwindSafe,
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> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.