-
Notifications
You must be signed in to change notification settings - Fork 0
Preprocessing 0.2.0 ordinalencoder transform
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
Encodes a row-major matrix as category indices.
public double[] Transform(ReadOnlySpan<T> values)Parameters — values is the categories to encode, row-major, with FeatureCount per row.
Returns — a new array of the same length, each value the index of its category.
Exceptions — ArgumentException when values holds no row, a partial one, a null, or a category
the fit never saw.
Example — two features, each coded against its own categories.
using Lodestar.Preprocessing;
string[] values = ["b", "x", "a", "y", "c", "x"];
OrdinalEncoder<string> encoder = Encoders.Ordinal(values, featureCount: 2);
string codes = string.Join(",", encoder.Transform(values)); // => 1,0,0,1,2,0Remarks — an unseen category is refused rather than coded: the reference's default raises too,
and its use_encoded_value needs a value outside the codes that nothing here asks for yet.
Returns double[] rather than int[] so the result feeds a scaler or a model without a conversion.
Applies to — net10.0, netstandard2.0.
See also — OrdinalEncoder, Encoders.Ordinal.