如何覆盖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?

查看:61
本文介绍了如何覆盖Google AI平台的标准库(即升级scikit-learn)并安装其他库以用于自定义预测例程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm currently building a pipeline and trying to see if I can get an ML model deployed in AI platform's prediction service, then use it later on in other projects via the HTTP request that the prediction service offers.

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

However the model that is being used was built using an scikit-learn library that is of a higher version than offered for the prediction runtime version 1.15 (this is the current version supported by google for scikit-learn predictions). This runtime version only supports scikit-learn version 0.20.4 and my model requires 0.23.1. As far as I know, everything else in the custom prediction routine works as intended, but the error received when loading the model () is only ever encountered when the scikit-learn version is older than the model needs.

因此,我需要一种方法来强制预测例程通过pip安装或某些等效方法来使用特定版本的scikit-learn-过去,我是通过setup.py文件中的自定义安装在Google Dataflow中完成此操作的但尚未在AI平台自定义预测例程中成功实现这一目标.我认为可以做到吗?

So, I need a way to force the prediction routine to use a particular version of scikit-learn via a pip install or some equivalent - in the past I have done this in Google Dataflow via custom installs in the setup.py file but have yet to succeed achieving this in AI platform custom prediction routines. I assume it can be done?

无效的"setup.py"

non-working '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']
)

推荐答案

因此,事实证明google当前不支持此功能.对于AI平台预测自定义容器Alpha,现阶段有一个封闭的Alpha-但暂时我已经使用Dataflow和自定义pip install命令的setup.py文件实现了相同的结果.

So it turns out google currently does not support this capability. There is a closed alpha at this stage for AI Platform Prediction Custom Containers Alpha - but for the time being I've achieved the same result using Dataflow with a setup.py file using custom pip install commands.

这篇关于如何覆盖Google AI平台的标准库(即升级scikit-learn)并安装其他库以用于自定义预测例程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆