FunctionTransformer<T>

Models & Types · AiDotNet.Preprocessing.FeatureGeneration

Applies a custom function to transform data.

Inheritance: TransformerBase<T, Matrix<T>, Matrix<T>> → FunctionTransformer<T>

For Beginners

Sometimes you need a custom transformation that doesn’t fit standard transformers. FunctionTransformer lets you plug in your own function:

  • Apply a mathematical formula to all values
  • Perform domain-specific feature engineering
  • Wrap existing transformation code

Example: Apply a custom normalization formula or domain-specific scaling.

How It Works

FunctionTransformer allows you to apply arbitrary functions to your data as part of a preprocessing pipeline. This is useful for applying domain-specific transformations or wrapping legacy code into the transformer API.

Constructors

Constructor Summary
FunctionTransformer(Func<Matrix<T>, Matrix<T>> func, Func<Matrix<T>, Matrix<T>> inverseFunc, bool validate, int[] columnIndices) Creates a new instance of FunctionTransformer with matrix-level functions.

Properties

Property Summary
bool SupportsInverseTransform { get; } Gets whether this transformer supports inverse transformation.
bool Validate { get; } Gets whether this transformer validates input/output shapes.

Methods

Method Summary
FunctionTransformer<T> Abs() Creates a FunctionTransformer that applies the absolute value.
FunctionTransformer<T> Clip(double min, double max) Creates a FunctionTransformer that clips values to a range.
FunctionTransformer<T> Exp() Creates a FunctionTransformer that applies the exponential function.
FunctionTransformer<T> FromElementFunction(Func<T, T> elementFunc, Func<T, T> inverseElementFunc, bool validate, int[] columnIndices) Creates a new instance of FunctionTransformer with element-wise functions.
FunctionTransformer<T> Log() Creates a FunctionTransformer that applies the natural logarithm.
FunctionTransformer<T> Log1p() Creates a FunctionTransformer that applies log(1 + x).
FunctionTransformer<T> Power(double power) Creates a FunctionTransformer that raises to a power.
FunctionTransformer<T> Sign() Creates a FunctionTransformer that applies the sign function.
FunctionTransformer<T> Sqrt() Creates a FunctionTransformer that applies the square root.
string[] GetFeatureNamesOut(string[] inputFeatureNames) Gets the output feature names after transformation.