quantlab.runs.trained_run.write_ensemble_run#

quantlab.runs.trained_run.write_ensemble_run(directory, *, seeds, train_window, fitted_train_window, test_window, metrics, provenance=None)[source]#

Write the run.json of an "ensemble" unit, atomically, as its last file.

Member k is the "model" unit in member_directory(directory, k), which must already be written; seeds holds one entry per member.

Parameters:
directoryPath or str

The unit’s directory.

seedssequence

Each member’s seed, None when the ensemble does not vary seeds.

train_window, fitted_train_window, test_windowtuple

(start, end) pairs of the ensemble, see TrainedRun.

metricsdict

The metrics of the combined prediction.

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:
Path

The run.json written, the ensemble’s load-mode checkpoint.

Examples

>>> path = write_ensemble_run(unit, seeds=[0, 1],
...                           train_window=("2024-01-01", "2024-02-09"),
...                           fitted_train_window=("2024-01-01", "2024-02-07"),
...                           test_window=("2024-02-12", "2024-02-23"),
...                           metrics={})
>>> TrainedRun.open(path).checkpoint == path
True