Preprocessing 0.2.0 onehotencoderoptions - 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 OneHotEncoder drops, and what it does with an unseen value.
public sealed record OneHotEncoderOptionsProperties — Drop chooses which category loses its column, and Unknown what happens to a
value the fit never saw — sklearn.preprocessing.OneHotEncoder's drop and handle_unknown, same
defaults.
Example — IfBinary drops the first category only where the feature has exactly two.
using Lodestar.Preprocessing;
var options = new OneHotEncoderOptions { Drop = CategoryDrop.IfBinary };
OneHotEncoder<string> binary = Encoders.OneHot(["y", "n", "y"], 1, options);
OneHotEncoder<string> three = Encoders.OneHot(["a", "b", "c"], 1, options);
int binaryColumns = binary.EncodedFeatureCount; // => 1
int threeColumns = three.EncodedFeatureCount; // => 3Remarks — the two settings interact: an ignored unknown encodes to all zeros, and so does a
dropped first category, so a row of zeros means either. Transform
says so with the example.
Applies to — net10.0, netstandard2.0.
See also — CategoryDrop, UnknownCategory.