InteractionFeatures<T>

Models & Types · AiDotNet.Preprocessing.FeatureGeneration

Generates pairwise interaction features between input features.

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

For Beginners

Interaction features capture combined effects:

  • If both “age” and “income” matter together (not just separately)
  • Creating age × income might help the model
  • This is simpler than full polynomial features (no squared terms)

How It Works

InteractionFeatures creates new features by multiplying pairs of existing features. Unlike PolynomialFeatures with degree=2, this only produces interaction terms, not squared terms.

For features [a, b, c], this produces: [ab, ac, bc]

Constructors

Constructor Summary
InteractionFeatures(bool includeOriginal, InteractionType interactionType, int[] columnIndices) Creates a new instance of InteractionFeatures.

Properties

Property Summary
InteractionType InteractionType { get; } Gets the type of interactions generated.
List<ValueTuple<int, int>> InteractionPairs { get; } Gets the interaction pairs (feature indices).
bool IncludeOriginal { get; } Gets whether original features are included in output.
bool SupportsInverseTransform { get; } Gets whether this transformer supports inverse transformation.
int NOutputFeatures { get; } Gets the number of output features.

Methods

Method Summary
string[] GetFeatureNamesOut(string[] inputFeatureNames) Gets the output feature names after transformation.