如何解决如何将Numpy数组传递给sagemaker端点?
我想通过测试数据集进行推断,然后将其转换为nd数组并将其传递给sagemaker端点。当我尝试直接使用端点时,它会起作用:
test_data_array = test_data.drop('default',axis=1).values #load the data into an array
xgb_predictor.content_type = 'text/csv' # set the data type for an inference
xgb_predictor.serializer = csv_serializer # set the serializer type
predictions = xgb_predictor.predict(test_data_array).decode('utf-8') # predict!
predictions_array = np.fromstring(predictions[1:],sep=',')
执行此操作并使用我的端点(xgb_predictor),它可以工作,但是当我尝试使用“ runtime.invoke_endpoint”的lamba函数来使用它时,它给了我错误。我还尝试了此链接中发布的解决方案:How to send numpy array to sagemaker endpoint using lambda function-但收到错误- ModelError::调用InvokeEndpoint操作时发生错误(ModelError):从以下位置收到客户端错误(415)带有消息“ application / json的模型不被接受的ContentType:csv,libsvm,镶木地板,recordio-protobuf,text / csv,text / libsvm,text / x-libsvm,application / x-parquet,application / x-recordio-protobuf 。”
在这种情况下,请遵循常规方法:
test_data_array = test_trial.drop('default',axis=1).values
response = runtime.invoke_endpoint(EndpointName = 'sagemaker-xgboost-',ContentType = 'text/csv',Body = ','.join([str(val) for val in test_data_array]).encode('utf-8')) # The actual review
我收到此错误: ModelError::调用InvokeEndpoint操作时发生错误(ModelError):从模型接收到客户端错误(415),并显示消息“加载csv数据失败,异常,请确保数据格式为csv:
在这里提供任何帮助。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。