)
if args.save_model:
if args.target != "all":
model_desc = f"{args.country}-{args.target}-{args.cv_type}-{args.universal_data_only}-{univ_data}-{ip_data}-{args.impute}-{args.standardise}-{args.target_transform}"
pipeline_desc = f"best_cfg-{model_desc}.pkl"
with open(
SAVE_DIRECTORY / f"{model_desc}.pkl",
"wb",
) as f:
joblib.dump(pipeline, f)
with open(SAVE_DIRECTORY / pipeline_desc, "wb") as f:
pickle.dump(automl.best_config_per_estimator, f)
else:
# TODO: change model save description
model_desc = f"{args.country}-{col}-{args.cv_type}-{args.universal_data_only}-{univ_data}-{ip_data}-{args.impute}-{args.standardise}-{args.target_transform}"
pipeline_desc = f"best_cfg-{model_desc}.pkl"
with open(SAVE_DIRECTORY / f"{model_desc}.pkl", "wb") as f:
joblib.dump(pipeline, f)
with open(SAVE_DIRECTORY / pipeline_desc, "wb") as f:
pickle.dump(automl.best_config_per_estimator, f)
if args.log_run:
mlflow.end_run()
# Marina - two stage model as suggested by Lyudmila?
https://github.com/fitzgeraldja/stc_unicef_cpi/blob/cad6b9492e8ca15b940c1140f6d18b127f9ea6c8/src/stc_unicef_cpi/models/train_model.py#L693