pub struct QuantileTransformer<F> { /* private fields */ }Expand description
An unfitted quantile transformer.
Calling Fit::fit computes the quantiles for each feature and returns a
FittedQuantileTransformer.
§Parameters
n_quantiles— number of quantile reference points (default 1000).output_distribution— target distribution (defaultUniform).subsample— maximum number of samples used to compute quantiles (default 100_000; set to 0 to use all samples).
§Examples
use ferrolearn_preprocess::quantile_transformer::{QuantileTransformer, OutputDistribution};
use ferrolearn_core::traits::{Fit, Transform};
use ndarray::array;
let qt = QuantileTransformer::<f64>::new(100, OutputDistribution::Uniform, 0);
let x = array![[1.0], [2.0], [3.0], [4.0], [5.0]];
let fitted = qt.fit(&x, &()).unwrap();
let out = fitted.transform(&x).unwrap();
// Values should be in [0, 1]
for v in out.iter() {
assert!(*v >= 0.0 && *v <= 1.0);
}Implementations§
Source§impl<F: Float + Send + Sync + 'static> QuantileTransformer<F>
impl<F: Float + Send + Sync + 'static> QuantileTransformer<F>
Sourcepub fn new(
n_quantiles: usize,
output_distribution: OutputDistribution,
subsample: usize,
) -> Self
pub fn new( n_quantiles: usize, output_distribution: OutputDistribution, subsample: usize, ) -> Self
Create a new QuantileTransformer.
Sourcepub fn n_quantiles(&self) -> usize
pub fn n_quantiles(&self) -> usize
Return the number of quantiles.
Sourcepub fn output_distribution(&self) -> OutputDistribution
pub fn output_distribution(&self) -> OutputDistribution
Return the target output distribution.
Trait Implementations§
Source§impl<F: Clone> Clone for QuantileTransformer<F>
impl<F: Clone> Clone for QuantileTransformer<F>
Source§fn clone(&self) -> QuantileTransformer<F>
fn clone(&self) -> QuantileTransformer<F>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<F: Debug> Debug for QuantileTransformer<F>
impl<F: Debug> Debug for QuantileTransformer<F>
Source§impl<F: Float + Send + Sync + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ()> for QuantileTransformer<F>
impl<F: Float + Send + Sync + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ()> for QuantileTransformer<F>
Source§fn fit(
&self,
x: &Array2<F>,
_y: &(),
) -> Result<FittedQuantileTransformer<F>, FerroError>
fn fit( &self, x: &Array2<F>, _y: &(), ) -> Result<FittedQuantileTransformer<F>, FerroError>
Fit by computing per-feature quantile reference values.
§Errors
FerroError::InsufficientSamplesif the input has fewer than 2 rows.FerroError::InvalidParameterifn_quantilesis less than 2.
Source§type Fitted = FittedQuantileTransformer<F>
type Fitted = FittedQuantileTransformer<F>
The fitted model type returned by
fit.Source§type Error = FerroError
type Error = FerroError
The error type returned by
fit.Source§impl<F: Float + Send + Sync + 'static> FitTransform<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>> for QuantileTransformer<F>
impl<F: Float + Send + Sync + 'static> FitTransform<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>> for QuantileTransformer<F>
Source§fn fit_transform(&self, x: &Array2<F>) -> Result<Array2<F>, FerroError>
fn fit_transform(&self, x: &Array2<F>) -> Result<Array2<F>, FerroError>
Source§type FitError = FerroError
type FitError = FerroError
The error type for the combined fit-transform operation.
Auto Trait Implementations§
impl<F> Freeze for QuantileTransformer<F>
impl<F> RefUnwindSafe for QuantileTransformer<F>where
F: RefUnwindSafe,
impl<F> Send for QuantileTransformer<F>where
F: Send,
impl<F> Sync for QuantileTransformer<F>where
F: Sync,
impl<F> Unpin for QuantileTransformer<F>where
F: Unpin,
impl<F> UnsafeUnpin for QuantileTransformer<F>
impl<F> UnwindSafe for QuantileTransformer<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
Mutably borrows from an owned value. Read more
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>
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