pub struct LabelEncoder { /* private fields */ }Expand description
Encode target labels with values between 0 and n_classes - 1, mirroring
sklearn.preprocessing.LabelEncoder. Classes are sorted (sklearn default).
Operates on Vec<String> (1-D) input.
Implementations§
Source§impl LabelEncoder
impl LabelEncoder
Sourcepub fn handle_unknown(self, val: LabelHandleUnknown) -> Self
pub fn handle_unknown(self, val: LabelHandleUnknown) -> Self
Set how unknown labels are handled during transform.
Sourcepub fn fit<I, S>(&mut self, labels: I) -> Result<()>
pub fn fit<I, S>(&mut self, labels: I) -> Result<()>
Learns the sorted class labels from the input.
Sourcepub fn transform<I>(&self, labels: I) -> Result<Vec<usize>>
pub fn transform<I>(&self, labels: I) -> Result<Vec<usize>>
Maps each label to its class index.
Sourcepub fn fit_transform<I, S>(&mut self, labels: I) -> Result<Vec<usize>>
pub fn fit_transform<I, S>(&mut self, labels: I) -> Result<Vec<usize>>
Fits the encoder and transforms the labels in one step.
Trait Implementations§
Source§impl Clone for LabelEncoder
impl Clone for LabelEncoder
Source§fn clone(&self) -> LabelEncoder
fn clone(&self) -> LabelEncoder
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LabelEncoder
impl Debug for LabelEncoder
Source§impl Default for LabelEncoder
impl Default for LabelEncoder
Source§impl<'de> Deserialize<'de> for LabelEncoder
impl<'de> Deserialize<'de> for LabelEncoder
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Estimator for LabelEncoder
Auto Trait Implementations§
impl Freeze for LabelEncoder
impl RefUnwindSafe for LabelEncoder
impl Send for LabelEncoder
impl Sync for LabelEncoder
impl Unpin for LabelEncoder
impl UnsafeUnpin for LabelEncoder
impl UnwindSafe for LabelEncoder
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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