Azure ML Studio Test Interface

71 Views Asked by At

The Azure ML Studio Test interface presents me with a JSON template to send as a Post Request payload:

{
  "input_data": {
    "columns": [
      "content_type",
      "project_name",
      "source_words",
      "source_text",
      "target_locale",
      "evaluated_phase",
      "evaluated_translation",
      "evaluated_vendor",
      "lqe_phase"
    ],
    "index": [],
    "data": []
  }
}

I am completing it as follows:

{
  "input_data": {
    "columns": [
      "content_type",
      "project_name",
      "source_words",
      "source_text",
      "target_locale",
      "evaluated_phase",
      "evaluated_translation",
      "evaluated_vendor",
      "lqe_phase"
    ],
    "index": [],
    "data": [
      {
        "content_type": "some text",
        "project_name": "some text",
        "source_words": 1267,
        "source_text": "some text",
        "target_locale": "text",
        "evaluated_phase": "more text",
        "evaluated_translation": "text text",
        "evaluated_vendor": "text",
        "lqe_phase": "final text"
      }   
    ]
  }
}

All input fields except source_words are text, source_words being int.

I continually get the error: InnerException: ValueError: ['source_words']: Found array with 0 sample(s) (shape=(0, 1)) while a minimum of 1 is required.

Can anyone tell me what's likely wrong here?

Update 2023-10-05

Have deployed several other models and all give the same error.

1

There are 1 best solutions below

1
On BEST ANSWER

Based on provided information it seems the issue is with the input format. One possible solution is to properly format the input.

You can check the swagger input format for your model. For this you can check Swagger URI to get proper the input format and check this thread for more info. Alternate you can also try to format the input based on below shown python code snippet example (Modify the input as per your definition):

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))

With this you'll get properly formatted input for your endpoint testing.

For further details you can check this thread.