pub struct ColumnTransformer { /* private fields */ }Expand description
Apply different transformers to different columns of a dataset, mirroring
sklearn.compose.ColumnTransformer.
Output columns are ordered as: each spec in insertion order (categorical
specs expand to their one-hot columns), followed by passthrough numeric
columns (when remainder = Passthrough).
Implementations§
Source§impl ColumnTransformer
impl ColumnTransformer
Sourcepub fn add_numeric<S>(
self,
name: S,
columns: Vec<usize>,
transformer: TransformerKind,
) -> Self
pub fn add_numeric<S>( self, name: S, columns: Vec<usize>, transformer: TransformerKind, ) -> Self
Adds a numeric block applying transformer to columns.
Sourcepub fn add_categorical<S>(
self,
name: S,
columns: Vec<usize>,
encoder: CategoricalTransformerKind,
) -> Self
pub fn add_categorical<S>( self, name: S, columns: Vec<usize>, encoder: CategoricalTransformerKind, ) -> Self
Adds a categorical block encoding columns with a categorical
CategoricalTransformerKind wrapper.
Sourcepub fn add_target<S>(
self,
name: S,
columns: Vec<usize>,
encoder: TargetTransformerKind,
) -> Self
pub fn add_target<S>( self, name: S, columns: Vec<usize>, encoder: TargetTransformerKind, ) -> Self
Adds a target (supervised) category encoding block, using encoder on
columns. This spec requires target values during fit; call
fit_with_target instead of fit.
Sourcepub fn fit(&mut self, table: &Table) -> Result<()>
pub fn fit(&mut self, table: &Table) -> Result<()>
Fits the column specs and remainder encoders to the table.
Returns an error if any ColumnSpec::Target specs are present,
because they require target values. Use
fit_with_target instead.
Sourcepub fn fit_transform_with_target(
&mut self,
table: &Table,
y: &[f64],
) -> Result<Matrix>
pub fn fit_transform_with_target( &mut self, table: &Table, y: &[f64], ) -> Result<Matrix>
Fits the column specs and Target specs using the provided target
values, then returns the transformed result.
Non-target specs are fitted via fit (or re-fitted if
already fitted). Target specs are fitted with y.
Sourcepub fn fit_with_target(&mut self, table: &Table, y: &[f64]) -> Result<()>
pub fn fit_with_target(&mut self, table: &Table, y: &[f64]) -> Result<()>
Fits the column specs and Target specs using the provided target
values.
Non-target specs are fitted via fit. Target specs are
additionally fitted with the given target values.
Sourcepub fn transform(&self, table: &Table) -> Result<Matrix>
pub fn transform(&self, table: &Table) -> Result<Matrix>
Transforms the table by applying each fitted spec and concatenating results.
Sourcepub fn fit_transform(&mut self, table: &Table) -> Result<Matrix>
pub fn fit_transform(&mut self, table: &Table) -> Result<Matrix>
Fits the transformer to the table and returns the transformed result.
Sourcepub fn transform_to_table(&self, table: &Table) -> Result<Output>
pub fn transform_to_table(&self, table: &Table) -> Result<Output>
Transforms the table and returns an crate::Output that preserves the
separation between numeric and categorical columns.
Unlike transform, remainder categorical columns are
passed through as strings instead of being one-hot encoded. This
is useful when you want to chain further categorical processing.
Sourcepub fn fit_transform_to_table(&mut self, table: &Table) -> Result<Output>
pub fn fit_transform_to_table(&mut self, table: &Table) -> Result<Output>
Fits then transforms the table, returning an crate::Output that preserves
numeric / categorical column separation.
Trait Implementations§
Source§impl Clone for ColumnTransformer
impl Clone for ColumnTransformer
Source§fn clone(&self) -> ColumnTransformer
fn clone(&self) -> ColumnTransformer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ColumnTransformer
impl Debug for ColumnTransformer
Source§impl Default for ColumnTransformer
impl Default for ColumnTransformer
Source§impl<'de> Deserialize<'de> for ColumnTransformer
impl<'de> Deserialize<'de> for ColumnTransformer
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>,
Source§impl FeatureNames for ColumnTransformer
impl FeatureNames for ColumnTransformer
Auto Trait Implementations§
impl Freeze for ColumnTransformer
impl RefUnwindSafe for ColumnTransformer
impl Send for ColumnTransformer
impl Sync for ColumnTransformer
impl Unpin for ColumnTransformer
impl UnsafeUnpin for ColumnTransformer
impl UnwindSafe for ColumnTransformer
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,
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>
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 more