manager.trainer.get_path_model

manager.trainer.get_path_model(name, iteration, model_dir=None)

Yield the path to a model file for a given iteration and model name.

Parameters

Name Type Description Default
name str Model name (e.g. "lgbm", "xgb"). required
iteration int Iteration of the model. required
model_dir Optional[Union[str, Path]] Directory where models are stored. If None, defaults to get_cache_home(). None

Returns

Name Type Description
Path Path Full path where the model file should be stored.

Examples

import tempfile
from pathlib import Path
from spotforecast2_safe.manager.trainer import get_path_model

with tempfile.TemporaryDirectory() as tmpdir:
    p = get_path_model("lgbm", 3, model_dir=tmpdir)
    print(p.name)
    assert p.name == "lgbm_forecaster_3.joblib"
lgbm_forecaster_3.joblib