rusty_machine/data/transforms/
mod.rs

1//! The Transforms module
2//!
3//! This module contains the `Transformer` and `Invertible` traits and reexports
4//! the transformers from child modules.
5//!
6//! The `Transformer` trait provides a shared interface for all of the
7//! data preprocessing transformations in rusty-machine.
8//!
9//! The transformers provide preprocessing transformations which are
10//! commonly used in machine learning.
11
12pub mod minmax;
13pub mod standardize;
14pub mod shuffle;
15
16use learning::error;
17
18pub use self::minmax::MinMaxScaler;
19pub use self::shuffle::Shuffler;
20pub use self::standardize::Standardizer;
21
22/// Trait for data transformers
23pub trait Transformer<T> {
24    /// Fit Transformer to input data, and stores the transformation in the Transformer
25    fn fit(&mut self, inputs: &T) -> Result<(), error::Error>;
26    /// Transforms the inputs and stores the transformation in the Transformer
27    fn transform(&mut self, inputs: T) -> Result<T, error::Error>;
28}
29
30/// Trait for invertible data transformers
31pub trait Invertible<T> : Transformer<T> {
32    /// Maps the inputs using the inverse of the fitted transform.
33    fn inv_transform(&self, inputs: T) -> Result<T, error::Error>;
34}