带有bigquery文件位置的自动SDK代码,但在预测时存在问题



我正在使用AI平台中的GCP automl sdk模块创建模型(使用bigquery表作为训练和预测的输入),并使用batch_prediction进行预测。问题是代码运行良好,但预测的输出表是空的,错误表有来自预测数据帧的所有序列和附加列,说明错误代码为3,错误为"时间序列没有可预测的值。时间序列已被排除在预测之外。

我用于模型训练的代码:

job = aiplatform.AutoMLForecastingTrainingJob(
display_name='train-sdk-automl_tst1',
optimization_objective='minimize-mae',    
column_transformations=[
{"timestamp": {"column_name": "Date"}},
{"numeric": {"column_name": "Price"}},
{"numeric": {"column_name": "Grammage"}},
{"numeric": {"column_name": "apparentTemperatureMax"}},
{"numeric": {"column_name": "apparentTemperatureMin"}},
{"numeric": {"column_name": "Consumer_promo"}},
{"numeric": {"column_name": "Promo_Value"}},
{"numeric": {"column_name": "Trade_Promotion"}},
{"numeric": {"column_name": "Holiday"}},
{"numeric": {"column_name": "Sales"}},
]
)
# This will take around an hour to run
my_model = job.run(
dataset=ds,
target_column='Sales',
time_column='Date',
time_series_identifier_column='SKU',
available_at_forecast_columns=['Date', 'Price','Grammage'
,'apparentTemperatureMax','apparentTemperatureMin','Consumer_promo',
"Promo_Value","Trade_Promotion","Holiday"],
unavailable_at_forecast_columns=['Sales'],
forecast_horizon=21.0,
data_granularity_unit='week',
data_granularity_count=1,
weight_column=None,
budget_milli_node_hours=1000,
model_display_name='sdk_tsting_bq-forecast-model', 
predefined_split_column_name=None
)

预测代码:

BATCH_PREDICT_SOURCE = 'bq://acn-intelligent-supply-chain.scoa_ml_forecast_tool.test_data_sdk1'
BATCH_PREDICT_DESTINATION_PREFIX = 'bq://acn-intelligent-supply-chain.scoa_ml_forecast_tool' 
my_model.batch_predict(
bigquery_source=BATCH_PREDICT_SOURCE,
instances_format='bigquery',
bigquery_destination_prefix = BATCH_PREDICT_DESTINATION_PREFIX,
predictions_format='bigquery',
job_display_name='predict_sdk_tst')

请指出这里可能出现的问题。

我认为用于批处理预测的BQ表需要在目标中具有NULL值(例如:"销售")列。如果你还没有这样做,试一试,看看是否有帮助。

相关内容

  • 没有找到相关文章

最新更新