PipelineTransformer
Module: strata.base • Kind: struct • Traits: Copyable, Movable, Transformer
Source: strata/base/pipeline.mojo
struct PipelineTransformer[*Transformers: Transformer](Copyable, Movable, Transformer)from strata.base import PipelineTransformerChains an arbitrary variadic sequence of data transformers into a single composite transformer.
Transforms data sequentially across steps:
Parameters (Compile-Time)
Section titled “Parameters (Compile-Time)”| Parameter | Description |
|---|---|
Transformers |
Variadic pack of Transformer types. |
Constructors
Section titled “Constructors”def __init__(out self, transformers: Tuple[*Self.Transformers])Initializes a PipelineTransformer with a variadic tuple of transformer steps.
| Argument | Type | Description |
|---|---|---|
transformers |
Tuple[*Self.Transformers] |
Tuple of transformer instances satisfying the Transformer trait. |
Attributes
Section titled “Attributes”| Attribute | Description |
|---|---|
transformers |
Variadic tuple of transformer instances. |
is_fitted |
Boolean flag indicating if transformer steps are fitted. |
Methods Overview
Section titled “Methods Overview”| Method | Description |
|---|---|
PipelineTransformer.fit() |
Fits all transformers sequentially. |
PipelineTransformer.transform() |
Sequentially applies transformations across all pipeline steps. |
PipelineTransformer.fit_transform() |
Fits all transformers and returns the final transformed output representation. |
Method Details
Section titled “Method Details”PipelineTransformer.fit()
Section titled “PipelineTransformer.fit()”def fit[in_dtype: DType](mut self, X: Matrix[in_dtype])
def fit[feat_dtype: DType, target_dtype: DType]( mut self, dataset: Dataset[feat_dtype, target_dtype],)Overload Note: This method accepts either a standard
X: Matrixor a unifieddataset: Datasetcontainer.
Fits all transformers sequentially.
| Parameter | Type | Description |
|---|---|---|
X |
Matrix[in_dtype] |
Input feature matrix of shape . |
dataset |
Dataset[feat_dtype, target_dtype] |
Dataset container holding feature matrix. (Can be provided alternatively in place of X) |
PipelineTransformer.transform()
Section titled “PipelineTransformer.transform()”def transform[in_dtype: DType]( self, X: Matrix[in_dtype],) -> Matrix[in_dtype]
def transform[feat_dtype: DType, target_dtype: DType]( self, dataset: Dataset[feat_dtype, target_dtype],) -> Dataset[feat_dtype, target_dtype]Overload Note: This method accepts either a standard
X: Matrixor a unifieddataset: Datasetcontainer.
Sequentially applies transformations across all pipeline steps.
| Parameter | Type | Description |
|---|---|---|
X |
Matrix[in_dtype] |
Input feature matrix of shape . |
dataset |
Dataset[feat_dtype, target_dtype] |
Dataset container holding feature matrix. (Can be provided alternatively in place of X) |
Returns: Matrix[in_dtype] — Matrix[in_dtype]: Transformed output matrix.
PipelineTransformer.fit_transform()
Section titled “PipelineTransformer.fit_transform()”def fit_transform[in_dtype: DType]( mut self, X: Matrix[in_dtype],) -> Matrix[in_dtype]
def fit_transform[feat_dtype: DType, target_dtype: DType]( mut self, dataset: Dataset[feat_dtype, target_dtype],) -> Dataset[feat_dtype, target_dtype]Overload Note: This method accepts either a standard
X: Matrixor a unifieddataset: Datasetcontainer.
Fits all transformers and returns the final transformed output representation.
| Parameter | Type | Description |
|---|---|---|
X |
Matrix[in_dtype] |
Input feature matrix of shape . |
dataset |
Dataset[feat_dtype, target_dtype] |
Dataset container holding feature matrix. (Can be provided alternatively in place of X) |
Returns: Matrix[in_dtype] — Matrix[in_dtype]: Final transformed output matrix.
Section titled “Returns: Matrix[in_dtype] — Matrix[in_dtype]: Final transformed output matrix.”Example
Section titled “Example”from strata import StandardScaler, RobustScaler, PCA, PipelineTransformer
var pipe = PipelineTransformer( (StandardScaler(), RobustScaler(), PCA(n_components=2)))