Transformer

Trait Transformer 

Source
pub trait Transformer {
    // Required methods
    fn fit(&mut self, x: &Matrix<f32>) -> Result<()>;
    fn transform(&self, x: &Matrix<f32>) -> Result<Matrix<f32>>;

    // Provided method
    fn fit_transform(&mut self, x: &Matrix<f32>) -> Result<Matrix<f32>> { ... }
}
Expand description

Trait for data transformers (scalers, encoders, etc.).

This trait defines the interface for preprocessing transformers. Implementations include scalers, encoders, and feature transformers.

§Future Usage

let mut scaler = StandardScaler::new();
let x_scaled = scaler.fit_transform(&x)?;
let x_test_scaled = scaler.transform(&x_test)?;

Required Methods§

Source

fn fit(&mut self, x: &Matrix<f32>) -> Result<()>

Fits the transformer to data.

§Errors

Returns an error if fitting fails.

Source

fn transform(&self, x: &Matrix<f32>) -> Result<Matrix<f32>>

Transforms data using fitted parameters.

§Errors

Returns an error if transformer is not fitted.

Provided Methods§

Source

fn fit_transform(&mut self, x: &Matrix<f32>) -> Result<Matrix<f32>>

Fits and transforms in one step.

§Errors

Returns an error if fitting fails.

Implementors§