I have deployed a machine learning model as a pickle file in azure machine learning. The endpoint is created. Now, I am trying to consume the endpoint through the following codes:
import requests
import numpy as np
# send a random row from the test set to score
random_index = np.random.randint(0, len(X_test) - 1)
input_data = '{"data": [' + str(list(X_test[random_index])) + "]}"
headers = {"Content-Type": "application/json"}
resp = requests.post(service.scoring_uri, input_data, headers=headers)
print("POST to url", service.scoring_uri)
print("prediction:", resp.text)
It's giving error with following message:
prediction: {"data": "Expecting value: line 1 column 12 (char 11)", "message": "Failed to predict"}
The data looks like:
X_test => array([[[0. ], [0.274710], [0.403273]]])
'{"data": [' + str(list(X_test[random_index])) + "]}"
convert it to
'{"data": [[array([0.]), array([0.274710]), array([0.403273])]]}'