TabularPredictor.clone_for_deployment¶
- TabularPredictor.clone_for_deployment(path: str, *, model: str = 'best', return_clone: bool = False, dirs_exist_ok: bool = False) str | 'TabularPredictor'[source]¶
将预测器及其所有工件克隆到本地磁盘上的新位置,然后删除在预测期间不需要的克隆工件。这非常适合在需要保存预测器快照的情况下使用,以便在执行更高级的操作(如fit_extra和refit_full)之前进行操作。
请注意,克隆体不再适合新模型,除了predict和predict_proba之外的大多数功能将不再有效。
与按顺序执行以下操作相同:
predictor_clone = predictor.clone(path=path, return_clone=True, dirs_exist_ok=dirs_exist_ok) predictor_clone.delete_models(models_to_keep=model, dry_run=False) predictor_clone.set_model_best(model=model, save_trainer=True) predictor_clone.save_space()
- Parameters:
path (str) – 克隆的预测器将保存到的目录路径。
model (str, default = 'best') – 在优化的预测器克隆中使用的模型。 所有其他不相关的模型将被删除以节省磁盘空间。 有关可用选项,请参阅 predictor.delete_models 的 models_to_keep 参数。 内部调用 predictor_clone.delete_models(models_to_keep=model, dry_run=False)
return_clone (bool, default = False) – 如果为True,返回加载的克隆TabularPredictor对象。 如果为False,返回克隆TabularPredictor对象的本地路径。
dirs_exist_ok (bool, default = False) – 如果为True,即使路径目录已经存在,也会克隆预测器,可能会覆盖不相关的文件。 如果为False,当路径目录已经存在时,将引发异常并避免执行复制。
- Returns:
如果 return_clone == True,返回加载的克隆 TabularPredictor 对象。
如果 return_clone == False,返回克隆 TabularPredictor 对象的本地路径。