pub struct PowerTransformer<F> { /* private fields */ }Expand description
An unfitted power transformer using the Yeo-Johnson method.
Calling Fit::fit estimates an optimal lambda per feature (via grid
search over a range of lambda values) and returns a FittedPowerTransformer
that can transform new data.
§Examples
use ferrolearn_preprocess::PowerTransformer;
use ferrolearn_core::traits::{Fit, Transform};
use ndarray::array;
let pt = PowerTransformer::<f64>::new();
let x = array![[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]];
let fitted = pt.fit(&x, &()).unwrap();
let transformed = fitted.transform(&x).unwrap();Implementations§
Source§impl<F: Float + Send + Sync + 'static> PowerTransformer<F>
impl<F: Float + Send + Sync + 'static> PowerTransformer<F>
Sourcepub fn without_standardize() -> Self
pub fn without_standardize() -> Self
Create a new PowerTransformer with standardization disabled.
Sourcepub fn standardize(&self) -> bool
pub fn standardize(&self) -> bool
Whether standardization is enabled.
Trait Implementations§
Source§impl<F: Clone> Clone for PowerTransformer<F>
impl<F: Clone> Clone for PowerTransformer<F>
Source§fn clone(&self) -> PowerTransformer<F>
fn clone(&self) -> PowerTransformer<F>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<F: Debug> Debug for PowerTransformer<F>
impl<F: Debug> Debug for PowerTransformer<F>
Source§impl<F: Float + Send + Sync + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ()> for PowerTransformer<F>
impl<F: Float + Send + Sync + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ()> for PowerTransformer<F>
Source§fn fit(
&self,
x: &Array2<F>,
_y: &(),
) -> Result<FittedPowerTransformer<F>, FerroError>
fn fit( &self, x: &Array2<F>, _y: &(), ) -> Result<FittedPowerTransformer<F>, FerroError>
Fit the transformer by estimating the optimal lambda per feature.
Uses Brent’s method to minimize the negative log-likelihood on the
interval [-3, 3], selecting the lambda that maximises the
log-likelihood of the Yeo-Johnson transformed column following a
normal distribution.
§Errors
Returns FerroError::InsufficientSamples if the input has zero rows.
Source§type Fitted = FittedPowerTransformer<F>
type Fitted = FittedPowerTransformer<F>
fit.Source§type Error = FerroError
type Error = FerroError
fit.Source§impl<F: Float + Send + Sync + 'static> FitTransform<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>> for PowerTransformer<F>
impl<F: Float + Send + Sync + 'static> FitTransform<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>> for PowerTransformer<F>
Source§fn fit_transform(&self, x: &Array2<F>) -> Result<Array2<F>, FerroError>
fn fit_transform(&self, x: &Array2<F>) -> Result<Array2<F>, FerroError>
Fit the transformer on x and return the transformed output in one step.
§Errors
Returns an error if fitting fails.
Source§type FitError = FerroError
type FitError = FerroError
Source§impl<F: Float + Send + Sync + 'static> PipelineTransformer<F> for PowerTransformer<F>
impl<F: Float + Send + Sync + 'static> PipelineTransformer<F> for PowerTransformer<F>
Source§fn fit_pipeline(
&self,
x: &Array2<F>,
_y: &Array1<F>,
) -> Result<Box<dyn FittedPipelineTransformer<F>>, FerroError>
fn fit_pipeline( &self, x: &Array2<F>, _y: &Array1<F>, ) -> Result<Box<dyn FittedPipelineTransformer<F>>, FerroError>
Auto Trait Implementations§
impl<F> Freeze for PowerTransformer<F>
impl<F> RefUnwindSafe for PowerTransformer<F>where
F: RefUnwindSafe,
impl<F> Send for PowerTransformer<F>where
F: Send,
impl<F> Sync for PowerTransformer<F>where
F: Sync,
impl<F> Unpin for PowerTransformer<F>where
F: Unpin,
impl<F> UnsafeUnpin for PowerTransformer<F>
impl<F> UnwindSafe for PowerTransformer<F>where
F: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
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>
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>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.