We click on our newly deployed model and will find see a list of attributes, of which the relevant one is the “Scoring URI”.

The scoring URI in azure ml. Not showing up? Your deployment might not be fully completed yet. The Scoring URI shows up when the complete deployment is finished.

Remember talking about API endpoints? This Scoring URI is our endpoint for the model we have created, meaning we can send (“do a request”) something to this endpoint (input) and will receive a response (output). And if we format the request correctly, we will get back what we want: a price per night estimate given our input columns.

Create a HTTP request

This part might get a bit confusing for those who have no experience working with HTTP requests, but just keep following the steps and you’ll get it to work!

Functionally, what we want to do is send a http request where we input values for the columns we have included in the model (except the target column, which is the one column we want back of course). That means we want to send information about:

“neighbourhood_group”, “neighbourhood”, “room_type”, “minimum_nights”,“number_of_reviews”, “last_review”, “reviews_per_month”.

This information is referred to as the “body” of our http request and Azure describes in their documentation how we should format this information to be interpretable by the model:

The REST API expects the body of the request to be a JSON document with the following structure:

{

"data":

[

<model-specific-data-structure>

]

}

where (an example of) our “model specific data structure” looks like this:

{

"data": [

{

"neighbourhood_group": "Queens",

"neighbourhood": "Ridgewood",

"room_type": "Entire home/apt",

"minimum_nights": 3,

"number_of_reviews": 9,

"last_review": "2019-06-26T00:00:00.000Z",

"reviews_per_month": 2.1

}

]

}

A HTTP request also includes one or more “Headers”, and according to the documentation, we need to add a “Content-Type” header:

“Content-Type” : “application/json”

To summarise, based on: (1) the endpoint/Scoring URI, (2) the body (input) and (3) the headers, we can create a request that will give us back (if everything works correct) an estimated price per night! Let’s put it to the test!

For the curious ones (which I assume is all of you who made it this far): here’s the complete request:

POST /score HTTP/1.1

Host: <scoring-uri>

Content-Type: application/json

User-Agent: PostmanRuntime/7.17.1

Accept: */*

Cache-Control: no-cache

Postman-Token: <token-value>

Host: <scoring-uri>

Accept-Encoding: gzip, deflate

Content-Length: 335

Connection: keep-alive

cache-control: no-cache {

"data": [

{

"neighbourhood_group": "Queens",

"neighbourhood": "Ridgewood",

"room_type": "Entire home/apt",

"minimum_nights": 3,

"number_of_reviews": 9,

"last_review": "2019-06-26T00:00:00.000Z",

"reviews_per_month": 2.1

}

]

}

There is some information in there that we haven’t covered; don’t worry about it, as it’s not essential for understanding our end to end workflow. On to the last part!

Send the HTTP Request

At this moment, you have a deployed model that is ‘callable’ by means of an API endpoint (the scoring URI). Anyone (quite literally anyone since we haven’t enforced any authorization on the API) can use your beautiful model in their apps, notebooks or other (business) applications by utilising the API endpoint. When I send the request from two paragraphs up, I get the following result:

"{\"result\": [125.5851758821278]}"

Awesome! So this tells us that given the model input (Queens, Ridgewood, Entire home/apt, 3 nights, 9 reviews, last review on the 26th of June 2019 and an average of 2.1 reviews per month) estimates that the price per night would be $125.58

Easy peasy! Obviously you want to see this to believe it, so here we go:

Download Postman, a free app for API development. We will use his to send our HTTP request to our model. Once installed. We’ll repeat the three steps of: setting the URL (scoring URI), adding the Content-Type Header and adding the body:

Open up Postman and select “Request” from the “Create New” tab: