Preprocessing 0.2.0 encoders label - CyrilB1531/lodestar GitHub Wiki
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 a label encoder on one column of labels.
public static LabelEncoder<T> Label<T>(ReadOnlySpan<T> labels) where T : IComparable<T>, IEquatable<T>Type parameter — T is the label type; string and int are the two the reference takes.
Parameters — labels is one column of labels.
Returns — a fitted LabelEncoder.
Exceptions — ArgumentException when labels is empty or holds a null.
Example — the codes and how many rows were read.
using Lodestar.Preprocessing;
string[] cities = ["paris", "lyon", "paris", "nice"];
LabelEncoder<string> encoder = Encoders.Label<string>(cities);
int rows = encoder.SampleCount; // => 4
string classes = string.Join(",", encoder.Classes); // => lyon,nice,parisRemarks — one column, not a matrix, which is the one difference from
Encoders.Ordinal: the reference's LabelEncoder takes a 1-D array and
its OrdinalEncoder a 2-D one, because the first is for a target and the second for features.
There is no featureCount parameter here for that reason.
Applies to — net10.0, netstandard2.0.
See also — LabelEncoder, Encoders,
Encoders.Ordinal.