pub struct FunctionTransformer { /* private fields */ }Expand description
Apply a user-defined function as a transformer, mirroring
sklearn.preprocessing.FunctionTransformer.
The function is stored as a function pointer.
§Serialization
The function pointers are not serialized. After deserialization call
set_func to restore the function before
calling transform or inverse_transform.
Implementations§
Source§impl FunctionTransformer
impl FunctionTransformer
Sourcepub fn new(func: fn(&Matrix) -> Result<Matrix>) -> Self
pub fn new(func: fn(&Matrix) -> Result<Matrix>) -> Self
Creates a new transformer applying func during transform.
Sourcepub fn with_inverse(self, inv_func: fn(&Matrix) -> Result<Matrix>) -> Self
pub fn with_inverse(self, inv_func: fn(&Matrix) -> Result<Matrix>) -> Self
Sets the inverse function used by inverse_transform.
Trait Implementations§
Source§impl Clone for FunctionTransformer
impl Clone for FunctionTransformer
Source§fn clone(&self) -> FunctionTransformer
fn clone(&self) -> FunctionTransformer
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 FunctionTransformer
impl Debug for FunctionTransformer
Source§impl Default for FunctionTransformer
Default is an identity transformer (no function set).
impl Default for FunctionTransformer
Default is an identity transformer (no function set).
Source§impl<'de> Deserialize<'de> for FunctionTransformer
impl<'de> Deserialize<'de> for FunctionTransformer
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 FunctionTransformer
Source§impl FeatureNames for FunctionTransformer
impl FeatureNames for FunctionTransformer
Source§impl Serialize for FunctionTransformer
impl Serialize for FunctionTransformer
Source§impl Transformer for FunctionTransformer
impl Transformer for FunctionTransformer
Source§fn inverse_transform(&self, x: &Matrix) -> Result<Matrix>
fn inverse_transform(&self, x: &Matrix) -> Result<Matrix>
Reverse the transformation, recovering an approximation of the
original input. Not all transformers support this; the default
implementation returns an error.
Source§fn fit_with_target(&mut self, x: &Matrix, _y: &[f64]) -> Result<()>
fn fit_with_target(&mut self, x: &Matrix, _y: &[f64]) -> Result<()>
Fit the transformer with supervised target values when they are
available. Unsupervised transformers ignore
y by default. Supervised
feature selectors override this method, allowing them to live safely in
a SupervisedPipeline.Auto Trait Implementations§
impl Freeze for FunctionTransformer
impl RefUnwindSafe for FunctionTransformer
impl Send for FunctionTransformer
impl Sync for FunctionTransformer
impl Unpin for FunctionTransformer
impl UnsafeUnpin for FunctionTransformer
impl UnwindSafe for FunctionTransformer
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