Computer Science Stack Exchange is a question and answer site for students, researchers and practitioners of computer science. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've studied this lots, and they say overfitting the actions in machine learning is bad, yet our neurons do become very strong and find the best actions/senses that we go by or avoid, plus can be de-incremented/incremented from bad/good by bad or good triggers, meaning the actions will level and it ends up with the best(right), super strong confident actions. How does this fail? It uses positive and negative sense triggers to de/re-increment the actions say from 44pos. to 22neg.

share|cite|improve this question
4  
This question is much broader than just for machine learning, neural networks, etc. It applies to examples as simple as fitting a polynomial. – gerrit Jan 7 at 10:24
4  
7  
@FriendlyPerson44 After re-reading your question I think there is a major disconnect between your title and your actual question. You seem to be asking about the flaws in your AI (which is only vaguely explained)- while people are answering "Why is overfitting bad?" – DoubleDouble Jan 7 at 19:33
3  
@DoubleDouble I agree. In addition, the connection between machine learning and neurons is dubious. Machine learning has nothing to do with 'acting brain-like', simulating neurons, or simulating intelligence. It seems there are a lot of different answers that might help OP at this point. – Ryan Jan 7 at 19:39
2  
You should sharpen your question and the title. Maybe to : "Why do we have to guard a virtual brain against overfitting while the human brain works great without any countermeasures against overfitting?" – Falco Jan 8 at 10:35

12 Answers 12

The best explanation I've heard is this:

When you're doing machine learning, you assume you're trying to learn from data that follows some probabilistic distribution.

This means that in any data set, because of randomness, there will be some noise: data will randomly vary.

When you overfit, you end up learning from your noise, and including it in your model.

Then, when the time comes to make predictions from other data, your accuracy goes down: the noise made its way into your model, but it was specific to your training data, so it hurts the accuracy of your model. Your model doesn't generalize: it is too specific to the data set you happened to choose to train.

share|cite|improve this answer
1  
"Learning from the noise" sounds vague to me. What exactly happens? Can you give an example? – Raphael Jan 7 at 10:28
    
even if your data is very clean and out of outliers(both natural and non-natural outliers) still "overfitting" is a bad practice and should be eliminated from your model. when your model is "overfitted" that's mean is your model didn't generalize the knowledge hidden in the data, and can't predict any other data points. Simply when you overfit your model you fit it only on your train/test dataset. – Aboelnour Jan 7 at 11:00
2  
@Raphael The system starts seeing the noise in the training set as features. If you then run the net on real data where that specific noise is missing you'll end up with a lower probability because there are features (= the noise that was included) missing. – drake7707 Jan 8 at 13:40
1  
@Raphael What about for example:I have a collection of images from a traffic camera. Let's train a net that detects whether there are cars present or not. After some training I have it gives a set with cars and without cars, great! Let's apply the net on a new set to detect whether a street is empty without people and huh, why doesn't it detect my empty street with a high probability? Looking back on the sample set and I notice that in every picture there were people in the background of images when there weren't any cars. Due to overfitting the net it laid emphasis on the people being present – drake7707 Jan 8 at 18:33
1  
Consider a system which has noise added by a coin flip. On heads, you add 1 to the value ,and on tails you add 0. To make the results obvious, we'll choose an absurdly small data set of two points: (2, 5) and (2.1, 8). The coin flip lands heads for the first point, tails for the second, introducing noise, making the dataset (3, 5), (2.1, 8). Now the neural net is learning from a dataset that looks like there is a significant correlation between the x and y values, even though almost all of it was noise. If you then send this 'net out at real data, its going to generate a lot of wrong results – Cort Ammon Jan 8 at 18:54

ELI5 Version

This is basically how I explained it to my 6 year old.

Once there was a girl named Mel ("Get it? ML?" "Dad, you're lame."). And every day Mel played with a different friend, and every day she played it was a sunny, wonderful day.

Mel played with Jordan on Monday, Lily on Tuesday, Mimi on Wednesday, Olive on Thursday .. and then on Friday Mel played with Brianna, and it rained. It was a terrible thunderstorm!

More days, more friends! Mel played with Kwan on Saturday, Grayson on Sunday, Asa on Monday ... and then on Tuesday Mel played with Brooke and it rained again, even worse than before!

Now Mel's mom made all the playdates, so that night during dinner she starts telling Mel all about the new playdates she has lined up. "Luis on Wednesday, Ryan on Thursday, Jemini on Friday, Bianca on Saturday -"

Mel frowned.

Mel's mom asked, "What's the matter, Mel, don't you like Bianca?"

Mel replied, "Oh, sure, she's great, but every time I play with a friend whose name starts with B, it rains!"


What's wrong with Mel's answer?

Well, it might not rain on Saturday.

Well, I don't know, I mean, Brianna came and it rained, Brooke came and it rained ...

Yeah, I know, but rain doesn't depend on your friends.

share|cite|improve this answer
10  
And to that other question, this is what "learning from the noise" means. – Kyle Hale Jan 7 at 16:07
    
To the rain comment - But we DO do that, then we keep working that way and learn more later. – Friendly Person 44 Jan 7 at 21:08
13  
@FriendlyPerson44 You're correct, people make mistakes and do bad things like overfit. Your question asked why overfitting is bad, not whether or not people do it. – Kyle Hale Jan 7 at 21:36
1  
This problem does not only apply to poorly learning robots but also poorly learning people. – Tomáš Zato Jan 8 at 14:19
    
I don't quite follow: Rain shouldn't be a predictor variable in the first place, what does it have to do with overfitting? – mucaho Jan 9 at 11:05

Overfitting implies that your learner won't generalize well. For example, consider a standard supervised learning scenario in which you try to divide points into two classes. Suppose that you are given $N$ training points. You can fit a polynomial of degree $N$ that outputs 1 on training points of the first class and -1 on training points of the second class. But this polynomial would probably be useless in classifying new points. This is an example of overfitting and why it's bad.

share|cite|improve this answer
    
But its super overfitted actions are linked to specific senses, and only when it sees the same senses again it matches memory and links to these actions, it won't do them when it sees other things. Generalizing is two things - all these tree images are tree, and use knowledge from past to figure this new thing out. For my AI to solve this, it sees a tree and hears "tree", and that matches memory and brings it to front, then it sees new trees and their names and they all link to senses in latest memory -the first tree image & sound. Figuring out new little related thing by knwldge is new actio – Friendly Person 44 Jan 6 at 23:26
2  
@FriendlyPerson44 In supervised machine learning, the outcome of the training should not need to change any further. This is where "overfitting" comes into play. It would be as if the machine had learned to recognize a tree - first by the colors, then the general shape, then a specific shape (where it should stop), but then it starts distinguishing trees by additional random patterns it found only in your training set. When you let it see new random pictures of trees, it decides those aren't trees. At that point, the worst case is that it is in use and nobody is supervising it! – DoubleDouble Jan 7 at 4:50
    
But mine recognizes a tree by saving the tree image and sound "tree" and linking the two senses together, and when tree is said it matches what's in memory and brings the match and any linked to it to front of memory and then when shown other trees and called new names these images & sounds like to the first learned ones. Trees aren't it's triggers though, food ect are, it isn't going to save actions when sees a color or pattern. Mine really learns the actions. – Friendly Person 44 Jan 7 at 6:35
1  
@FriendlyPerson44 What does that have to do with why overfitting is bad? – DoubleDouble Jan 7 at 20:09

Roughly speaking, over-fitting typically occurs when the ratio

enter image description here

is too high.

Think of over-fitting as a situation where your model learn the training data by heart instead of learning the big pictures which prevent it from being able to generalized to the test data: this happens when the model is too complex with respect to the size of the training data, that is to say when the size of the training data is to small in comparison with the model complexity.

Examples:

  • if your data is in two dimensions, you have 10000 points in the training set and the model is a line, you are likely to under-fit.
  • if your data is in two dimensions, you have 10 points in the training set and the model is 100-degree polynomial, you are likely to over-fit.

enter image description here

From a theoretical standpoint, the amount of data you need to properly train your model is a crucial yet far-to-be-answered question in machine learning. One such approach to answer this question is the VC dimension. Another is the bias-variance tradeoff.

From an empirical standpoint, people typically plot the training error and the test error on the same plot and make sure that they don't reduce the training error at the expense of the test error:

enter image description here

I would advise to watch Coursera' Machine Learning course, section "10: Advice for applying Machine Learning".

share|cite|improve this answer
1  
I like the "learning by heart" line because humans are capable (and do) do this to some extent. Imagine take an extremely difficult quiz in which the questions and answers never change but you are told the answers when you get them incorrect. Pretend the equation (2+2) is difficult, you recognize the equation and say '4' - but then (2+3) comes along, but you haven't learned to add, you've just learned to say '4' when you have '2+2' – DoubleDouble Jan 7 at 20:18
    
nice explanation – Nikos M. Jan 13 at 23:16

I think we should consider two situations:

Finite training

There is a finite amount of data we use to train our model. After that we want to use the model.

In this case, if you overfit, you will not make a model of the phenomenon that yielded the data, but you will make a model of your data set. If your data set is not perfect - I have trouble imagining a perfect data set - your model will not work well in many or some situations, depending on the quality of the data you used to train on. So overfitting will lead to specialization on your data set, when you want generalization to model the underlying the phenomenon.

Continuous learning

Our model will receive new data all the time and keep learning. Possibly there is an initial period of increased elasticity to get an acceptable starting point.

This second case is more similar to how the human brain is trained. When a human is very young new examples of what you want to learn have a more pronounced influence than when you are older.

In this case overfitting provides a slightly different but similar problem: systems that fall under this case are often systems that are expected to perform a function while learning. Consider how a human is not just sitting somewhere while new data is presented to it to learn from. A human is interacting with and surviving in the world all the time.

You could argue that because the data keeps coming, the end result will work out fine, but in this time span what has been learned needs to be used! Overfitting will provide the same short time effects as in case 1, giving your model worse performance. But you are dependent on the performance of your model to function!

Look at at this way, if you overfit you might recognize that predator that is trying to eat you sometime in the future after many more examples, but when the predator eats you that is moot.

share|cite|improve this answer
    
Good answer for the question which the op implies: "Why do we have to prevent overfitting in virtual brains, when our brains seem to work ok, without any overfitting-compensation" - beacause a machine is trained, while humans learn for themselves. – Falco Jan 8 at 10:32

Let's say you want teach the computer to determine between good and bad products and give it the following dataset to learn: diagram with dataset. 0 to 50 are 0. 52 and 74 are 0. Remaining values from 51 to 100 are 1

0 means the product is faulty, 1 means it is OK. As you can see, there is a strong correlation between the X and Y axis. If the measured value is below or equal 50 it very likely (~98%) that the product is faulty and above it is very likley (~98%) it is OK. 52 and 74 are outliers (either measured wrong or not measured factors playing a role; also known as noise). The measured value might be thickness, temperature, hardness or something else and it's unit is not important in this example So the generic algorithm would be

if(I<=50)
    return faulty;
else
    return OK;

It would have a chance of 2% of misclassifying.

An overfitting algorithm would be:

if(I<50)
    return faulty;
else if(I==52)
    return faulty;
else if(I==74)
    return faulty;
else
    return OK;

So the overfitting algorithm would misclassify all products measuring 52 or 74 as faulty allthough there is a high chance that they are OK when given new datasets/used in production. It would have a chance of 3,92% of misclassifying. To an external observer this misclassification would be strange but explainable knowing the original dataset which was overfitted.

For the original dataset the overfitted algorithm is the best, for new datasets the generic (not overfitted) algorithm is most likely the best. The last sentence describes in basic the meaning of overfitting.

share|cite|improve this answer

In my college AI course our instructor gave an example in a similar vein to Kyle Hale's:

A girl and her mother are out walking in the jungle together, when suddenly a tiger leaps out of the brush and devours her mother. The next day she is walking through the jungle with her father, and again the tiger jumps out of the brush. Her father yells at her to run, but she replies "Oh, it's ok dad, tigers only eat mothers."

But on the other hand:

A girl and her mother are out walking in the jungle together, when suddenly a tiger leaps out of the brush and devours her mother. The next day her father finds her cowering in her room and asks her why she isn't out playing with her friends. She replies "No! If I go outside a tiger will most certainly eat me!"

Both overfitting and underfitting can be bad, but I would say that it depends upon the context of the problem you are trying to solve which one worries you more.

share|cite|improve this answer
    
Also see this related question on CrossValidated. – Blackhawk Jan 7 at 22:47

Take a look at this article, it explains overfitting and underfitting fairly well.

http://scikit-learn.org/stable/auto_examples/model_selection/plot_underfitting_overfitting.html

The article examines an example of signal data from a cosine function. The overfitting model predicts the signal to be slightly more complicated function (that is also based on a cosine function). However, the overfitted model concludes this based not on generalization but on memorization of noise in the signal data.

share|cite|improve this answer
4  
If that link breaks, your answer will be next to worthless. Please give at least a summary (with attribution, of course) so that the answer has value independent of that link. – Raphael Jan 7 at 13:37

With no experience in machine learning and judging from @jmite's answer here is a visualization of what I think he means:

Random graph of approximate right shape for demonstration

Assume the individual bars in the graph above are your data, for which your trying to figure out the general trends to apply to larger sets of data. Your goal is to find the curved line. If you overfit - instead of the curved line shown, you connect the top of every individual bar together, and then apply that to your data set - and get a weird in-accurate spiky response as the noise (variations from the expected) gets exaggerated into your real-practice data sets.

Hope I've helped somewhat...

share|cite|improve this answer

One that I have actually encountered is something like this. First, I measure something where I expect the input to output ratio to be roughly linear. Here's my raw data:

Input   Expected Result
1.045   0.268333453
2.095   0.435332226
3.14    0.671001483
4.19    0.870664399
5.235   1.073669373
6.285   1.305996464
7.33    1.476337174
8.38    1.741328368
9.425   1.879004941
10.47   2.040661489

And here that is a graph:

enter image description here

Definitely appears to fit my expectation of linear data. Should be pretty straightforward to deduce the equation, right? So you let your program analyze this data for a bit, and finally it reports that it found the equation that hits all of these data points, with like 99.99% accuracy! Awesome! And that equation is... 9sin(x)+x/5. Which looks like this: enter image description here

Well, the equation definitely predicts the input data with nearly perfect accuracy, but since it is so overfitted to the input data, it's pretty much useless for doing anything else.

share|cite|improve this answer
    
I think overfitting is more of a question of what you do incorrectly once you have the input data. Here there is nothing you can do; the inputs are inadequate because there is undersampling. – Emre Jan 10 at 21:41
1  
@Emre: I don't intend for undersampling, I intended for the input/output to be linear, but the over-fitting produced an equation that was clearly non-linear. I will edit to clarify. – Mooing Duck Jan 10 at 21:45

Overfitting in real life:

White person sees news story of black person committing crime. White person sees another news story of black person committing a crime. White person sees a third news story of black person committing a crime. White person sees news story about white person wearing red shirt, affluent parents, and a history of mental illness commit a crime. White person concludes that all black people commit crime, and only white people wearing red shirts, affluent parents, and a history of mental illness commit crime.

If you want to understand why this kind of overfitting is "bad", just replace "black" above with some attribute that more or less uniquely defines you.

share|cite|improve this answer
    
Stereotyping is what laypersons call overfitting. – Emre Jan 7 at 8:07
3  
That's not overfitting. Overfitting would be the system deciding that the only people who are criminals are those who have the same skin colour, shirt colour, parental income and history of mental illness as one of the criminals in the news reports. – David Richerby Jan 7 at 8:30
8  
@Emre No, stereotyping is the exact opposite of overfitting. Stereotyping is coming to conclusions that ignore most of the properties of the training data. Overfitting is coming to the conclusion that only data that every point in the training data perfectly describes part of the thing you're trying to recognise. – David Richerby Jan 7 at 8:34
    
Moderator note: off-topic/out-of-context comments deleted. For general discussion, please visit Computer Science Chat. If you have a question about a particular program that may or may not be using overfitting usefully, please ask a new question. – Gilles Jan 7 at 21:20
2  
@ArnabDatta Overfitting is matching an excessively complicated model too precisely to the training data; stereotyping is the use of an excessively simplified model. – David Richerby Jan 8 at 9:04

Any data you test will have properties you want it to learn, and some properties that are irrelevant that you DON'T want it to learn.

John is age 11
Jack is age 19
Kate is age 31
Lana is age 39

Proper fitting: The ages are approximately linear, passing through ~age 20
Overfit: Two humans cannot be 10 years apart (property of noise in the data)
Underfit: 1/4 of all humans are 19 (stereotyping)

share|cite|improve this answer
    
Welcome! We already have lots of informal examples so I'm not sure this adds much. And it seems hard to make this example more formal. For example, what is the linear function you mention? The input to the function seems to be the person's name, which isn't a number. Meanwhile, "two humans cannot be ten years apart" and "1/4 of humans are 19" aren't examples of functions being learnt from the data. – David Richerby Jan 8 at 21:00

protected by Gilles Jan 10 at 19:40

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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