如何覆盖 Google AI 平台的标准库(即升级 scikit-learn)并安装其他库以用于自定义预测例程?

How do you override Google AI platform's standard library's (i.e upgrade scikit-learn) and install other libraries for custom prediction routines?

我目前正在构建一个管道并尝试查看是否可以在 AI 平台的预测服务中部署一个 ML 模型,然后通过预测服务提供的 HTTP 请求稍后在其他项目中使用它。

然而,正在使用的模型是使用 scikit-learn 库构建的,该库的版本高于为预测运行时版本 1.15 提供的版本(这是 google 为 scikit- 支持的当前版本学习预测)。此运行时版本仅支持 scikit-learn 版本 0.20.4,而我的模型需要 0.23.1。据我所知,自定义预测例程中的其他所有内容都按预期工作,但加载模型时收到的错误 () 只会在 scikit-learn 版本早于模型需要时遇到。

所以,我需要一种方法来强制预测例程通过 pip 安装或类似的东西使用特定版本的 scikit-learn - 过去我通过自定义安装在 Google Dataflow 中完成了此操作在 setup.py 文件中,但尚未在 AI 平台自定义预测例程中成功实现。我想这可以完成吗?

不工作'setup.py'

from setuptools import setup
from setuptools import find_packages

REQUIRED_PACKAGES = ['scikit-learn>=0.23.1',
                 'mlxtend>=0.17.2']

setup(
    name='my_custom_code',
    version='0.1',
    install_requires=REQUIRED_PACKAGES,
    packages=find_packages(),
    include_package_data=True,
    scripts=['predictor.py']
)

这是一个猜测的想法,因为我以前没有遇到过这个问题,但请告诉我它是否有效:您能否通过 --package_uris 指定一个包含 scikit-learn 你想要什么?

您可以通过以下方式获取所需 scikit-learn 版本的压缩包:

pip download scikit-learn==0.23.1 --no-binary=:all:

无耻外挂:你应该看看我的platform。它支持直接的 scikit-learn 模型 -> HTTP 端点部署并且更易于使用 :) 给我发一封电子邮件到 contact@modelzoo.dev,我可以把你放在我的 beta 列表中。

所以 google 目前不支持此功能。 AI Platform Prediction Custom Containers Alpha 在这个阶段有一个封闭的 alpha - 但目前我使用 Dataflow 和 setup.py 文件使用自定义 pip 安装命令获得了相同的结果。