<jupyter_start><jupyter_text>Get Diabetes Predictions from a Designer PipelineModify the code in the cell below to use the ***ENDPOINT*** and ***PRIMARY_KEY*** for your **predict-diabetes** service. Then run the cell to submit new patient data and retrieve the predicted classification.<jupyter_code>endpoint = 'http://a59d0785-f42e-413e-ba6e-9661bd2203fb.westus2.azurecontainer.io/score' #Replace with your endpoint
key = '<KEY>' #Replace with your key

import urllib.request
import json
import os

data = {
    "Inputs": {
        "WebServiceInput0":
        [
            {
                    'PatientID': 1882185,
                    'Pregnancies': 9,
                    'PlasmaGlucose': 104,
                    'DiastolicBloodPressure': 51,
                    'TricepsThickness': 7,
                    'SerumInsulin': 24,
                    'BMI': 27.36983156,
                    'DiabetesPedigree': 1.3504720469999998,
                    'Age': 43,
            },
        ],
    },
    "GlobalParameters":  {
    }
}

body = str.encode(json.dumps(data))

print (body)

headers = {'Content-Type':'application/json', 'Authorization':('Bearer '+ key)}

req = urllib.request.Request(endpoint, body, headers)

try:
    response = urllib.request.urlopen(req)
    result = response.read()
    json_result = json.loads(result)
    output = json_result["Results"]["WebServiceOutput0"][0]
    print('Patient: {}\nPrediction: {}\nProbability: {:.2f}'.format(output["PatientID"],
                                                            output["DiabetesPrediction"],
                                                            output["Probability"],))
except urllib.error.HTTPError as error:
    print("The request failed with status code: " + str(error.code))

    # Print the headers to help debug
    print(error.info())
    print(json.loads(error.read().decode("utf8", 'ignore')))<jupyter_output>b'{"Inputs": {"WebServiceInput0": [{"PatientID": 1882185, "Pregnancies": 9, "PlasmaGlucose": 104, "DiastolicBloodPressure": 51, "TricepsThickness": 7, "SerumInsulin": 24, "BMI": 27.36983156, "DiabetesPedigree": 1.3504720469999998, "Age": 43}]}, "GlobalParameters": {}}'
Patient: 1882185.0
Prediction: 1.0
Probability: 0.70
{'fraction_non_alphanumeric': 0.13650651100134711, 'fraction_numerical': 0.05837449483610238, 'mean_word_length': 2.5648, 'pattern_counts': {'":': 15, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '53642', 'license': 'MIT', 'n_tokens_mistral': 788, 'n_tokens_neox': 659, 'n_words': 149, 'path': '03 - Get Designer Prediction.ipynb', 'repo_name': 'DataGeek-Harsh/DP-100-Completed', 'size': '2254'}