Preprocessing onehotencoderoptions - 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

OneHotEncoderOptions

Which category OneHotEncoder drops, and what it does with an unseen value.

public sealed record OneHotEncoderOptions

PropertiesDrop 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.

ExampleIfBinary 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;    // => 3

Remarks — 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 alsoCategoryDrop, UnknownCategory.

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