quantlab.model.walk_forward_training#
Walk-forward training: one walk-forward cross-validation of a model or an ensemble.
train_walk_forward runs a train_cv call for anything satisfying the
public protocol WalkForwardTrainable; BaseModel and BaseEnsemble
are its two adapters, and their train_cv delegates here. It owns the
procedure, so the two cannot drift apart:
check the unit’s hyperparameters, before any directory exists;
lay out the folds over the unit’s bars with
quantlab.model.split.walk_forward_foldsand its purge length;create the trial directory
{class}_trial_{timestamp}/under the unit’smodel_save_dirand train fold i, in order, intofold_{i}/(the unit applies the fold’s dates, trains and restores its own dates);average every
train_*/val_*/test_*metric of the folds’ trained runs (cv_mean_metrics), write the means to a{class}_cv_summarytracking run in the trial’s group and record the walk-forward trained run (quantlab.runs.trained_run) with the unit’s provenance.
The module imports no quantlab layer above quantlab.utils except the
trained-run module.
Examples#
>>> run = train_walk_forward(model.collect(), train_periods=20)
>>> run.kind, len(run.folds)
('walk_forward', 4)
Classes
What |
Functions
Average every |
|
Return |
|
Run a walk-forward cross-validation of |