pub struct KNNImputer { /* private fields */ }
Expand description
K-Nearest Neighbors Imputer for filling missing values
This transformer fills missing values using k-nearest neighbors. For each sample, the missing features are imputed from the nearest neighbors that have a value for that feature.
Implementations§
Source§impl KNNImputer
impl KNNImputer
Sourcepub fn new(
_nneighbors: usize,
metric: DistanceMetric,
weights: WeightingScheme,
missingvalues: f64,
) -> Self
pub fn new( _nneighbors: usize, metric: DistanceMetric, weights: WeightingScheme, missingvalues: f64, ) -> Self
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Creates a KNNImputer with default parameters
Uses 5 neighbors, Euclidean distance, uniform weighting, and NaN as missing values
Sourcepub fn with_n_neighbors(_nneighbors: usize) -> Self
pub fn with_n_neighbors(_nneighbors: usize) -> Self
Creates a KNNImputer with specified number of neighbors and defaults for other parameters
Sourcepub fn with_distance_weighting(_nneighbors: usize) -> Self
pub fn with_distance_weighting(_nneighbors: usize) -> Self
Creates a KNNImputer with distance weighting
Sourcepub fn _nneighbors(&self) -> usize
pub fn _nneighbors(&self) -> usize
Returns the number of neighbors used for imputation
Sourcepub fn metric(&self) -> &DistanceMetric
pub fn metric(&self) -> &DistanceMetric
Returns the distance metric used
Sourcepub fn weights(&self) -> &WeightingScheme
pub fn weights(&self) -> &WeightingScheme
Returns the weighting scheme used
Auto Trait Implementations§
impl Freeze for KNNImputer
impl RefUnwindSafe for KNNImputer
impl Send for KNNImputer
impl Sync for KNNImputer
impl Unpin for KNNImputer
impl UnwindSafe for KNNImputer
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> 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.