运行随机森林以供生产使用

huangapple go评论51阅读模式
英文:

Running random forest for production

问题

我正在尝试将随机森林模型投入生产,使用AWS Lambda Layers。我已经使用sklearn随机森林创建了一个模型。以下是依赖项:

joblib==1.1.0
numpy==1.23.1
pandas==1.4.2
python-dateutil==2.8.2
pytz==2022.1
scikit-learn==1.1.1
scipy==1.9.0
six==1.16.0
threadpoolctl==3.1.0
tokenizers==0.12.1

我正在使用Windows 10操作系统。这些软件包的安装大小约为290 MB。然而,Lambda Layers要求软件包大小不超过250 MB。

有什么方法可以减小这个安装大小吗?有没有一种轻量级的安装方式,可以用于推理,或者以某种方式安装sklearn的一部分(sklearn依赖于占用大部分空间的scipy)。还有其他什么方法/策略吗?

英文:

I am trying to productionize a random forest model using AWS Lambda Layers. I have used sklearn random forest to create a model. Following are the dependencies:

joblib==1.1.0
numpy==1.23.1
pandas==1.4.2
python-dateutil==2.8.2
pytz==2022.1
scikit-learn==1.1.1
scipy==1.9.0
six==1.16.0
threadpoolctl==3.1.0
tokenizers==0.12.1

I am using Windows 10 OS. The size of the installation of these packages on disk is ~290 MB. However, Lambda Layers require less than 250 MB package size.

What are some ways I can reduce this installation size ? Is there a way to install something lightweight for inference or somehow install parts of sklearn (sklearn has dependency on scipy which is eating up most of the space). Is there any other way/strategy ?

答案1

得分: 1

你可以直接使用 Lambda 层来使用 sklearn,通过此链接: https://github.com/keithrozario/Klayers

Python 3.9 的 sklearn 的 ARN: arn:aws:lambda:us-east-1:770693421928:layer:Klayers-p39-sklearn:1

注意: 对于运行机器学习模型来说,使用 Lambda 函数并非理想选择。你可以使用 Sagemaker 实现更健壮的方案。

英文:

You can directly use a Lambda Layer for sklearn via ARN from here: https://github.com/keithrozario/Klayers

ARN for sklearn for Python 3.9: arn:aws:lambda:us-east-1:770693421928:layer:Klayers-p39-sklearn:1

Note: It isn't ideal to use Lambda functions for running machine learning models though. You could use Sagemaker for more robust implementation.

huangapple
  • 本文由 发表于 2023年4月19日 22:35:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/76055764.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定