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.jsonof a"model"unit, atomically, as its last file.The evaluation files are recorded when the
evaluation_pathsofdirectoryexist; 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, seeTrainedRun.- trained_ondict
factor_names,label_namesandsymbols.- 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_fingerprintandcode; 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 {}