Preprocessing categorydrop - CyrilB1531/lodestar GitHub Wiki

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

HomePreprocessingEncoding and imputation

CategoryDrop

Which category, if any, OneHotEncoder leaves without a column.

public enum CategoryDrop

FieldsNone gives every category a column, First drops each feature's first, and IfBinary drops the first only where the feature has exactly two — drop=None, "first" and "if_binary".

Example — dropping the first category of a three-category feature.

using Lodestar.Preprocessing;

OneHotEncoder<string> encoder = Encoders.OneHot(
    ["a", "b", "c"], 1, new OneHotEncoderOptions { Drop = CategoryDrop.First });

int columns = encoder.EncodedFeatureCount;                 // => 2
string first = string.Join(",", encoder.Transform(["a"])); // => 0,0

Remarks — dropping one category is what a linear model with an intercept needs: with every category carrying a column, the columns of a feature sum to 1 and are collinear with the intercept. IfBinary is the compromise the reference offers — drop where a single column says everything, keep where it does not.

Applies to — net10.0, netstandard2.0.

See alsoOneHotEncoderOptions.

⚠️ **GitHub.com Fallback** ⚠️