quantlab.runs.trained_run.write_model_run#

quantlab.runs.trained_run.write_model_run(directory, *, checkpoint, train_window, fitted_train_window, test_window, trained_on, metrics, resolved_hyperparameters=None, provenance=None)[source]#

Write the run.json of a "model" unit, atomically, as its last file.

The evaluation files are recorded when the evaluation_paths of directory exist; NaN and inf metrics become null.

Parameters:
directoryPath or str

The unit’s directory, already holding the checkpoint.

checkpointPath or str

The checkpoint file, inside directory.

train_window, fitted_train_window, test_windowtuple

(start, end) pairs, see TrainedRun.

trained_ondict

factor_names, label_names and symbols.

metricsdict or None

The fit’s metrics; None when the fit was not evaluated.

resolved_hyperparametersdict, optional

The hyperparameters the library actually trained with; None to record nothing.

provenancemapping, optional

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

Examples

>>> write_model_run(unit, checkpoint=unit / "head.joblib",
...                 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"),
...                 trained_on={"factor_names": ["f"], "label_names": ["y"], "symbols": ["A"]},
...                 metrics=None)
>>> TrainedRun.open(unit).metrics
{}