>> Well, it's finally time to deploy our model as a web service.
We're only going to test this out
from within the Jupyter Notebook,
from within Azure ML studio today,
but it does get deployed with a simple rest endpoint,
so it'll be easy to integrate into my app later on.
Let's get started.
Now that we have a model that we're happy with,
let's go ahead and deploy that model as a web service.
We're going to consume that web service
from within the Jupyter Notebook for now,
because consuming it from within
an application is out of scope for this series.
To get started, we're in our Jupyter Notebook again,
and we're going to need to have access
to the runs that we've already completed.
So let's make sure we have those.
First, I'm going to grab my training run.
Now, this was the original run that I
ran back in VS Code a few videos ago.
This was the run that use the training data.
Let's make sure we still have access to that.
That looks right. We can see that it's been
completed and this was an AutoML run.
We also need to have access to
that best run that Francesca helped us get.
Let's make sure that we have access to this one as well.
Awesome, this is looking good.
We have our best_run and our training_run.
Now, that best run created a model,
and that's the one that we want to target for our web service.
Let's go ahead and grab that model name.
We can see that the model name is this right here.
When we ran that model,
it created a scoring file for us.
So let's make sure that we have
access to that scoring file because that's
essentially going to be what
our web service calls to make a forecast.
We want to create a new folder called inference
and a new file called score.py.
We want to take the scoring file from
the best_run and save it to that file.
So we'll go ahead and run that,
and let's make sure that that all worked.
We can see that we've got this new inference folder,
and if we open it up,
we've got that score.py file.
Now, it's time to actually register our model.
I added a description and I'm registering
the model against our original training_run.
We've just registered our model.
Notice that the model_id is the
same as the model_ name from the best_run.
We can now find that model in
the workspace by heading over to "Models",
and you'll see that I've been testing it a bit.
So I'm going to click on this new one that I just created,
and you'll see that this is version 2 and I've just created it.
Now, before we get started on deploying our model,
I want to make sure that I have all of the libraries,
classes, packages, whatever I need ready to go right now.
Next, we're going to create an inference configuration.
Basically, this is telling our model
what script to run when it gets input,
and which environment to use to be able to run that script.
We're going to use best_run's environment.
We know already from above that we're going to use
best_runs scoring script to run when the model is called.
Because we're going to deploy
this web service on Azure Container Instance,
we need to create a deploy configuration.
So we're going to specify the CPU cores memory.
We're going to specify this as an AutoML forecasting type,
and give it a brief description.
Lastly, we're going to actually deploy this model.
We give the web service a name.
We deploy it specifying the workspace, the name,
the model that we created above,
the inference config, and the ACI config.
Now, we're just going to wait for it to deploy.
Well, we can see that, that succeeded.
Let's go see if we can see it inside of the workspace.
We'll head over to "Endpoints" and we'll do a refresh,
I don't even have to click it.
Here's our new web service.
We can click on it and we can see
the rest endpoints and all of the other information about it.
Looks like we're headed in the right direction.
Now, I promised that we'd actually test this web service,
so let's give that a try.
Before we do, I have created
a small CSV file that just has the next 14 days.
Remember that we ended our training data on August 31st,
so I created a CSV file that'll just predict the next 14 days.
Let's go ahead and give this one a try.
That's looking good.
Now, let's create a JSON file for this,
and let's call our web service.
I'm going to go ahead and give this a "Run".
Looks like it works, but this is hard to read.
I'm going to load in the response to
a dictionary and create a data frame
around it and make sure that I do have a forecast column.
Now, I want to actually compare my truth,
so what was in that testing data that I brought in in the test_df.
I want to compare that to what I'm getting back as the response.
We're going to create a new data frame with three columns in it.
One is our truth,
so the actual count of bikes that were rented for that day.
The second is the forecast,
the forecasted number of bikes that were rented for that day.
This is coming from our web service response.
A third is going to be the absolute percentage error.
Now, this is only on 14 rows,
so we're not going to graph this out.
It'll still allow us to see how accurate this is.
Awesome. We can see that
the truth and the forecasts are pretty close.
Now, we've successfully deployed
our model and tested it from inside of Jupyter Notebooks.
I highly encourage you to try this
out and then test it in other ways as well.