【发布时间】:2020-10-29 19:34:29
【问题描述】:
我在 SageMaker 中使用 Batch Transform 来调用存储的 XGBoost 模型,并对存储在 S3 中的数据进行评分。但是,在调用模型之前,我必须对列进行几次转换。
以下是用于批量转换的代码:
batch_input = 's3://{}/{}/batch/test_data_Batch.csv'.format(bucket,prefix) # test data used for prediction
batch_output = 's3://{}/{}/batch/batch-inference/test_data_Batch.csv.out'.format(bucket,prefix)
Modelname = '<your_model_name_here>' # the model name we already have
transformJobName = 'DEMO-xgboost-churn-call-batch'+ strftime("%Y-%m-%d-%H-%M-%S", gmtime())
client = boto3.client('sagemaker')
create_batch = client.create_transform_job(
TransformJobName=transformJobName,
ModelName=Modelname,
MaxConcurrentTransforms=0,
MaxPayloadInMB=6,
BatchStrategy='MultiRecord',
TransformInput={
'DataSource': {
'S3DataSource': {
'S3DataType': 'S3Prefix',
'S3Uri': batch_input
}
},
'ContentType': 'text/csv',
'CompressionType': 'None',
'SplitType': 'Line'
},
TransformOutput={
'S3OutputPath': batch_output,
'AssembleWith': 'Line'
},
TransformResources={
'InstanceType': 'ml.m4.xlarge',
'InstanceCount': 1
}
)
在使用 XGBoost 模型运行批量转换之前,如何调用特征工程 Python 函数来转换数据?一些指针会有所帮助。谢谢。
【问题讨论】:
标签: python amazon-web-services amazon-sagemaker