From ce9a5e54be79aa4c1ca8207ac9eb737880793a30 Mon Sep 17 00:00:00 2001 From: nicedlp Date: Thu, 7 Sep 2023 08:48:37 +0000 Subject: [PATCH] Add timestamp in model filename --- formation_indus_ds_avancee/train_and_predict.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/formation_indus_ds_avancee/train_and_predict.py b/formation_indus_ds_avancee/train_and_predict.py index ea8b56f..8a8c8e9 100644 --- a/formation_indus_ds_avancee/train_and_predict.py +++ b/formation_indus_ds_avancee/train_and_predict.py @@ -18,7 +18,11 @@ def train_model(features: pd.DataFrame, model_registry_folder: str) -> None: y = features[target] model = RandomForestRegressor(n_estimators=1, max_depth=10, n_jobs=1) model.fit(X, y) - joblib.dump(model, os.path.join(model_registry_folder, 'model.joblib')) + + + timestr = time.strftime("%Y%m%d-%H%M%S") + + joblib.dump(model, os.path.join(model_registry_folder, f'model_{timestr}.joblib')) def predict_with_io(features_path: str, model_path: str, predictions_folder: str) -> None: