Skip to content

Preprocessing 0.2.0 encoders

github-actions[bot] edited this page Sep 24, 2026 · 1 revision

Lodestar.Preprocessing 0.2.0. This page is frozen at that release. Read the current documentation for what main says now. A link to a decision or a migration page follows main, and leaves the archive.

Home › Encoding and imputation

Encoders

Fits the categorical encoders.

public static class Encoders

Example — one feature of three categories, one column each.

using Lodestar.Preprocessing;

string[] values = ["b", "a", "c", "a"];

OneHotEncoder<string> encoder = Encoders.OneHot(values, featureCount: 1);

string categories = string.Join(",", encoder.Categories[0]);  // => a,b,c
string first = string.Join(",", encoder.Transform(["b"]));    // => 0,1,0

Remarks — a static factory rather than a Fit on each encoder, for two reasons. A public static member on a generic type is what CA1000 refuses; and inference reads better — Encoders.OneHot(values, 1) against OneHotEncoder<string>.Fit(values, 1). It is the shape Splitters already has in this package.

One element type per call, which is what a 2-D array carries in the reference too: a caller with a string column and an integer column makes two calls and concatenates the results. The type decides the category order — strings sort by code point, integers as numbers — and that order decides the columns.

Applies to — net10.0, netstandard2.0.

See also — OneHotEncoder, OrdinalEncoder, LabelEncoder, SimpleImputer, the encoding index.

Members

Member What it does
Encoders.OneHot Fits a one-hot encoder on a row-major matrix of categories.
Encoders.Ordinal Fits an ordinal encoder on the same.
Encoders.Label Fits a label encoder on one column of labels.

Clone this wiki locally