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.
-
5$\begingroup$ This question is much broader than just for machine learning, neural networks, etc. It applies to examples as simple as fitting a polynomial. $\endgroup$– gerritCommented Jan 7, 2016 at 10:24
-
4$\begingroup$ stats.stackexchange.com/a/128625/11849 $\endgroup$– RolandCommented Jan 7, 2016 at 12:39
-
7$\begingroup$ @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?" $\endgroup$– DoubleDoubleCommented Jan 7, 2016 at 19:33
-
3$\begingroup$ @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. $\endgroup$– ShazCommented Jan 7, 2016 at 19:39
-
2$\begingroup$ 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?" $\endgroup$– FalcoCommented Jan 8, 2016 at 10:35
12 Answers
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.
-
2$\begingroup$ "Learning from the noise" sounds vague to me. What exactly happens? Can you give an example? $\endgroup$– RaphaelCommented Jan 7, 2016 at 10:28
-
1$\begingroup$ 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. $\endgroup$ Commented Jan 7, 2016 at 11:00
-
2$\begingroup$ @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. $\endgroup$– DrakarahCommented Jan 8, 2016 at 13:40
-
2$\begingroup$ @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 $\endgroup$– DrakarahCommented Jan 8, 2016 at 18:33
-
1$\begingroup$ 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 $\endgroup$ Commented Jan 8, 2016 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.
-
10$\begingroup$ And to that other question, this is what "learning from the noise" means. $\endgroup$ Commented Jan 7, 2016 at 16:07
-
$\begingroup$ To the rain comment - But we DO do that, then we keep working that way and learn more later. $\endgroup$ Commented Jan 7, 2016 at 21:08
-
14$\begingroup$ @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. $\endgroup$ Commented Jan 7, 2016 at 21:36
-
1$\begingroup$ This problem does not only apply to poorly learning robots but also poorly learning people. $\endgroup$ Commented Jan 8, 2016 at 14:19
-
$\begingroup$ I don't quite follow: Rain shouldn't be a predictor variable in the first place, what does it have to do with overfitting? $\endgroup$– mucahoCommented Jan 9, 2016 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.
-
$\begingroup$ 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 $\endgroup$ Commented Jan 6, 2016 at 23:26
-
2$\begingroup$ @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! $\endgroup$ Commented Jan 7, 2016 at 4:50
-
$\begingroup$ 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. $\endgroup$ Commented Jan 7, 2016 at 6:35
-
1$\begingroup$ @FriendlyPerson44 What does that have to do with why overfitting is bad? $\endgroup$ Commented Jan 7, 2016 at 20:09
Roughly speaking, over-fitting typically occurs when the ratio
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.
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:
I would advise to watch Coursera' Machine Learning course, section "10: Advice for applying Machine Learning".
-
2$\begingroup$ 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' $\endgroup$ Commented Jan 7, 2016 at 20:18
-
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.
-
$\begingroup$ 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. $\endgroup$– FalcoCommented Jan 8, 2016 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:
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.
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.
-
$\begingroup$ Also see this related question on CrossValidated. $\endgroup$ Commented Jan 7, 2016 at 22:47
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:
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:
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.
-
$\begingroup$ 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. $\endgroup$– EmreCommented Jan 10, 2016 at 21:41
-
1$\begingroup$ @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. $\endgroup$ Commented Jan 10, 2016 at 21:45
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.
-
4$\begingroup$ 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. $\endgroup$– RaphaelCommented Jan 7, 2016 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:
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...
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.
-
$\begingroup$ Stereotyping is what laypersons call overfitting. $\endgroup$– EmreCommented Jan 7, 2016 at 8:07
-
3$\begingroup$ 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. $\endgroup$ Commented Jan 7, 2016 at 8:30
-
9$\begingroup$ @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. $\endgroup$ Commented Jan 7, 2016 at 8:34
-
$\begingroup$ 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. $\endgroup$ Commented Jan 7, 2016 at 21:20
-
3$\begingroup$ @ArnabDatta Overfitting is matching an excessively complicated model too precisely to the training data; stereotyping is the use of an excessively simplified model. $\endgroup$ Commented Jan 8, 2016 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)
-
$\begingroup$ 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. $\endgroup$ Commented Jan 8, 2016 at 21:00