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