Preprocessing polynomialfeatures outputfeaturecount - CyrilB1531/lodestar GitHub Wiki

Development build. This page describes main, not a released package. The latest published Lodestar.Preprocessing is 0.2.0 — read its documentation.

Home › Preprocessing › Feature transforming

PolynomialFeatures.OutputFeatureCount

How many terms an expansion produces, without producing one.

public static int OutputFeatureCount(int featureCount, PolynomialFeaturesOptions options = null)

Parameters — featureCount is how many values each input row carries. options chooses the degree, the interaction restriction and the bias; null takes the reference's defaults.

Returns — the number of columns Transform would emit.

Exceptions — ArgumentOutOfRangeException when featureCount is not positive or the degree is negative. ArgumentException when the degree is 0 and the bias is off, which leaves no term, or when the terms are more than one array holds — counted, not listed (#1230).

Example — four features at degree three, before deciding whether to expand them.

using Lodestar.Preprocessing;

var options = new PolynomialFeaturesOptions { Degree = 3 };

int columns = PolynomialFeatures.OutputFeatureCount(featureCount: 4, options);   // => 35

Remarks — ask this before expanding a wide matrix. The expansion allocates every column of every row at once, and the column count is a binomial coefficient: it grows faster than a reader expects, and a matrix that fits comfortably in memory can have an expansion that does not.

Applies to — net10.0, netstandard2.0.

See also — PolynomialFeatures.Transform, PolynomialFeatures.FeatureNames, the Python equivalence table.