pub struct ColumnTransformer<S = Untrained> { /* private fields */ }Expand description
Column Transformer
Apply different transformers to different subsets of features. This allows you to apply different preprocessing steps to different types of features (e.g., numerical vs. categorical).
§Parameters
transformers- List of (name, transformer, columns) tuplesremainder- How to handle remaining columns (‘drop’, ‘passthrough’)sparse_threshold- Threshold for sparse outputn_jobs- Number of parallel jobstransformer_weights- Weights for each transformer
§Examples
ⓘ
use sklears_compose::ColumnTransformer;
use scirs2_core::ndarray::array;
let data = array![[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]];
let mut ct = ColumnTransformer::new();
ct.add_transformer("numeric".to_string(), vec![0, 1]);
ct.add_transformer("categorical".to_string(), vec![2]);Implementations§
Source§impl ColumnTransformer<Untrained>
impl ColumnTransformer<Untrained>
Sourcepub fn builder() -> ColumnTransformerBuilder
pub fn builder() -> ColumnTransformerBuilder
Create a column transformer builder
Sourcepub fn add_transformer(&mut self, name: String, columns: Vec<usize>)
pub fn add_transformer(&mut self, name: String, columns: Vec<usize>)
Add a transformer for specific columns (legacy method)
Sourcepub fn add_transformer_step(
&mut self,
name: String,
transformer: Box<dyn PipelineStep>,
columns: Vec<usize>,
)
pub fn add_transformer_step( &mut self, name: String, transformer: Box<dyn PipelineStep>, columns: Vec<usize>, )
Add a transformer with actual PipelineStep implementation
Sourcepub fn sparse_threshold(self, threshold: f64) -> Self
pub fn sparse_threshold(self, threshold: f64) -> Self
Set the sparse threshold
Sourcepub fn transformer_weights(self, weights: HashMap<String, f64>) -> Self
pub fn transformer_weights(self, weights: HashMap<String, f64>) -> Self
Set transformer weights
Source§impl ColumnTransformer<ColumnTransformerTrained>
impl ColumnTransformer<ColumnTransformerTrained>
Sourcepub fn transform_output(
&self,
x: &ArrayView2<'_, Float>,
) -> SklResult<ColumnTransformerOutput>
pub fn transform_output( &self, x: &ArrayView2<'_, Float>, ) -> SklResult<ColumnTransformerOutput>
Transform data and return appropriate output format (dense or sparse)
Sourcepub fn get_transformer_info(&self) -> Vec<(String, Vec<usize>)>
pub fn get_transformer_info(&self) -> Vec<(String, Vec<usize>)>
Get information about fitted transformers
Sourcepub fn n_features_out(&self) -> usize
pub fn n_features_out(&self) -> usize
Get number of output features
Trait Implementations§
Source§impl<S: Clone> Clone for ColumnTransformer<S>
impl<S: Clone> Clone for ColumnTransformer<S>
Source§fn clone(&self) -> ColumnTransformer<S>
fn clone(&self) -> ColumnTransformer<S>
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<S: Debug> Debug for ColumnTransformer<S>
impl<S: Debug> Debug for ColumnTransformer<S>
Source§impl Default for ColumnTransformer<Untrained>
impl Default for ColumnTransformer<Untrained>
Source§impl Estimator for ColumnTransformer<Untrained>
impl Estimator for ColumnTransformer<Untrained>
Source§type Config = ColumnTransformerConfig
type Config = ColumnTransformerConfig
Configuration type for the estimator
Source§type Error = SklearsError
type Error = SklearsError
Error type for the estimator
Source§fn validate_config(&self) -> Result<(), SklearsError>
fn validate_config(&self) -> Result<(), SklearsError>
Validate estimator configuration with detailed error context
Source§fn check_compatibility(
&self,
n_samples: usize,
n_features: usize,
) -> Result<(), SklearsError>
fn check_compatibility( &self, n_samples: usize, n_features: usize, ) -> Result<(), SklearsError>
Check if estimator is compatible with given data dimensions
Source§fn metadata(&self) -> EstimatorMetadata
fn metadata(&self) -> EstimatorMetadata
Get estimator metadata
Source§impl Fit<ArrayBase<ViewRepr<&f64>, Dim<[usize; 2]>>, Option<&ArrayBase<ViewRepr<&f64>, Dim<[usize; 1]>>>> for ColumnTransformer<Untrained>
impl Fit<ArrayBase<ViewRepr<&f64>, Dim<[usize; 2]>>, Option<&ArrayBase<ViewRepr<&f64>, Dim<[usize; 1]>>>> for ColumnTransformer<Untrained>
Source§type Fitted = ColumnTransformer<ColumnTransformerTrained>
type Fitted = ColumnTransformer<ColumnTransformerTrained>
The fitted model type
Source§fn fit(
self,
x: &ArrayView2<'_, Float>,
y: &Option<&ArrayView1<'_, Float>>,
) -> SklResult<Self::Fitted>
fn fit( self, x: &ArrayView2<'_, Float>, y: &Option<&ArrayView1<'_, Float>>, ) -> SklResult<Self::Fitted>
Fit the model to the provided data with validation
Source§fn fit_with_validation(
self,
x: &X,
y: &Y,
_x_val: Option<&X>,
_y_val: Option<&Y>,
) -> Result<(Self::Fitted, FitMetrics), SklearsError>where
Self: Sized,
fn fit_with_validation(
self,
x: &X,
y: &Y,
_x_val: Option<&X>,
_y_val: Option<&Y>,
) -> Result<(Self::Fitted, FitMetrics), SklearsError>where
Self: Sized,
Fit with custom validation and early stopping
Auto Trait Implementations§
impl<S> Freeze for ColumnTransformer<S>where
S: Freeze,
impl<S> RefUnwindSafe for ColumnTransformer<S>where
S: RefUnwindSafe,
impl<S> Send for ColumnTransformer<S>where
S: Send,
impl<S> Sync for ColumnTransformer<S>where
S: Sync,
impl<S> Unpin for ColumnTransformer<S>where
S: Unpin,
impl<S> UnwindSafe for ColumnTransformer<S>where
S: 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> 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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> StableApi for Twhere
T: Estimator,
impl<T> StableApi for Twhere
T: Estimator,
Source§const STABLE_SINCE: &'static str = "0.1.0"
const STABLE_SINCE: &'static str = "0.1.0"
API version this type was stabilized in
Source§const HAS_EXPERIMENTAL_FEATURES: bool = false
const HAS_EXPERIMENTAL_FEATURES: bool = false
Whether this API has any experimental features