quantlab.runs.trained_run.write_walk_forward_run#

quantlab.runs.trained_run.write_walk_forward_run(directory, *, folds, cv_mean, provenance=None)[source]#

Write the run.json of a "walk_forward" unit and return the unit.

Fold i is the unit in fold_directory(directory, i), which must already be written; its windows and metrics are copied from its own run.json into the walk-forward record.

Parameters:
directoryPath or str

The unit’s directory.

foldssequence of int

The fold indices, in fold order.

cv_meandict

The fold means of the metrics; NaN and inf become null.

provenancemapping, optional

The top unit’s data_fingerprint and code, and for an assembled unit assembled_from; None (a member, a fold) records an empty fingerprint and no code.

Returns:
TrainedRun

The walk-forward unit, as TrainedRun.open reads it.

Examples

>>> run = write_walk_forward_run(trial, folds=[0, 1], cv_mean={})
>>> run.kind, [fold.index for fold in run.folds]
('walk_forward', [0, 1])