Skip to content

Preprocessing unknowncategory

github-actions[bot] edited this page Sep 21, 2026 · 11 revisions

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

UnknownCategory

What OneHotEncoder does with a value the fit never saw.

public enum UnknownCategory

FieldsRefuse 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,0

Remarks — 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 alsoOneHotEncoderOptions, OneHotEncoder.Transform.

Clone this wiki locally