[英]I wonder if model.tar.gz from Sagemaker can be used for inference in another notebook?
Little background: I successfully ran a regression experiment on AWS and saved the best model from that experiment.小背景:我成功地在 AWS 上进行了回归实验,并从该实验中保存了最佳模型。 I have downloaded my best model as
model.tar.gz.
我已将我最好的模型下载为
model.tar.gz.
to use it for inference on my dataset elsewhere.用它来推断我在其他地方的数据集。 I extracted it and uploaded the 'xgboost-model' file into my Jupyter Lab workspace, where my dataset is.
我提取了它并将“xgboost-model”文件上传到我的 Jupyter Lab 工作区,我的数据集就在其中。
regression_model = 'xgboost-model'
predictions = regression_model.predict(X_test)
The error I'm getting is:我得到的错误是:
----> 1 predictions = regression_model.predict(X_test)
AttributeError: 'str' object has no attribute 'predict'
I know that XGBRegressor
has predict
attribute, but my model doesn't seem to have it though it's exported as an xgboost
model.我知道
XGBRegressor
具有predict
属性,但我的模型似乎没有它,尽管它被导出为xgboost
模型。 Any suggesstions on what I'm supposed to be doing instead?关于我应该做什么的任何建议?
Hey so for your model data, you can use it in another notebook, but you need to make sure the dataset you're predicting on has the same attributes as the data you trained on so that you can predict accurately with the model.嘿,对于您的模型数据,您可以在另一个笔记本中使用它,但您需要确保您预测的数据集与您训练的数据具有相同的属性,以便您可以使用模型进行准确预测。 Second point to try out is using the boto3 invoke_endpoint call, the predict attribute is from the SageMaker Python SDK.
尝试的第二点是使用 boto3 invoke_endpoint 调用,predict 属性来自 SageMaker Python SDK。 The boto3 SDK is the general AWS Python SDK.
boto3 开发工具包是通用的 AWS Python 开发工具包。 I've attached an example of deploying your endpoint with this model.tar.gz, simply passing in the string is not adequate you need to create an endpoint and then perform inference with either the predict call or the invoke_endpoint call.
我附上了一个使用这个 model.tar.gz 部署端点的示例,仅传递字符串是不够的,您需要创建一个端点,然后使用 predict 调用或 invoke_endpoint 调用执行推理。
Example: https://github.com/RamVegiraju/Pre-Trained-Sklearn-SageMaker示例: https ://github.com/RamVegiraju/Pre-Trained-Sklearn-SageMaker
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.