question

SenthilMuruganRAMACHANDRAN-7389 avatar image
0 Votes"
SenthilMuruganRAMACHANDRAN-7389 asked ·

Error while consuming the deployed web service through python

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-learningazure-machine-learning-inference
· 1
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi, thanks for reaching out. The error message is most likely related to your training or scoring script. We'll need to be able to run your code, do you have a repo that we can use to troubleshoot further?

0 Votes 0 ·
GiftA-MSFT avatar image
0 Votes"
GiftA-MSFT answered ·

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!

· 1 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for the suggestion. I Tried it multiple times. Its not working with single input also.

0 Votes 0 ·
GiftA-MSFT avatar image
0 Votes"
GiftA-MSFT answered ·

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!

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.