Created an Auto ML Job, registered the model and created an end point but the schema of the test input is failing

226 Views Asked by At

I have used the azure auto ml low code editor way of building a forecasting model (predict the demand of a product based on a 8 year time series data) by following this guide : https://learn.microsoft.com/en-us/azure/machine-learning/tutorial-automated-ml-forecast?view=azureml-api-2

Where by we have done the below steps :

  • Create and load a dataset.
  • Configure and run an automated ML experiment.
  • Specify forecasting settings.
  • Deploy the best model.
  • Create an endpoint for the model

However while testing the endpoint from the studio test section, I am getting the below error :

enter image description here

On checking the logs, could find an input data format error as below : enter image description here The schema of the CSV that was uploaded as dataset for training the model is shared below. Please help with some leads. enter image description here

1

There are 1 best solutions below

0
On

Based on the provided information, I have reproduced the issue. enter image description here It seems the input expected input format required is different.

To fix this you can use the below code snippet to get the correct format:

import json

# Define the input_data dictionary
input_data = {
    "instant": 1,
    "date": "1/1/2013",
    "season": 1,
    "yr": 0,
    "mnth": 1,
    "weekday": 6,
    "weathersit": 2,
    "temp": 0.344167,
    "atemp": 0.363625,
    "hum": 0.805833,
    "windspeed": 0.160446,
    "casual": 331,
    "registered": 654
}

# Convert input_data dictionary to the desired format
formatted_data = {
    "input_data": json.dumps({
        "columns": list(input_data.keys()),
        "index": [0],
        "data": [list(input_data.values())]
    })
}

# Print the formatted data
print(json.dumps(formatted_data, indent=2))

Output:

{
  "input_data": "{\"columns\": [\"instant\", \"date\", \"season\", \"yr\", \"mnth\", \"weekday\", \"weathersit\", \"temp\", \"atemp\", \"hum\", \"windspeed\", \"casual\", \"registered\"], \"index\": [0], \"data\": [[1, \"1/1/2011\", 1, 0, 1, 6, 2, 0.344167, 0.363625, 0.805833, 0.160446, 331, 654]]}"
}

With the above output format, the test executed successfully. enter image description here