使用 TPOT CV 拟合时,fitted_pipeline_ 是否在整个数据集上重新训练?

When fitting with TPOT CV, is the fitted_pipeline_ retrained on the whole dataset?

我正在使用带有 TPOTRegressor 的 LeaveOutGroupOut CV 策略

from tpot import TPOTRegressor
from sklearn.model_selection import LeaveOneGroupOut

tpot = TPOTRegressor(
    config_dict=regressor_config_dict,
    generations=100,
    population_size=100,
    cv=LeaveOneGroupOut(),
    verbosity=2,
    n_jobs=1)

tpot.fit(XX, yy, groups=groups)

优化后,得分最高的训练管道存储在 tpot.fitted_pipeline_ 中,tpot.fitted_pipeline_.predict(X) 可用。

我的问题是:安装的管道将接受哪些训练?例如

此外,有没有办法访问与 winning/optimized 管道的分割集相对应的完整训练模型集?

TPOT 将适合整个训练集的最终 'best' 管道:代码

因此,如果您打算通过 TPOT 对象直接与 'best' 管道交互,建议您永远不要将测试数据传递给 TPOT 拟合函数。

如果这对您来说是个问题,您可以直接通过 tpot.fitted_pipeline_ 属性重新训练管道,它只是一个 sklearn Pipeline 对象。或者,您可以使用 export 函数将 'best' 管道导出到其对应的 Python 代码并与 TPOT 外部的管道进行交互。

Additionally, is there a way to access the complete set of trained models corresponding to the set of splits for the winning/optimized pipeline?

没有。 TPOT 在评估管道时使用 sklearn 的 cross_val_score,因此它从 CV 过程中抛出了训练好的管道集。但是,您可以通过 tpot.evaluated_individuals_ 属性访问 TPOT 评估的每个管道的评分结果。