-
Notifications
You must be signed in to change notification settings - Fork 0
Preprocessing unknowncategory
Development build. This page describes
main, not a released package. The latest published Lodestar.Preprocessing is 0.1.0 — read its documentation.
Home › Preprocessing › Encoding and imputation
What OneHotEncoder does with a value the fit never saw.
public enum UnknownCategoryFields — Refuse raises naming the feature, and Ignore encodes the value as all zeros —
handle_unknown="error" and "ignore", with Refuse the default as "error" is.
Example — the same value under both settings.
using Lodestar.Preprocessing;
OneHotEncoder<string> lenient = Encoders.OneHot(
["a", "b"], 1, new OneHotEncoderOptions { Unknown = UnknownCategory.Ignore });
string unknown = string.Join(",", lenient.Transform(["zzz"])); // => 0,0Remarks — refusing is the default because the alternative is silent: an unknown category becomes a row of zeros that a model reads as a category of its own, and no exception marks the point where the data stopped matching the fit.
Applies to — net10.0, netstandard2.0.
See also — OneHotEncoderOptions, OneHotEncoder.Transform.