TabularPredictor.refit_full

TabularPredictor.refit_full(model: str | List[str] = 'all', set_best_to_refit_full: bool = True, train_data_extra: DataFrame = None, num_cpus: int | str = 'auto', num_gpus: int | str = 'auto', fit_strategy: Literal['auto', 'sequential', 'parallel'] = 'auto', **kwargs) Dict[str, str][source]

在所有数据上重新训练模型(训练 + 验证)。 对于打包模型:

通过将打包的集成模型折叠为在所有训练数据上拟合的单个模型,优化模型的推理时间。 这个过程通常会导致轻微的准确性下降和大幅的推理速度提升。 推理速度提升通常比原始的打包集成模型快10-200倍。

推理加速因子等同于 (k * n),其中 k 是折叠次数 (num_bag_folds),n 是袋装集成中完成的重复次数 (num_bag_sets)。

The runtime is generally 10% or less of the original fit runtime.

运行时间可以大致估计为原始拟合运行时间的1 / (k * n),其中k和n如上定义。

For non-bagged models:

通过在不使用验证集的情况下对100%的数据进行重新训练来优化模型的准确性。 通常会导致准确性略有提高,而推理时间不变。 运行时间将大约等于原始拟合运行时间。

此过程不会改变原始模型,而是添加额外的模型。 如果此过程重新拟合了stacker模型,它们将在推理过程中使用祖先模型的refit_full版本。 此过程生成的模型将没有验证分数,因为它们使用所有数据进行训练。

因此,用户需要通过将测试数据包含在predictor.leaderboard(test_data)中来确定模型的质量是否足够。 如果用户没有额外的测试数据,他们应该参考原始模型的分数来估计refit_full模型的性能。

警告:请注意,在没有单独在测试数据上验证的情况下使用refit_full模型意味着该模型未经测试,并且不能保证与原始模型一致。

cache_data 必须在原始训练期间设置为 True 才能启用此功能。

Parameters:
  • model (str | List[str], default = 'all') –

    要重新拟合的模型名称。

    如果为‘all’,则所有模型都会被重新拟合。 如果为‘best’,则验证分数最高的模型会被重新拟合。

    如果所选模型是加权或堆叠集成模型,则所有祖先模型也将被重新拟合。 有效的模型可以通过调用predictor.model_names()在此predictor中列出。

  • set_best_to_refit_full (bool | str, default = True) – 如果为True,将最佳模型设置为先前最佳模型的refit_full版本。 这意味着当调用predictor.predict(data)时,使用的模型将是refit_full版本,而不是原始版本的模型。 如果model不是最佳模型,则忽略此设置。 如果为str,则将其解释为模型名称,并将最佳模型设置为set_best_to_refit_full模型的refit_full版本。

  • train_data_extra (pd.DataFrame, default = None) – 如果指定,将在重新拟合模型时用作额外的训练数据行。 需要标签列。仅用于L1模型。

  • num_cpus (int | str, default = "auto") – The total amount of cpus you want AutoGluon predictor to use. Auto means AutoGluon will make the decision based on the total number of cpus available and the model requirement for best performance. Users generally don’t need to set this value

  • num_gpus (int | str, default = "auto") – The total amount of gpus you want AutoGluon predictor to use. Auto means AutoGluon will make the decision based on the total number of gpus available and the model requirement for best performance. Users generally don’t need to set this value

  • fit_strategy (Literal["auto", "sequential", "parallel"], default = "auto") –

    The strategy used to fit models. If “auto”, uses the same fit_strategy as used in the original TabularPredictor.fit() call. If “sequential”, models will be fit sequentially. This is the most stable option with the most readable logging. If “parallel”, models will be fit in parallel with ray, splitting available compute between them.

    Note: “parallel” is experimental and may run into issues. It was first added in version 1.2.0.

    For machines with 16 or more CPU cores, it is likely that “parallel” will be faster than “sequential”.

    Added in version 1.2.0.

  • **kwargs – [高级] 开发者调试参数。

Return type:

原始模型名称字典 -> 重新拟合完整模型名称。