如何将管道代码从 Pycaret AutoML 下载到 .py 文件中?

How to download pipeline code from Pycaret AutoML into .py files?

PyCaret 似乎是一个很棒的 AutoML 工具。它工作起来既快速又简单,我想将生成的管道代码下载到 .py 文件中 以仔细检查并在需要时自定义某些部分。不幸的是,我不知道如何让它成为现实。阅读 documentation 没有帮助。可不可以?

无法获取底层代码,因为 PyCaret 会为您处理。但是,作为用户,您可以决定您希望流程采取的步骤,例如

# Setup experiment with user-defined options for preprocessing, etc.
setup(...) 

# Create a model (uses training split only)
model = create_model("lr")

# Tune hyperparameters (user can pass a custom tuning grid if needed)
# Again, uses training split only
tuned = tune_model(model, ...)

# Finalize model (so that the best hyperparameters are retrained on the entire dataset
finalize_model(tuned)

# Any other steps you would like to do.
...

最后可以将整个流水线保存为pkl文件,以备后用

# Saves the model + pipeline as a pkl file
save_model(final, "my_best_model")