[MUSIC]
>> Hi I'm Anna Thomas,
a Data and Applied Scientists on the Azure SQL team.
Today, I'm joined by my friend,
David Peter Hansen who's on the Docs team.
So can you tell me a little bit about what you do David Peter?
>> Yeah. So my name is David Peter,
I'm a Senior Content Developer on the Documentation team.
On the vast analytics we write
documentation about advanced analytics and AI,
and machine learning on the lead
for Azure SQL Database Machine Learning Services,
and SQL Server Machine Learning Services,
and SQL Server Language Extensions,
where we are then writing the documentation for these areas.
>> Awesome. Cool. So today I think you wanted to show us some of
the stuff we're doing with Doc's
and some of the stuff you've been working on.
>> Yeah. So other documentation we recently created was around
Azure SQL Database Machine Learning Services which
is currently in public preview.
So we've been expanding the documentation a lot in
that area to be able
to help our customers get on board and try out these new features,
make it easier for them to get started.
>> Awesome.
>> So some of the things we created here is a Quickstart.
We have one that creates and trains
a predictive model very simple one around that.
So rather than just scroll
through here and show you the entire thing,
let me actually show you how it works within Azure SQL Database.
>> Awesome. So you're going to show us click
through and the quickstart, and run through with this?
>> So we had two quickstart.
The first is very simple and it's
very similar to this one where we have.
You basically have a very simple R script.
So in Azure Database Machine Learning Services,
basically what you can do is you can run R
within Azure SQL database.
So you are able to do
predictive analytics and machine learning within the database.
Rather than having to move the data
out to your compute and put it back in,
so now you can basically run the compute where the data resides.
>> Awesome.
>> So I have a super simple script which is a bit
silly here where an R script,
where we have some variables like a is one,
b is two, and c and so on.
The last thing I do here,
is just I multiplier c and d,
outputted as data frame.
All of this is if you can run this from like RStudio or RGUI,
or something like that,
it would give you an output.
But what we're doing here,
is we're running it within Azure SQL database
using the stored procedure
here called sp_execute_external_scripts.
We give it a language.
At the moment, we have R support,
but more language as will follow.
In SQL Server which has a similar to the on-prem product,
we also have Python support and well language extensions,
Java, and more languages will come.
>> So you're using sp_execute_external_script here,
but is it possible for me to use RStudio or another tool?
>> You could use RStudio as well to
connect to it in the compute contexts of
the server and then run it on Azure SQL Database as well.
>> Got you.
>> So this is very simple,
so I'm not doing it right now.
But it's absolutely possible.
>> Great.
>> What you'll notice down here is just some of the parameters,
is that I had
the output parameter set to e. So
that's my e variable that I've come out here.
I'm just going to return a result set,
that is the output of this.
Let me try run this really quick.
There we go. So we can see here that we have the output of 2.5.
So barriers, well, it's not really that interesting.
But it's just to show, "Okay. This is running."
All of this is running in Azure.
It's not running locally on my laptop in anyway.
Let's do a little bit more complex.
So let's say we have some cars here,
and those cars has a speed and distance, for example.
So let me create a table that does that.
Actually, then insert some data here.
This dataset is one of the sample datasets that comes with
R. So you'll see here that I'm
simply just taking cars and I'll insert again.
Now, I have an input table,
that is a car speed that I just created.
So let me run that.
Yeah. So I'm going to go here and create
a model that build a model.
When within that model I have a formula,
some R code in there that then,
goes and uses this data from the cars speed to go and
predict the distance from the speed of the cars or how fast.
The distances is a braking distance, I should have said that.
So the braking distance of these cars,
depending on how fast they're speeding.
>> Got you.
>> So let me go and create. As I'm
not going to go into all the details.
If you want all the details, go to the Quick Start.
>> Yeah.
>> It's all written in there.
So now that I have this model,
I would want to store it somewhere.
So what I want to do is create a table.
First, I give the model a name.
Then, the model itself is stored as
a binary max within my SQL server.
So that once I've built and created a model,
and then train it, I can store it in there,
so that we're able to use it.
So you don't need to do that over and over again.
>> Right now, I can have it and I can call it later.
>> Absolutely.
>> Awesome.
>> So let me go and create this table here.
Then, I'll simply just go and execute
the store procedure and insert the output which is the model,
and insert it into my table that I just created.
>> Cool. So what will this return now?
>> So right now, basically the store procedure
returns the binary model from R itself,
that is installed in the database.
So we haven't done anything,
except we built a model and we trained the model on the data.
So let me go and create the table here.
Well, there's no data. I can then go
here and again, call an RScript.
So that's RScript, takes, it goes.
First, I get the model that I stored from
my stopping distant models table that I created.
I then take that model and un-serialize it,
so I get it back into R. I used the data from the new data car.
So you see down here,
I have a data input that is that table that I just created.
I can then go and use rxPredict to go
and predict the distance of these things.
All right. So let me run this one.
It takes a little bit of time.
We can see here these are
the different speeds that I inserted before.
Then, there's a predicted breaking distance depending
on how faster the car actually was.
>> Intuitively, this makes sense.
It looks like the faster the speed,
the longer the braking distance.
>> The longer the breaking distance.
Right. So it's a very simple example of this.
I went very quickly over it.
So what you could do is go to our Quickstart here,
and it have all the descriptions
about what this particularly example does.
If you want something a bit more advanced,
we also have more in-depth tutorials.
>> Okay.
>> So we recently created two tutorials,
one that builds predictive models in R,
and one where you're building a clustering model.
>> Clustering model.
>> Yeah. So we got that as well.
>> Now, if I'm going through one of these tutorials or Quickstarts
and have a question or I get stuck on something, can I e-mail you?
>> No. So I
always receive a lot of e-mails. But there are two ways.
So if you find something that is like, okay,
you think this might be wrong or you find a typo for example,
or if you want to
help improve and contribute to the documentation.
There are two ways of doing that.
The first one is to go all the way to the bottom here,
and you see you have this feedback button.
So if it's about the product,
you can click this product and it will
take you to the product part of it,
which is our engineering group that will respond to that.
But if it's about the documentation itself,
you can click on this page and that will take you to GitHub.
So all our documentation is written in GitHub.
So actually this box behind here is GitHub.
Create a GitHub issue,
with then, actually, we'll send an e-mail, also you.
>> Directly you said e-mails.
>> You directly send me e-mail
and we will then get back to you about that issue.
>> Awesome.
>> Another way is, let's say you find a typo
or there's something that you think,
"Let's improve this documentation anyway."
Another way is, because all our documentation is open-source,
so you can go up here in the top
and simply click the "Edit" button.
So if you go and do that,
you see it takes us to GitHub.
The Azure Docs is the GitHub repo for
all our Azure documentation that we
have in edit, and that's open-source.
You can see here this one is under SQL database.
Then, SQL database to 12 predictive model prepare data.md.
So the.md because it's a Markdown file.
So we're using Markdown to write.
>> All the docs.
>> Cool.
>> Similarly to go and edit it,
you click on this little pen here and you can go,
and click and "Edit" the documentation itself.
Now, you can see, yeah,
this is basically just Markdown that we have here.
Let's say we find a typo in there.
Once I'm done, I want to go down here.
I go and I write,
fixed typo, for example.
Then, I will then go and click "Proposed Changes".
>> Something more to edit.
>> Yeah. Then, that will go in and I would create
a pull request which we will then go and review,
and if everything looks good,
you will get merged into
the documentation and contribute to it that way.
>> Great. Awesome. Well, thanks so
much for joining us, David Peter.
I hope our audience learned a lot.
I hope you-all like this video,
or comment and let us know what you're doing with
Azure ML or Azure SQL database
with machine learning with
R. Check out our docs and even start contributing.
>> Thank you so much for having me here.
>> Yeah. Thanks.
>> Thank you.
>> Thanks guys.
>> Thank you. Bye.
[MUSIC]