Preprocessing splitting - 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.
Home āŗ Preprocessing
Splitting ā Lodestar.Preprocessing
One entry point, Splitters: it cuts the rows into cross-validation folds
or into a single train and test split, at sklearn.model_selection parity wherever the reference is
deterministic.
Indices in, indices out. A splitter here never sees the data. It is told how many rows there are ā or, to stratify, what class each row belongs to ā and it hands back the row numbers that train and the row numbers that are held out. Nothing is copied, and nothing decides the caller's layout.
Why this exists when ML.NET splits data
ML.NET has TrainTestSplit(IDataView, double, ā¦) and CrossValidationSplit(IDataView, int, ā¦), and
both return data views. They also never stratify:
dotnet/machinelearning#4396 has asked for it
since 2019 and is open. samplingKeyColumnName keeps rows that share a key together, which is the
opposite operation ā it prevents a group from straddling the split, where stratifying spreads a class
across every fold.
SharpLearning.CrossValidation does stratify, and its StratifiedIndexSampler<T> always shuffles from
a seed, so it cannot reproduce a scikit-learn fold. What is missing in .NET is a splitter that is
framework-free and reproducible, which is what
decision 0004
wrote this for.
The permutation is an argument, not a seed
Each splitter has a second overload taking order, a permutation of 0..nā1 that it reads the rows
in. Passing the permutation scikit-learn drew reproduces KFold(shuffle=True) and ShuffleSplit
ā the train/test split holds out the permutation's head, as ShuffleSplit does. Passing your own
gives a split this package can describe exactly, without claiming a generator no reference shares ā
the same choice KMeansOptions.InitialCentres makes by taking the centres rather than a seed.
StratifiedKFold(shuffle=True) is the exception: it shuffles each class's fold list rather than the
rows, so no permutation reproduces it, and the stratified order gives the unshuffled folds over the
rows read in that order instead.
Types
| Type | What it is |
|---|---|
Splitters |
The three splitters. |
FoldSplit |
One fold: which rows train, and which are held out. |
TrainTestSplit |
A single train and test split of the rows. |
See also
- Feature scaling ā the other half of this package.
- scikit-learn ā .NET ā what is delegated and what is not.
- Python ā C# equivalence.