PurgedWalkForwardCrossValidator<T, TInput, TOutput>
Models & Types · AiDotNet.CrossValidators
Walk-forward cross-validation that purges training samples whose label windows overlap the validation fold, and embargoes a gap after it.
Inheritance: CrossValidatorBase<T, TInput, TOutput> → PurgedWalkForwardCrossValidator<T, TInput, TOutput>
For Beginners
When the answer for “today” depends on the next 20 days, the rows just before your validation period secretly contain validation-period information. Scoring against them flatters the model. This removes them, so the number you get is one you can trust.
How It Works
Every other cross-validator here — including TimeSeriesCrossValidator,
which is rolling-origin — leaks when labels look forward. A 20-bar forward return computed at the
last training index is derived from bars inside the validation fold, so the model is scored partly
on data it effectively saw, and the resulting estimate is optimistic. Purging removes those
overlapping training samples; the embargo additionally drops a gap after the fold to cover serial
correlation outliving the label window.
The fold geometry is PurgedWalkForwardValidator’s — the same logic behind
PurgedWalkForwardSplitter, so a purged split and a purged cross-validation agree rather
than being two separate implementations that can drift apart.
Constructors
| Constructor | Summary |
|---|---|
PurgedWalkForwardCrossValidator(int labelHorizon, int nSplits, int embargo, bool expanding, CrossValidationOptions options) |
Creates a purged, embargoed walk-forward cross-validator. |
Methods
| Method | Summary |
|---|---|
CrossValidationResult<T, TInput, TOutput> Validate(IFullModel<T, TInput, TOutput> model, TInput X, TOutput y, IOptimizer<T, TInput, TOutput> optimizer) |