Skip to content

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 PipelineTransformer

Chains an arbitrary variadic sequence of data transformers into a single composite transformer.

Transforms data sequentially across steps:

X→T1(X)→T2(T1(X))→⋯→TN(… )X \to T_1(X) \to T_2(T_1(X)) \to \dots \to T_N(\dots)
Parameter Description
Transformers Variadic pack of Transformer types.

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.

Attribute Description
transformers Variadic tuple of transformer instances.
is_fitted Boolean flag indicating if transformer steps are fitted.

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.

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: Matrix or a unified dataset: Dataset container.

Fits all transformers sequentially.

Parameter Type Description
X Matrix[in_dtype] Input feature matrix of shape (N,D)(N, D).
dataset Dataset[feat_dtype, target_dtype] Dataset container holding feature matrix. (Can be provided alternatively in place of X)

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: Matrix or a unified dataset: Dataset container.

Sequentially applies transformations across all pipeline steps.

Parameter Type Description
X Matrix[in_dtype] Input feature matrix of shape (N,D)(N, D).
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.


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: Matrix or a unified dataset: Dataset container.

Fits all transformers and returns the final transformed output representation.

Parameter Type Description
X Matrix[in_dtype] Input feature matrix of shape (N,D)(N, D).
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.”
from strata import StandardScaler, RobustScaler, PCA, PipelineTransformer
var pipe = PipelineTransformer(
(StandardScaler(), RobustScaler(), PCA(n_components=2))
)