-
Notifications
You must be signed in to change notification settings - Fork 0
Preprocessing 0.2.0 encoders
Lodestar.Preprocessing 0.2.0. This page is frozen at that release. Read the current documentation for what
mainsays now. A link to a decision or a migration page followsmain, and leaves the archive.
Home › Encoding and imputation
Fits the categorical encoders.
public static class EncodersExample — 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,0Remarks — 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.
| 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. |