Preprocessing 0.2.0 categorydrop - CyrilB1531/lodestar GitHub Wiki
Lodestar.Preprocessing 0.2.0. This page is frozen at that release. Read the current documentation for what
mainsays now. A link to a decision or a migration page followsmain, and leaves the archive.
Home › Encoding and imputation
Which category, if any, OneHotEncoder leaves without a column.
public enum CategoryDropFields — None 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,0Remarks — 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 also — OneHotEncoderOptions.