PreprocessingPipeline<T, TInput, TOutput>
Models & Types · AiDotNet.Preprocessing
Chains multiple data transformers into a sequential pipeline.
Implements: IDataTransformer<T, TInput, TOutput>
For Beginners
Think of a pipeline as a series of steps. For example:
- First, fill in missing values (SimpleImputer)
- Then, scale the data (StandardScaler)
- Finally, create polynomial features (PolynomialFeatures)
The pipeline ensures all these steps happen in the right order.
How It Works
A preprocessing pipeline applies transformers in sequence, passing the output of each transformer as input to the next. This enables composable preprocessing workflows similar to sklearn’s Pipeline.
Constructors
| Constructor | Summary |
|---|---|
PreprocessingPipeline() |
Creates a new empty preprocessing pipeline. |
Properties
| Property | Summary |
|---|---|
IReadOnlyList<ValueTuple<string, IDataTransformer<T, TInput, TInput>>> Steps { get; } |
Gets the named steps in the pipeline. |
bool IsFitted { get; } |
Gets whether this pipeline has been fitted to data. |
bool SupportsInverseTransform { get; } |
Gets whether this pipeline supports inverse transformation. |
int Count { get; } |
Gets the number of steps in the pipeline. |
int[] ColumnIndices { get; } |
Gets the column indices this transformer operates on (null for pipelines). |
Methods
| Method | Summary |
|---|---|
IDataTransformer<T, TInput, TInput> GetStep(string name) |
Gets a transformer step by name. |
PreprocessingPipeline<T, TInput, TOutput> Add(IDataTransformer<T, TInput, TInput> transformer) |
Adds a transformer step to the pipeline. |
PreprocessingPipeline<T, TInput, TOutput> Add(string name, IDataTransformer<T, TInput, TInput> transformer) |
Adds a named transformer step to the pipeline. |
PreprocessingPipeline<T, TInput, TOutput> Clone() |
Creates a clone of this pipeline without fitted state. |
PreprocessingPipeline<T, TInput, TOutput> SetFinalTransformer(IDataTransformer<T, TInput, TOutput> transformer) |
Sets the final transformer that may change the output type. |
TInput InverseTransform(TOutput data) |
Inverse transforms data through all pipeline steps in reverse order. |
TOutput FitTransform(TInput data) |
Fits the pipeline and transforms the data in a single step. |
TOutput Transform(TInput data) |
Transforms data through all pipeline steps. |
string[] GetFeatureNamesOut(string[] inputFeatureNames) |
Gets the output feature names after all transformations. |
void Fit(TInput data) |
Fits all transformers in the pipeline to the training data. |