We just talked about the concept of
training a model in the previous lecture.
In that context, it is important to understand
that this is probably the hardest and most
complicated part of the whole process
when developing a machine learning solution. Training a
model is not an easy task like just
run some algorithm on the training dataset
and we will get the best trained model.
The challenge is to make the model more generic,
making sure it is performing well on unseen data.
We need to remember that the learning algorithm
created the model while trying to optimize something.
It's all about optimization.
It's a process of adjusting a model step by step
to get the best performance on the training dataset.
On the other end, the objective of the machine
learning system is to be able to make good
prediction on data it has never seen before.
This is called generalization.
A well generalized model is a model where
the patterns learned from the examples provided in
the training dataset can be successfully used
also on new unseen data instances.
That's the whole objective of any machine learning solution
to make good prediction on new data, okay,
not on the training dataset.
As I mentioned, this is not an easy task
and there are two main challenges to overcome before
we can get a well generalized model.
Those challenges are called
underfitting and overfitting.
Starting with underfitting, underfitting refers to a
situation that the trained model is not
working well on the training data and
of course cannot generalize to new data.
The trained model didn't capture the
underlying structure of the data.
If this is the end result of the
learning algorithm, then something is not working.
Take a look on the following simple two charts.
We have multiple points as the training dataset
and one linear line created by some learning algorithm
which was supposed to represent the model.
The line itself is the model.
We can easily see that on the left side,
this linear line is not really representing the patterns
in the data, which is the problem of underfitting.
On the other end, the line in the second graph
is not linear and can better represent the patterns.
It has better fit to the training data.
Now, what are the main reasons for underfitting?
The first one is that the model is probably too
simple and we need to build a more complex model
that can better learn the underlying structure of the data.
In that case, it makes sense
to try a different learning algorithm.
For example, here we moved from an algorithm
that will build a linear line to an
algorithm that can build non-linear line, okay.
That will better represent the underlying data.
The second reason for underfitting is that the
training dataset is not good enough.
Maybe there are not enough examples, or
maybe the input features of the provided
example are not informative enough.
Like providing an algorithm just the size
of a house without other related features,
it's not enough. On the other end,
underfitting is also a standard
transition phase of any training model.
During the training process, the learning algorithm
will build and adjust the model while
performing a certain number of iteration.
At the beginning of training, the model will
underfit the training data because it is just
started to model the relevant patterns.
And in each learning iteration, the model performance
should improve again and again, making the model
a much better fit to the training data.
Okay, so it will be a transition phase from
an underfitting model until to a fitting model.
If we keep trying to improve the model, there is a
danger that we can create a model that is overfitting
the dataset and now are moving to the second challenge.
After reaching some optimum point when the algorithm is
running over the dataset, the model testing performance
will start to degrade, which means the model is
starting to overfit the training data learning patterns that
are too specific to the training data and will
be irrelevant to new data.
As a simple analogy, let's say we just bought
a few grocery items in the local supermarket, like
20 items during our vacation in a different country.
The overall price of that basket
was relatively cheaper than our expectation.
It surprised us in a positive way.
And when going back home, we told our friends
that the supermarkets in that country are unbelievable cheaper.
What do you think, is it a reasonable conclusion?
Well, not really.
We just overgeneralized a pattern about something from a
relatively very small amount of samples for that small
amount of items we bought in the supermarket.
It is making sense.
It is nicely fitting with the conclusion.
Maybe we are right and maybe we are completely wrong.
It makes sense to check a much larger amount
of items in the supermarket before making a conclusion.
Now when the same thing happens in
machine learning, it is called overfitting.
Overfitting is a very common
situation when training models.
It means that the trained model we created
performs very well on the training data, but
it does not generalized well to new data.
The model is not performing well on new data.
Looking on the same graph when drawing
a line that is perfectly connecting the
points is an example of overfitting.
For those points in our training
dataset it is perfect.
But when we use it for new data
points, this model will not perform so well.
But why when using the training data
set we encounter such an overfitting situation?
Well, there are few common reasons.
The training dataset is a
sample of much larger distribution.
If we take 100 items in a supermarket to be
compared on a price level with the same items in
a different supermarket, it is a small sample.
It's not all the items available in the
supermarket, which can be millions of items.
Maybe if we will compare 1000 items or
10,000 items, we will get much better distribution
of data about the items in the supermarket.
The same challenge is when training a
model using the training dataset.
The training dataset is a sample.
It is a group of examples.
It should be a large sample size that will resemble
as good as possible the true distribution of the data.
This is the key issue to remember.
The training data should represent the distribution
of the data as much as possible,
otherwise it will just overfit the training data.
The next reason it can be also too complex model.
The objective of a model is to fit the data well, but
at the same time fit the data as simple as possible.
It is a careful balance.
If the model is too complex while trying
to fit perfectly the training data, then we
increase the risk of overfitting anyway.
Even if we took a very large data
set, how can we discover such problems?
How can we trust that the model will
also make a good job on new data?
Maybe it is overfitting the training dataset
and it's not generalized well to new data.
The answer is that we will need to test the
model performance on a separate dataset to check and
validate that our model is working well on new data.
It is called the test dataset.
The concept is quite simple.
We will have a group of examples to train a
model and another group of example to test the model.
We'll talk about it later in this training. As
a quick summary of the key things to remember.
Training a model is not an easy task.
It's actually the core job of a data
scientist when building a machine learning project.
The challenge is to make
the trained model more generic.
Making sure it is performing well on
unseen data, making the model well generalized.
There are two main challenges
to overcome, underfitting and overfitting.
Underfitting is when the training model is not working
well on the training dataset and of course cannot
generalize to new data. Overfitting which is more complex
problem is when the training model we created
perform very well on the training data, but
it does not generalize well to new data.
The model is not performing well on new data. Okay.
Overall, this section was a high level
introduction to the basic machine learning terminology.
Please post a question if you
would like to ask something.
In the next section, we are going to talk
about the main classification of machine learning system.
[No audio]