Created
March 23, 2020 06:22
-
-
Save zachrenwick/7aaa4573ea6ca4bb38ce866e788ecb75 to your computer and use it in GitHub Desktop.
Use this to return a prediction from Azure Auto ML model deployed to ACI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
# URL for the web service | |
scoring_uri = 'http://put-your-azure-ml-uri-here.westus2.azurecontainer.io/score' | |
# If the service is authenticated, set the key or token | |
#key = '<your key or token>' | |
# example payload for bike share forecast future (next day) | |
data = {"data": | |
[ | |
{ | |
"Date":"2020-03-21", | |
"SUB_CHANNEL":"DTH", | |
"Fiscal_Month":2, | |
"Fiscal_Week":7, | |
"Fiscal_Year":2021, | |
} | |
] | |
} | |
# Convert to JSON string | |
input_data = json.dumps(data) | |
# Set the content type | |
headers = {'Content-Type': 'application/json'} | |
# If authentication is enabled, set the authorization header | |
#headers['Authorization'] = f'Bearer {key}' | |
# Make the request and display the response | |
resp = requests.post(scoring_uri, input_data, headers=headers) | |
print(resp.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment