5
$\begingroup$

Many people (including me) is thinking or used to think that an overfitted model is the model in which the training error >> the validation error. But after reading this very interesting comment by @Firebug, I suddenly realized that it is not true. Random Forest is a perfect example of this, the training error is often closed to 0, the out-of sample is often far smaller than the latter but close to the test sample.

Another example is presented below:

enter image description here

People often refer the green curve as overfitting, and the black curve is better because the testing error of the green curve is lower than that of the training set. But it can happen that even the testing error of the green curve is lower than training error, but on the other blind test, the green curve is still better than the black curve.

So my questions are:

  1. Is the black curve better than the green curve?
  2. what exactly is overfitting, and what is the proper way of identifying an overfitted model?
  3. It is not true to say that an overfitted model is worse than the non-overfitted model?
$\endgroup$
  • $\begingroup$ RF doesn't alway give 0... We have many questions asking why the training errors are high. $\endgroup$ – HelloWorld May 24 '17 at 14:22
  • 1
    $\begingroup$ @SmallChess: it was written "often" on the question. $\endgroup$ – Metariat May 24 '17 at 14:24
  • $\begingroup$ When we fit a model, we generally tune it by looking at validation performance, not training performance. If the test performance is considerably worse than validation and unacceptable, then it's overfitting. $\endgroup$ – HelloWorld May 24 '17 at 14:24
  • $\begingroup$ I disagree "often" or anything like "regular", but it depends on the problem so let's not get into it. RF on the simple titanic data set gives about 98% accuracy. Kaggle has details, so it's not close to 0. Titantic is very very simple. $\endgroup$ – HelloWorld May 24 '17 at 14:25
  • $\begingroup$ It depends on your perspective but in my opinion 98% accuracy is pretty close to the 0% error. $\endgroup$ – Metariat May 24 '17 at 14:59
7
$\begingroup$
  1. You can't determine which curve is better by staring at them. And by "staring" I mean analyzing them based on pure statistical features of this particular sample.

For instance, the black curve is better than the green one if the blue dots that stick out of the blue area into the red are by a pure chance, i.e. random. If you obtained another sample and the blue dots in the red area disappeared, while other blue dots showed up, this would mean that the black curve is truly capturing the separation, and the deviations are random. BUT how would you know this by looking at this ONE sample?! You can't.

Therefore, lacking the context it is impossible to say which curve is better by just staring at this sample and the curves on it. You need exogenous information, which could be other samples or your knowledge of the domain.

  1. Overfitting is the concept, and there's no one right way of identifying the issue that works for any domain and any sample. It's case by case.

Like you wrote the dynamics of error reduction in training and testing samples is one way. It goes to the same idea that I wrote above: detecting that the deviations from the model are random. For instance, if you obtained another sample, and it rendered the different blue points in red area but these new points were very close the old one - this would mean that the deviations from the black line are systematic. In this case you would naturally gravitate towards the blue line.

So, overfitting in my world is treating random deviations as systematic.

  1. Overfitting model is worse than non overfitting model ceteris baribus. However, you can certainly construct an example when the overfitting model will have some other features that non-overfitting model doesn't have, and argue that it makes the former better than the latter.

The main issue with overfitting (treating random as systematic) will mess up its forecasts. It does so mathematically because it becomes very sensitive to those inputs that are not important. It converts the noise in inputs into a false signal in the response, while the non-overfitting ignores the noise and produces smoother response, hence higher signal to noise ratio in the output.

$\endgroup$
  • $\begingroup$ This is what I think as well! $\endgroup$ – Metariat May 31 '17 at 13:20
  • $\begingroup$ but how do you conclude the black curve is better than the blue one if the diviations are random? There's a chance that the blue one is better than the black one, and vice versa. $\endgroup$ – Metariat Jul 11 '17 at 9:18
  • $\begingroup$ @Metariat, that's the point, if the deviations are random you don't know much about the shape of the border between the colors, so it's unlikely that the green shape is accurate and you go with a smoother black line $\endgroup$ – Aksakal Jul 11 '17 at 13:23
3
$\begingroup$

From wikipedia:

In overfitting, a statistical model describes random error or noise instead of the underlying relationship. Overfitting occurs when a model is excessively complex, such as having too many parameters relative to the number of observations. A model that has been overfit has poor predictive performance, as it overreacts to minor fluctuations in the training data.

So basically when training a model on data, you are both fitting noise and structure. The noise comes from sampling error and as a machine learning designer your job is to design the algorithm such that it fits as much of the stucture as posible without getting to much noise, such that the performance degenerates. So looking at it from a marginal perspective say you add one unit of complexity to your model. The marginal performance change is now composed as a bias reduction term from the additional structure you are fitting and variance term from the noise you are fitting. When the marginal variance effect is larger then the marginal bias effect you are overfitting. Standard illustration of bias and variance below.

enter image description here

By the way the assymtotic training error of random forest classification is 0 (at least if there are not identical observations with different classes). This is true since on all predictions are present in on average 62 % of the estimators and each of these estimators have the correct prediction. So given enough trees the law of large numbers will assure that the correct class will have at least a score of 0.62 no matter the predictions when the observation is not used to fit the estimator.

$\endgroup$
  • 2
    $\begingroup$ Why do you say "the asymptotic training error of random forest classification is 0"? What if there are training points with identical X but different Y? In that case any model must make training errors, since the prediction is constant for a given X. $\endgroup$ – Adrian May 31 '17 at 13:15
  • 1
    $\begingroup$ Good catch Adrian. Differently relevant if the number of variables are very low. Correction added to the answer. $\endgroup$ – Peter Mølgaard Pallesen Jun 2 '17 at 7:26
0
$\begingroup$

Overfitting is when you end up modeling noise in the data which results in lower classification error on training data but reduces the accuracy on not-seen(validation data).

Say you have 10 pairs: $(x,2x+e)$ plotted with you with e as a small random error. You can definitely model this perfectly with a 9 degree polynomial. But that would be overfitting as this is mostly not the correct model. The correct model is y = 2x. In this light you can even see what two most popular solutions to this problem are 1. Get more data 2. Keep the model simpler (Less number of parameters)

$\endgroup$
0
$\begingroup$

ELI5 version: Consider a neural network having 1M parameters for classifying cat-dog. We can assume each parameter of 1M as a linear line fitting a yes/no question for features like if the img has tail, claws etc. what happens here is we have more than enough questions/parameters to infer if a given img is cat/dog and we learn extra information including background etc which can be in train distribution and may not be in validation distribution.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.