PostprocessingPipeline<T, TInput, TOutput>

Models & Types · AiDotNet.Postprocessing

Chains multiple data transformers into a sequential postprocessing pipeline.

Implements: IDataTransformer<T, TInput, TOutput>

For Beginners

Think of a pipeline as a series of steps for processing model output. For example:

  1. First, apply softmax to get probabilities
  2. Then, decode indices to labels
  3. Finally, format the output

The pipeline ensures all these steps happen in the right order.

How It Works

A postprocessing pipeline applies transformers in sequence, passing the output of each transformer as input to the next. This enables composable postprocessing workflows similar to sklearn’s Pipeline, applied to model outputs.

Constructors

Constructor Summary
PostprocessingPipeline() Creates a new empty postprocessing 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.
PostprocessingPipeline<T, TInput, TOutput> Add(IDataTransformer<T, TInput, TInput> transformer) Adds a transformer step to the pipeline.
PostprocessingPipeline<T, TInput, TOutput> Add(string name, IDataTransformer<T, TInput, TInput> transformer) Adds a named transformer step to the pipeline.
PostprocessingPipeline<T, TInput, TOutput> Clone() Creates a clone of this pipeline without fitted state.
PostprocessingPipeline<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 data.