Generalization Error/Generalization Loss/Test Error/ Expected Error of Hypothesis/Risk - Python for Integrated Circuits - - An Online Book - |
||||||||
Python for Integrated Circuits http://www.globalsino.com/ICs/ | ||||||||
Chapter/Index: Introduction | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | Appendix | ||||||||
================================================================================= Generalization error, also known as generalization loss or test error (misclassification), is a critical concept in machine learning and statistics. It represents the difference between a model's performance on the training data (which it has seen during training) and its performance on unseen or new data (the test data). In essence, generalization error measures how well a machine learning model can generalize its learned patterns to make accurate predictions on data it has never encountered before. Mathematically, you can represent generalization error using the following equation: Generalization Error (E_generalization) = |Performance on Training Data - Performance on Test Data| ------------------- [3930a] In this equation:
The absolute difference between these two performances quantifies the generalization error. Ideally, you want the generalization error to be as low as possible. A low generalization error indicates that the model has learned to generalize well from the training data to unseen data, which means it is likely to make accurate predictions in practical applications. High generalization error, on the other hand, indicates that the model has overfitted the training data and cannot generalize to new data effectively. Overfitting occurs when a model learns the noise or specific details in the training data rather than capturing the underlying patterns, leading to poor performance on new data. The generalization error can also be expressed as the expected error of a hypothesis ℎ with respect to a distribution , given by, where,
This expression [3930b] represents the expected error of the hypothesis ℎon examples drawn from the distribution . The expectation is taken over the distribution , which implies that it is not specific to the training data but reflects the model's performance on a broader set of examples.In general, risk can be defined as the expected value of a loss function under a certain distribution, where, is the risk associated with hypothesis ℎ. is the loss function, and the expectation is taken over the distribution In practice, machine learning practitioners often use techniques like cross-validation to estimate the generalization error, as they typically don't have access to the true performance on unseen data during model development. In the case of 0-1 loss in Form [3930b] above, the expression is a specific form of this general risk formula. ============================================ Generalization Error: In this example, we'll generate synthetic data and fit a polynomial regression model to it. We'll then calculate and visualize the training error and test error (generalization error) as the polynomial degree increases, demonstrating the trade-off between underfitting and overfitting. Code: This script generates a plot showing how the training error and test error change as the polynomial degree increases. It illustrates the concept of generalization error by demonstrating the trade-off between underfitting (high training and test error) and overfitting (low training error but high test error). ============================================
|
||||||||
================================================================================= | ||||||||
|
||||||||