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

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 alsoOneHotEncoder, OrdinalEncoder, 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.
⚠️ **GitHub.com Fallback** ⚠️