ArticleslgStudy

biology

Generalization error

Generalization error is a biology topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Generalization error rather than just read about it. In short: For supervised learning applications in machine learning and statistical learning theory, generalization error (also known as the out-of-sample error, the probability of error, or the risk) is a measure of how accurately an algorithm is able to predict outcomes for previously unseen data. As learning algorithms are evaluated on finite samples, the evaluation of a learning algorithm may be sensitive to sampling error.

Generalization error — main illustration
Generalization error — illustration

Key takeaways

  • Generalization error belongs to biology; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Generalization error to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Generalization error from memory before moving on to harder problems.

Reference excerpt

For supervised learning applications in machine learning and statistical learning theory, generalization error (also known as the out-of-sample error, the probability of error, or the risk) is a measure of how accurately an algorithm is able to predict outcomes for previously unseen data. As learning algorithms are evaluated on finite samples, the evaluation of a learning algorithm may be sensitive to sampling error. As a result, measurements of prediction error on the current data may not provide much information about the algorithm's predictive ability on new, unseen data. The generalization error can be minimized by avoiding overfitting in the learning algorithm. The performance of machine learning algorithms is commonly visualized by learning curve plots that show estimates of the generalization error throughout the learning process.

Definition

In a learning problem, the goal is to develop a function fn(x→) that predicts output values y for each input datum x→. The subscript n indicates that the function fn is developed based on a data set of n data points. The generalization error, or expected loss, or risk I[f] of a particular function f over all possible values of x→ and y is the expected value of the loss function V(f):

I[f]=∫X×YV(f(x→),y)ρ(x→,y)dx→dy, where ρ(x→,y) is the unknown joint probability distribution for x→ and y. Without knowing the joint probability distribution ρ, it is impossible to compute I[f]. Instead, we can compute the error on sample data, which is called empirical error (or empirical risk). Given n data points, the empirical error of a candidate function f is:

In[f]=1n∑i=1nV(f(x→i),yi) An algorithm is said to generalize if:

limn→∞I[f]−In[f]=0 The aim of many problems in statistical learning theory is to bound or characterize the difference of the generalization error and the empirical error in probability:

PG=P(I[fn]−In[fn]≤ε)≥1−δn That is, the goal is to characterize the probability 1−δn that the generalization error is less than the empirical error plus some error bound ϵ (generally dependent on δ and n). For many types of algorithms, it has been shown that an algorithm has generalization bounds if it meets certain stability criteria. Specifically, if an algorithm is symmetric (the order of inputs does not affect the result), has bounded loss and meets two stability conditions, it will generalize. The first stability condition, leave-one-out cross-validation stability, says that to be stable, the prediction error for each data point when leave-one-out cross validation is used must converge to zero as n→∞. The second condition, expected-to-leave-one-out error stability (also known as hypothesis stability if operating in the L1 norm) is met if the prediction on a left-out datapoint does not change when a single data point is removed from the training dataset. These conditions can be formalized as:

Leave-one-out cross-validation stability An algorithm L has CVloo stability if for each n, there exists a βCV(n) and δCV(n) such that:

∀i∈{1,…,n},ℙS{|V(fSi,zi)−V(fS,zi)|≤βCV(n)}≥1−δCV(n) and βCV(n) and δCV(n) go to zero as n goes to infinity.

Expected-leave-one-out error stability An algorithm L has Elooerr stability if for each n there exists a βELm and a δELm such that:

∀i∈{1,…,n},ℙS{|I[fS]−1n∑i=1NV(fSi,zi)|≤βEL(n)}≥1−δEL(n) with βEL(n) and δEL(n) going to zero for n→∞. For leave-one-out stability in the L1 norm, this is the same as hypothesis stability:

𝔼S,z[|V(fS,z)−V(fSi,z)|]≤βH(n) with βH(n) going to zero as n goes to infinity.

Algorithms with proven stability A number of algorithms have been proven to be stable and as a result have bounds on their generalization error.

Relation to overfitting

The concepts of generalization error and overfitting are closely related. Overfitting occurs when the learned function fS becomes sensitive to the noise in the sample. As a result, the function will perform well on the training set but not perform well on other data from the joint probability distribution of x and y. Thus, the more overfitting occurs, the larger the generalization error. The amount of overfitting can be tested using cross-validation methods, that split the sample into simulated training samples and testing samples. The model is then trained on a training sample and evaluated on the testing sample. The testing sample is previously unseen by the algorithm and so represents a random sample from the joint probability distribution of x and y. This test sample allows us to approximate the expected error and as a result approximate a particular form of the generalization error. Many algorithms exist to prevent overfitting. The minimization algorithm can penalize more complex functions (known as Tikhonov regularization), or the hypothesis space can be constrained, either explicitly in the form of the functions or by adding constraints to the minimization function (Ivanov regularization). The approach to finding a function that does not overfit is at odds with the goal of finding a function that is sufficiently complex to capture the particular characteristics of the data. This is known as the bias–variance tradeoff. Keeping a function simple to avoid overfitting may introduce a bias in the resulting predictions, while allowing it to be more complex leads to overfitting and a higher variance in the predictions. It is impossible to minimize both simultaneously.

References

Further reading Olivier, Bousquet; Luxburg, Ulrike; Rätsch, Gunnar, eds. (2004). Advanced Lectures on Machine Learning. Lecture Notes in Computer Science. Vol. 3176. pp. 169–207. doi:10.1007/b100712. ISBN 978-3-540-23122-6. S2CID 431437. Retrieved 10 December 2022. Bousquet, Olivier; Elisseeff, Andr´e (1 March 2002). "Stability and Generalization". The Journal of Machine Learning Research. 2: 499–526. doi:10.1162/153244302760200704. S2CID 1157797. Retrieved 10 December 2022. Mohri, M., Rostamizadeh A., Talwakar A., (2018) Foundations of Machine learning, 2nd ed., Boston: MIT Press. Moody, J.E. (1992), "The Effective Number of Parameters: An Analysis of Generalization and Regularization in Nonlinear Learning Systems Archived 2016-09-10 at the Wayback Machine", in Moody, J.E., Hanson, S.J., and Lippmann, R.P., Advances in Neural Information Processing Systems 4, 847–854. White, H. (1992b), Artificial Neural Networks: Approximation and Learning Theory, Blackwell.

Worked examples

Example 1 — a first encounter with Generalization error

Start with the simplest possible case. Write down what Generalization error claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In biology, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Generalization error before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Generalization error ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Generalization error

In research
Generalization error appears in biology research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Generalization error in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Generalization error is common in secondary-school and first-year university syllabi. It links to neighbouring topics Classification algorithms, so understanding it makes those chapters shorter.
In everyday life
Look for Generalization error outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Generalization error” →

How to study Generalization error in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Generalization error means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Generalization error out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Generalization error in simple terms?

For supervised learning applications in machine learning and statistical learning theory, generalization error (also known as the out-of-sample error, the probability of error, or the risk) is a measure of how accurately an algorithm is able to predict outcomes for previously unseen data. As learni…

Why does Generalization error matter?

Because it connects several biology ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Generalization error?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Generalization error.

Tags

  • Classification algorithms

Keep exploring