[MUSIC PLAYING]
JASON MAYES: In this subchapter, you
will learn about what machine learning models actually are,
the types of machine learning that are most common,
whilst also gaining a high level understanding
of how they're trained to learn a new task, which will give you
a foundation to then go deeper with real examples later
in the course.
You will also learn what you need
to know when gathering data so that it has the best
chance of working well.
So let's get to it.
First, let's define what a machine learning model actually
is.
You'll hear the term "model" used a lot
in the context of ML.
And you can think of this as a magic black box, for which
the internal logic is hidden for now, that takes some inputs
and gives you some outputs.
The key thing to note here is that these inputs and outputs
are always numerical.
You'll learn more about this hidden logic
later in the course, when you start to write your own models.
But for now, you can think of it as essentially a bunch
of mathematics that transforms the inputs into the output
values, from which you can then make some useful decision.
For example, if the machine learning model
was designed to recognize different species of flower
from some input values, then each output number
may represent the probability of how confident it
was that a certain type of flower
was represented by those input values.
And what might those input values be, exactly?
Well, maybe they represent the color of the flower's petals.
Or maybe they represent the stem length.
Each model you make will require specific inputs
that represent something about the thing you're
trying to learn about.
And later, you'll see how you, as a machine learning engineer,
will define these for yourself.
But once you've fed data into the model,
you can then take the outputs and decide
if you want to do something based
on what it's predicted, if it has
a certain level of confidence.
In the example shown here, the system
produces outputs that range from 0 to 1.
So in this instance, if we take the highest number
on the outputs, we can see that rose
has the highest prediction, as it has the highest score.
In this particular example, the output
is actually a score of confidence.
So 0.78 out of 1 is equivalent to saying 78%.
Therefore, we also know that the system
is 78% sure that it saw a rose.
You can take this knowledge and use it
in your regular web application logic
to then do something useful.
In fact, often, the machine learning part of your program
will just be a small part of the overall code that you write.
Most of your code will be the regular programming that you're
already familiar with, namely the application logic, the user
interface, or retrieving something from, say,
a database on a server.
Now, the other thing I'd like to highlight at this point
is that initially the machine learning model is untrained.
And this means it's probably no better than flipping
a bunch of coins to decide what the output values are,
which is not very useful to you.
You must then train the model to make it good at a certain task.
And there are many different ways you can do that.
In fact, there are three key forms of machine learning
that are used today.
First up, and by far the most common, is supervised learning.
All this means is that the data that you'll
use to train the machine learning system
is prelabeled, like you see here on this scatterplot of fruit
data points.
Here, I plot the weight and color for some fruit samples.
Each data point has a corresponding label
associated with it that you know to be correct--
in this case, apples and oranges.
You therefore know the ground truth
for each example you're going to show the system to learn from.
This is important, because when you train the machine learning
system, at the start, it will be wrong a lot of time.
But it can realize this right away from unknown known labels
and then change itself slightly to automatically
be better next time around.
And if you think about it, this is
very similar to how human babies are taught.
You show them an object and then tell them the name for it.
And just like a human learning, you're
probably needing to show a few examples
before it will be able to distinguish
between such objects correctly.
Now, one thing to note here is that for an ML system,
you might need thousands of examples
if you're training your system from a completely blank canvas.
Often, there is a lot of variation for something
even as simple as an apple, as you can see here.
Size, shape, color, even textures and more
can change from one apple to another.
And as a computer is just dealing with numbers,
an image of an apple is essentially
millions of color values from an image.
So these variations can lead to very different outcomes
as far as the computer is concerned.
So if the system has only ever seen green apples
to learn from, it'll probably misclassify
other types of apples thinking it's something else.
Now, this point is really important.
Computers can only work with numbers.
This is very different to how you and I consciously
process data.
On the left is a magnified image of a person.
Now as a human, you can probably make out
where the face is pretty fast.
But a computer cannot see objects like you and I can.
It just sees numbers, as shown by the middle image.
Here, numbers from 0 to 255 represent different shades
of gray.
And on the right-hand side is what
would be fed into your machine learning model as an input.
Do you still see the face in that?
Well, as a human, it's nearly impossible
to recognize in this form.
But this is what your machine learning model
must learn from and somehow take these numbers to produce
some output that represent how sure it is that a face is
in those input numbers.
And this is why the quality of training data
is very important.
Generally speaking, the more diverse
and well-labeled your data, the better machine learning
model you'll be able to train that
can generalize well to unseen examples in the future.
Now, next up, we've got unsupervised learning.
Taking the same example as before,
you've got a bunch of example data plotted on the graph
as shown.
But in this situation, you don't know
what the labels are in advance.
The only thing you might know is how many classes you expect
to discover from the data.
Now, as you know from the previous example,
the data shown here represents apples and oranges,
which means two possible classes of data.
As such, you can train the machine learning program
to attempt to cluster the data together,
finding what data is most likely to be related.
Looking at these data points, you can instinctively
see as a human that there are two distinct clusters
of points, as shown, which the machine learning
program might also learn.
The program, however, doesn't know which cluster of points
represent an apple versus which is an orange.
In fact, it would not even know the existence of such things.
So it will return general class names, like class A or class B.
And then you would have to make the correlation later on.
One other point to note is that you might not always
know how many total classes there are in the data.
In this case, you might decide to take an educated guess,
for example, three, to see how well it
works with your data set.
And here, the machine learning system
will find three clusters for you,
even though there are only two real ones to be found.
The computer will always do what it's told.
And clustering like this, however,
can be useful in domains where true labels are hard to obtain,
while still allowing you to classify data
in meaningful ways.
In fact, unsupervised learning powers systems
you might already be using, like recommendation engines,
to find similarities between what person A bought
versus what person B currently has in a shopping
cart to suggest items for the person who is still shopping.
And once an unsupervised model has been trained,
it's typical that human testing has
been required to validate that it performs well
for the task at hand.
This is kind of the opposite of supervised learning, where
you spend more time up front labeling the data,
but can then be pretty sure that it works
as intended once trained, as it's able to score itself
as it goes along.
Finally, you've also got reinforcement learning.
But this is a newer area of research
that has had success in areas such as gaming, robotics,
and even scientific research, but can vary wildly
in performance depending on the problem at hand,
as it ultimately relies on trial and error.
In essence, this form of machine learning
tries to take actions to achieve a goal in such a way
to maximize a reward that's defined.
In this example, you can see a character
in a virtual environment learning
how to walk using reinforcement learning.
When it fails, it tries variations to attempt
to get better at the task.
But you might be surprised sometimes with the results.
Here, the character uses his arm to balance correctly
in a somewhat unnatural way.
But in this game, it works better
for the other things it had tried previously.
And what seems obvious to a human
might not be the result you see, as shown here.
So one must use such systems with caution
and thoroughly test for solution that it creates.
In the case of a computer game, the goal
might be to get a high score, for example.
And in a game like "Pac-Man," the system might get a reward
each time the character eats some food.
And if it hits a ghost, it receives a punishment.
And that's all the feedback it gets.
Each time it makes a winning move,
it strengthens the connections for the things
that it did previously.
And if it loses, it weakens the connections to what it tried.
Given some inputs that the image picks from a game,
it can then explore different combinations
of available actions that it can perform through thousands
or even millions of iterations until it finds
a combination of rules that link the inputs to the outputs such
that it can perform well at the task at hand.
Reinforcement learning is an active area of research
to be aware of and certainly one to monitor for the future.
But you'll find that supervised learning is where
you see most focus right now.
For that reason, you'll be focusing on supervised learning
in this course, which, at present, is
one of the most used and mature forms of ML, which
can solve many of the common problems
that you'll encounter in the industry today.
So head on to the next video to learn
how you can train ML systems.
[MUSIC PLAYING]