PurgedWalkForwardSplitter<T>
Models & Types · AiDotNet.Preprocessing.DataPreparation.Splitting.TimeSeries
Walk-forward splitter that purges training samples whose label windows overlap the test fold, and embargoes a gap after it.
Inheritance: DataSplitterBase<T> → PurgedWalkForwardSplitter<T>
For Beginners
When your answer for “today” depends on the next 20 days, the rows right before your test period secretly contain test-period information. This removes those rows so the score you get is honest.
How It Works
The fold geometry is PurgedWalkForwardValidator’s, which is the only implementation
in the library carrying both labelHorizon and embargo — but it is a static class, so
it could not be handed to ConfigureDataSplitter and was unreachable from the facade. This
wraps it as an IDataSplitter so the same logic is configurable like every other
splitter, rather than remaining a parallel API the builder cannot use.
Why purge and embargo matter. A plain chronological split leaks whenever a label spans the boundary: a 20-bar forward return computed at the last training index is derived from bars inside the test fold, so the model is scored partly on data it effectively saw. Purging drops those overlapping training samples; the embargo additionally drops a gap after the fold, covering serial correlation that outlives the label window. Standard practice in financial ML, and absent from mainstream ML libraries.
Constructors
| Constructor | Summary |
|---|---|
PurgedWalkForwardSplitter(int labelHorizon, int nSplits, int embargo, bool expanding) |
Creates a purged, embargoed walk-forward splitter. |
Properties
| Property | Summary |
|---|---|
bool RequiresLabels { get; } |
|
bool SupportsValidation { get; } |
|
int NumSplits { get; } |
|
string Description { get; } |
Methods
| Method | Summary |
|---|---|
DataSplitResult<T> Split(Matrix<T> X, Vector<T> y) |
|
IEnumerable<DataSplitResult<T>> GetSplits(Matrix<T> X, Vector<T> y) |