>> Hi, everyone. Thanks for coming out.
My name is rohan.
You're here hopefully because you want to hear about
Ml.Net which is a new machine [ indiscernible ]
Everything i'm showing you today is on preview quality bits.
Things are likely to change. So ml.Net, like i said is a
Machine learning framework. Open source. And because it runs on .Net it's
Cross platform. Use it on windows, linux and macos.
Pers. Targeted at .Net developers who
Want to branch in machine learning. Data scientists and folks who
Work in machine learning have tools they use for that and
We're not trying to take that part of the market.
We're trying to find a market that is easy for .Net developers
In the applications. When we think about machine
Leashing solutions there are two categories.
Pre-built things. Things like cognitive services
Where i can give an image and text and the noted model is --
The model is trained to give me information back about that. On the other end, we have custom models.
Where there's no preexisting model i can use or i have
Something domain specific with a -- where the preexisting
Models don't work for my situation. Ml.Netted -- ml.Net false into this category.
I'm going to do a demo the rest of the time. That's all the slides.
Because this is a short session i will use code snippets.
I don't want to spend the whole time walking through code i have
Already written. And in 20 minutes you wasn't --
We won't achieve knoche -- much.
I will send you to other zags you can get more detailed look
At ml.Net. For our scenario we have a piece
Of music. The problem with the music is
Some of the notes are missing from it.
I will swap to my demo machine.
Here we have the piece of music highlighted by the vertical bars
You see dropping down below the music.
Holder. [ Music ]
>> Obviously that's not what we fiant our music.
There are rules about music. What notes sound good together.
As developers we could find those rules and write code.
That would take a while because be complex.
We have a huge amount of data of existing songs that give us and
Idea of what notes sound good together. We'll use that existing data,
Train a machine learning model and use that to predict what
Notes should be inserted in the missing places.
The data set that we're going to use comes from uci.
And it's a data set that has some songs, it basically pulls
The melody out. The data setvy in visual studio
Here. Set is
A song. One, two, three, four, five and
A huge string of data that identifies which notes, how long
They are and where they are in the music et cetera.
>> The first thing we do when we're looking at training a
Model we need to do data manipulation to get in the right
Shape for our model. Here's a visual representation
Of the data we're getting. Notes in -- are grouped into
Measures. We're going to focus on each
Measure and as you know, floats assigned -- notes are assigned
Letters and we will twist the data to lock like this.
When we say there's a b and it also occurs in a bar with an a
And a c. And we'll repeat that for every
Measure and note. Because machine learning works
Better with numbers, we will assign numbers to the notes.
Music doesn't start at a it starts at c.
So we'll give it 0 through 11. The goal of what we're trying to
Do is we want to predict this note which is called the label.
Given all of these inputs. The other notes in the same
Section of music. Res
We're trying to predict on. >> So let's run through this in
Visual studio. I have a separate project where
I'm going to model. I don't want to do it in my
Actual client application because i don't need to rebuild
Every time. Just once on the data set and
We're working on a console application. I have implemented an [ indiscernible ]
I will not go into this. The way you implement data super
Dependent on the data you're working with.
In our case a small amount of data. I chose to load the whole thing
To memory and write it to csv. With a larger data set you might
Take a different approach. Let's run the
App. So my data manipulation routine
Finished and out put this modified
Csv. The first two are debugging.
It says which song it came from and which section of the song.
The rest of the notes here represents that data we just
Looked at on the slide. It says note and says whether
The other notes are press innocent the same measure.
Now that we have data in the right format pel it's time to --
Based on it. Now i have ml.Net installed.
And one of the types in there is >> the learning pipeline is the
Oing to go through to create the model.
The first step is to load the data up that is going to be part
Of the model. A csv
File. I give it the path to the file.
[ Indiscernible ] model here.
This is the object model that represents the input i will give
To the routine. Ly go to the definition of this.
This is the note number that we're trying to predict.
Obviously when we do an actual prediction it will be null
Because we don't know it. When we're training the model
That's known note number. Below that we have columns for
Talked about. E do know about the notes in the bar.
Now that we've got the data loaded, it's time to give ml.Net
A bit more information about how to interpret our data.
Represented as a numeric value that could have a -- any number
Of always have up to the limits of the type.
In our model there's a set number.
We will transform this into an internal type that it will use
To represent the notes. >> So to do that we copy the
Note number into another column into our data set called label.
Label is the column it needs to detect and calculate based on.
And use this diction ariser which will take our float number
And transform it to the buckets of data at 10 through 11.
We go through a similar process of features. We have a bunch of columns that
Data. We combine that into a column
Called features. Now we've -- now we have to
Train our model. >> On the pipeline we're going
To add a new trainer. Now i'm not going to drill into
This is the appropriate trainer for the problem we're trying to
Solve where we have a set number of inputs and classify the
Predicted out put. Now we need to tell ml.Net, once
It's done the prediction how do i output that prediction to the
Final result? the result is this predicted
Note class. You can see i have a single
Column here which is the note number we expect as the output.
>> So to tell ml.Net how to do that we go ahead and add this
Bit of code which is saying, when you get the calculator
Result, go and convert it from the internal data type that has
The 12 buckets, convert it back into a float to use in the
Application. Ned it we've defined the process for
It's time to create the model. Everything we've done so far
Hasn't actually caused any code to excompute.
It's -- execute. It's setting the logic it will flow threw.
We will -- through. We will create a model variable
And take the pipeline and train it.
We tell it what the input and output is.
This is going to be the no pre diction input and out put into a
Predicted note.
>> Not that. >> Now having the model in
Memory is no use to us here because we float use it in
This -- we will not use it in this application.
We will write it out to disc and i passed in the path i wanted
On. This an a-sync operationally
Await it.
>> Let's run an application and we should get a
Model. You'll see a bunch of output
That comes from ml.Net give. Inging information about what
It's doing internally. --
It would be good to test to make sure it's working.
Ly go to our test model method.
>> Here i've created input. I've said we know the key signature.
This is another aspect of music this section of music.
Note a and 11 are present. We want ml.Net to tell us what
Other note would sound good in that bar of music.
>> We need to load up our model. Now in this application we had
It --. In this application we had the
Model in memory but i want to test load it from file because
That's what i will do from the other. From here we will say the output
Equals we're going predict based
On the input. And we want to write the number
To console. Output note number.
Okay. So it said, note 9 which happens
To be an a would sound good with these other notes.
Now we know we have a working model. Let's integrate
It into our client application.
I will copy the zip file. And we'll close our console app
And move to our client application.
I can do a straight paste in here.
Music model is added to our project. I will is it to copy to the
Output directory so the application can consume it.
Now when the music loads, i already have it running through
The service called a music repairer.
But at the moment it's not implemented.
Notes. Some are missing which is
Represented by a note number of 0 and we will predict what those notes will be.
So again, this is the same goad we
Application. And from there, based on the
Note we have here, we need to predict. So we need to get the notes that
Are in the measure we need those in the input prediction.
I have a helper method already which will take the list of
Notes. Then we're going predict based
On that input. Now it's time to go change the note number.
So we're going to say note dot note which is a note number.
At this point we know it's an a, b or c.
There's lots of those. Base notes, high treble notes.
I have a alternated will find -- have a method that will find the
Note closest. I call that adjust to measure octave.
We pass the result and we pass the now notes.
Like i said that will work out which c will sound best.
Let's run again.
>> We see the notes represented.
I have them in red so it's easier to follow along.
Hit play. [ Music ]
>> Okay. Now in that one we were missing
A few notes. I was interested what would
Happen if we had data where we're missing a lot of notes.
The music is loaded from this file. You can see we have a few notes
Set to zero. I have an alternative version
Here where we have a whole bunch of notes set to zero.
Almost every second note is. Loading it is this here.
Damaged. Run
Again. From here a lot more red notes.
Predicted. Go ahead and play.
[ Music ] music.
[ Applause ] >> before i send you
Off on your way. There's a couple of things i
Want you to be aware of. If you're entered in learning
More the url at the top is the place to go to.
There's information and simple tutorials. This was a super quick overview
Ml.Net session which is 75-minute deep dive and everything you can do with it.
And later today, me and a couple others are going to take this
Music demo and a few other ai solutions and turn it into an
Interesting show of things you can do with ai and ml.Net.