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(
n_neighbors: usize,
metric: DistanceMetric,
weights: WeightingScheme,
missing_values: f64,
) -> Self
pub fn new( n_neighbors: usize, metric: DistanceMetric, weights: WeightingScheme, missing_values: 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(n_neighbors: usize) -> Self
pub fn with_n_neighbors(n_neighbors: usize) -> Self
Creates a KNNImputer with specified number of neighbors and defaults for other parameters
Sourcepub fn with_distance_weighting(n_neighbors: usize) -> Self
pub fn with_distance_weighting(n_neighbors: usize) -> Self
Creates a KNNImputer with distance weighting
Sourcepub fn n_neighbors(&self) -> usize
pub fn n_neighbors(&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 more