Skip to content

Preprocessing encoding

github-actions[bot] edited this page Sep 23, 2026 · 12 revisions

Development build. This page describes main, not a released package. The latest published Lodestar.Preprocessing is 0.1.0 — read its documentation.

HomePreprocessing

Encoding and imputation — Lodestar.Preprocessing

Three encoders and two imputers, at sklearn.preprocessing and sklearn.impute parity, over row-major spans rather than an IDataView: Encoders.OneHot gives each category a column, Encoders.Ordinal gives it a code, Encoders.Label does the same for a target column, SimpleImputer fills what is missing from the column's own statistic, and KnnImputer fills it from the rows that resemble the one with the gap.

One element type per call. A 2-D array carries one dtype in the reference too, so the encoders are generic over the category type and a caller with a string column and an integer column makes two calls. The type decides the order — strings sort by code point as numpy's do, integers as numbers — and that order decides the columns.

Why this exists when ML.NET has most of it

ML.NET has OneHotEncoding, MapValueToKey and ReplaceMissingValues; SharpLearning has OneHotTransformer and ReplaceMissingValuesTransformer. Almost nothing here is absent from .NET. Each one of them is reached through an IDataView or through a catalog naming columns, or works on that library's own matrix type — and what is absent is a call that takes an array and returns one. That is the whole argument, and decision 0004 says so rather than claiming a capability gap.

The one member with no counterpart at all is KnnImputer: ML.NET's ReplaceMissingValues fills from a column statistic — its mean, minimum, maximum or the type's default — and offers nothing that reads the row being filled.

Types

Type What it is
Encoders Fits the three encoders.
OneHotEncoder One column per category.
OneHotEncoderOptions Which category to drop, and what an unseen value becomes.
CategoryDrop None, the first, or the first of a binary feature.
UnknownCategory Refuse an unseen value, or encode it as zeros.
OrdinalEncoder One code per category.
LabelEncoder One code per label, for a target column.
SimpleImputer Fills missing values with a per-feature statistic.
SimpleImputerOptions Which statistic, and what to do with an empty feature.
ImputationStrategy Mean, median, most frequent, or a constant.
KnnImputer Fills missing values from the nearest rows.
KnnImputerOptions How many donors, and how they are weighted.
NeighbourWeights Equal shares, or the reciprocal of the distance.

See also

Clone this wiki locally