swagger.json 预测模型的示例 json 似乎没有 return 预测

swagger.json example json for forecast model doesn't seem to return predictions

尝试使用 Azure ML 服务对预测模型进行预测时,swagger.json 包含以下输入架构:

"example": {"data": [{"date": "2019-08-30T00:00:00.000Z", "y_query": 1.0}]}

但是,当我将其作为输入来生成预测时,我收到以下错误:

data= {"data": [{"date": "2019-08-30T00:00:00.000Z", "y_query": 1 }]}
# Convert to JSON string
input_data = json.dumps(data)

# Set the content type
headers = {'Content-Type': 'application/json'}
# If authentication is enabled, set the authorization header
#headers['Authorization'] = f'Bearer {key}'

# Make the request and display the response
resp = requests.post(scoring_uri, input_data, headers=headers)
print(resp.text)

"{\"error\": \"DataException:\n\tMessage: y values are present for each date. Nothing to forecast.\n\tInnerException None\n\tErrorResponse \n{\n    \\"error\\": {\n        \\"code\\": \\"UserError\\",\n        \\"inner_error\\": {\n            \\"code\\": \\"InvalidData\\"\n        },\n        \\"message\\": \\"y values are present for each date. Nothing to forecast.\\"\n    }\n}\"}"

我试过不传递 y 值,这会导致 'expected two axis got one' 并将 0 作为 y_query 传递。任何关于如何使用这种方法进行预测的指导将不胜感激。

Web 服务的文档在此处:https://docs.microsoft.com/en-us/azure/machine-learning/service/how-to-consume-web-service

尝试使用 nan 作为 y_query 的值。并确保日期是训练集中使用的时间单位之后的下一个时间单位。

以下提交方式 np.nan 对我有效 y_query。

input_sample = pd.DataFrame(data=[{'Feature1_text': 'text1', 'Feature2_int': 0, 'Feature3_double': 2.0, 'DateHour': '2019-11-12T04:00:00.000Z', 'y_query': np.nan}])
run(input_sample)

如前所述,确保日期时间输入的时间是训练中最后一个日期之后的时间,否则会出现以下错误。

Input prediction data X_pred or input forecast_destination contains dates prior to the latest date in the training data. Please remove prediction rows with datetimes in the training date range or adjust the forecast_destination date.