PolynomialFeatures<T>

Models & Types · AiDotNet.Preprocessing.FeatureGeneration

Generates polynomial and interaction features.

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

For Beginners

This transformer creates new features from existing ones:

  • Polynomial terms: a, a², a³, etc.
  • Interaction terms: ab, ab*c, etc.
  • Useful for capturing non-linear relationships

Example with degree=2 and features [x₁, x₂]: Output: [1, x₁, x₂, x₁², x₁x₂, x₂²]

How It Works

PolynomialFeatures generates a new feature matrix consisting of all polynomial combinations of the features with degree less than or equal to the specified degree. For example, with degree=2 and input [a, b], generates [1, a, b, a², ab, b²].

Constructors

Constructor Summary
PolynomialFeatures(int degree, bool interactionOnly, bool includeBias, int[] columnIndices) Creates a new instance of PolynomialFeatures.

Properties

Property Summary
bool IncludeBias { get; } Gets whether a bias (constant) column is included.
bool InteractionOnly { get; } Gets whether only interaction features are generated.
bool SupportsInverseTransform { get; } Gets whether this transformer supports inverse transformation.
int Degree { get; } Gets the degree of polynomial features.
int NInputFeatures { get; } Gets the number of input features.
int NOutputFeatures { get; } Gets the number of output features after transformation.

Methods

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