Skip to main content

LabelTransformer

Trait LabelTransformer 

Source
pub trait LabelTransformer: Estimator {
    // Required methods
    fn name(&self) -> &'static str;
    fn fit(&mut self, x: &[String]) -> Result<()>;
    fn transform(&self, x: &[String]) -> Result<Vec<usize>>;
    fn inverse_transform(&self, x: &[usize]) -> Result<Vec<String>>;
    fn is_fitted(&self) -> bool;

    // Provided method
    fn fit_transform(&mut self, x: &[String]) -> Result<Vec<usize>> { ... }
}
Expand description

Trait for 1-D label encoders that map &[String] to Vec<usize>.

Used to encode target labels for supervised learning.

Required Methods§

Source

fn name(&self) -> &'static str

Human-readable name of the transformer.

Source

fn fit(&mut self, x: &[String]) -> Result<()>

Fit on label data, learning the unique sorted classes.

Source

fn transform(&self, x: &[String]) -> Result<Vec<usize>>

Transform labels to integer indices.

Source

fn inverse_transform(&self, x: &[usize]) -> Result<Vec<String>>

Reverses the transformation: indices back to strings.

Source

fn is_fitted(&self) -> bool

Whether the transformer has been fitted.

Provided Methods§

Source

fn fit_transform(&mut self, x: &[String]) -> Result<Vec<usize>>

Convenience: fit then transform.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§