【发布时间】:2021-01-15 17:37:28
【问题描述】:
我正在使用 SageMaker 管道对测试数据进行推断。 Pipeline 使用 SKLearn 单处理器和 XGBoost 模型。该管道适用于没有 ID 列的数据。但是,当我尝试包含一个 ID 列来跟踪预测时,它会失败。我在下面给出了代码sn-ps。
import sagemaker
from sagemaker.predictor import json_serializer, csv_serializer, json_deserializer
input_data_path = 's3://batch-transform/input-data/validation_data.csv'
output_data_path = 's3://batch-transform/predictions/'
transform_job = sagemaker.transformer.Transformer(
model_name = model_name,
instance_count = 1,
instance_type = 'ml.m4.xlarge',
strategy = 'MultiRecord',
assemble_with = 'Line',
output_path = output_data_path,
base_transform_job_name='pipeline_with_id',
sagemaker_session=sagemaker.Session(),
accept = 'text/csv')
transform_job.transform(data = input_data_path,
content_type = 'text/csv',
split_type = 'Line',
input_filter='$[1:]',
join_source='Input')
output_filter='$[0,-1]')
这会导致以下错误:
Fail to join data: mismatched line count between the input and the output
我正在按照此页面中给出的示例进行操作:
有人能指出导致错误的原因吗?谢谢
【问题讨论】:
-
您找到解决此错误的方法了吗?我遇到了类似的问题,我认为文档很差......
-
是的。这是标题的问题。我用来构建模型的数据假定了标题,但预测数据没有标题。我必须从训练数据中删除标题才能完成这项工作。这是删除不同数量的行的问题。
-
但是批量转换验证数据与训练数据没有任何关系,对吧?因此,在这种情况下,从验证数据中删除标头就足够了。我的数据中没有任何要批量转换的标题,但我仍然收到此错误。不幸的是......
标签: python amazon-web-services scikit-learn amazon-sagemaker