Error while consuming the deployed web service through python

Senthil Murugan RAMACHANDRAN 21 Reputation points
2021-02-22T12:19:22.46+00:00

I have tried consuming the web service with python with the link how-to-consume-web-service. I'm getting an error

predict() missing 1 required positional argument: 'X'

I have trained the model to predict only one field " DESCRIPTION" and two input fields "CUSTOMERCODE", "DESCRIPTION"

when I try to predict with input data with the code below:

import requests
import json

URL for the web service

scoring_uri = 'xxx'

If the service is authenticated, set the key or token

key = 'xxx'

Two sets of data to score, so we get two results back

data = {"data":
[
[
"10000",
"CAPPUCINO"
],
[
"12345",
"CAFFINE"
]
]
}
input_data = json.dumps(data)
headers = {'Content-Type': 'application/json'}
headers['Authorization'] = f'Bearer {key}'
resp = requests.post(scoring_uri, input_data, headers=headers)
print(resp.text)

Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
2,653 questions
{count} votes

2 answers

Sort by: Most helpful
  1. GiftA-MSFT 11,161 Reputation points
    2021-02-25T18:44:25.18+00:00

    It seems your input is CUSTOMERCODE and target is DESCRIPTION, however, you are entering data for the target column when it is expecting only CUSTOMERCODE as input. Hope this helps!


  2. GiftA-MSFT 11,161 Reputation points
    2021-03-02T02:43:22.363+00:00

    Hi, can you try testing your model locally first to view the results and the expected format for your test data? It seems you performed some transformations when fitting the model, so you need to ensure that you are providing your test data with the expected shape and dimension of the array. Hope this helps!

    0 comments No comments