User:Avalenzu/sandbox

Template:User sandbox In machine learning, early stopping is a form of regularization used to avoid overfitting when training a learner with an iterative method, such as gradient descent. Such methods update the learner so as to make it better fit the training data with each iteration. Up to a point, this improves the learner's performance on data outside of the training set. Past that point, however, improving the learner's fit to the training data comes at the expense of increased generalization error. Early stopping rules provide guidance as to how many iterations can be run before the learner begins to over-fit. Early stopping rules have been employed in many different machine learning methods, with varying amounts of theoretical foundation.

Background

This section presents some of the basic machine-learning concepts required for a description of early stopping methods.

Overfitting

{{#invoke:main|main}}

This image represents the problem of overfitting in machine learning. The red dots represent training set data. The green line represents the true functional relationship, while the red line shows the learned function, which has fallen victim to overfitting.

Machine learning algorithms train a model based on a finite set of training data. During this training, the model is evaluated based on how well it predicts the observations contained in the training set. In general, however, the goal of a machine learning scheme is to produce a model that generalizes, that is, that predicts previously unseen observations. Overfitting occurs when a model fits the data in the training set well, while incurring larger generalization error.

Regularization

{{#invoke:main|main}} Regularization, in the context of machine learning, refers to the process of modifying a learning algorithm so as to prevent overfitting. This generally involves imposing some sort of smoothness constraint on the learned model. [1] This smoothness may be enforced explicitly, by fixing the number of parameters in the model, or by augmenting the cost function as in Tikhonov regularization. Tikhonov regularization, along with principle component regression and many other regularization schemes, fall under the umbrella of spectral regularization, regularization characterized by the application of a filter. Early stopping also belongs to this class of methods.

{{#invoke:main|main}} Gradient descent methods are first-order, iterative, optimization methods. Each iteration updates an approximate solution to the optimization problem by taking a step in the direction of the negative of the gradient of the objective function. By choosing the step-size appropriately, such a method can be made to converge to a local minimum of the objective function. Gradient descent is used in machine-learning by defining a loss function that reflects the error of learner on the training set and then minimizing that function.

Definition

Early stopping refers to any regularization (machine-learning) technique wherein an iterative machine-learning scheme is stopped prior to convergence so as to prevent overfitting.

Early stopping based on analytical results

Early stopping in statistical learning theory

Early-stopping can be used to regularize non-parametric regression problems encountered in machine learning. For a given input space, ${\displaystyle X}$, output space, ${\displaystyle Y}$, and samples drawn from an unknown probability measure, ${\displaystyle \rho }$, on ${\displaystyle Z=X\times Y}$, the goal of such problems is to approximate a regression function, ${\displaystyle f_{\rho }}$, given by

${\displaystyle f_{\rho }(x)=\int _{Y}yd\rho (y|x),x\in X}$,

where ${\displaystyle \rho (y|x)}$ is the conditional distribution at ${\displaystyle x}$ induced by ${\displaystyle \rho }$.[2] One common choice for approximating the regression function is to use functions from a reproducing kernel Hilbert space.[2] These spaces can be infinite dimensional, in which they can supply solutions that overfit training sets of arbitrary size. Regularization is, therefore, especially important for these methods. One way to regularize non-parametric regression problems is to apply an early stopping rule to an iterative procedure such as gradient descent.

The early stopping rules proposed for these problems are based on analysis of upper bounds on the generalization error as a function of the iteration number. They yield prescriptions for the number of iterations to run that can be computed prior to starting the solution process.[3] [4]

Example: Least-squares loss

(Adapted from Yao, Rosasco and Caponnetto, 2007[3])

${\displaystyle \mathbf {z} =\left\{(x_{i},y_{i})\in X\times Y:i=1,\dots ,m\right\}\in Z^{m}}$,

drawn independently from ${\displaystyle \rho }$, minimize the functional

${\displaystyle {\mathcal {E}}(f)=\int _{X\times Y}\left(f(x)-y\right)^{2}d\rho }$

where, ${\displaystyle f}$ is a member of the reproducing kernel Hilbert space ${\displaystyle {\mathcal {H}}}$. That is, minimize the expected risk for a Least-squares loss function. Since ${\displaystyle {\mathcal {E}}}$ depends on the unknown probability measure ${\displaystyle \rho }$, it cannot be used for computation. Instead, consider the following empirical risk

${\displaystyle {\mathcal {E}}_{\mathbf {z} }(f)={\frac {1}{m}}\sum _{i=1}^{m}\left(f(x_{i})-y_{i}\right)^{2}.}$

Let ${\displaystyle f_{t}}$ and ${\displaystyle f_{t}^{\mathbf {z} }}$ be the t-th iterates of gradient descent applied to the expected and empirical risks, respectively, where both iterations are initialized at the origin, and both use the step size ${\displaystyle \gamma _{t}}$. The ${\displaystyle f_{t}}$ form the population iteration, which converges to ${\displaystyle f_{\rho }}$, but cannot be used in computation, while the ${\displaystyle f_{t}^{\mathbf {z} }}$ form the sample iteration which usually converges to an overfitting solution.

We want to control the difference between the expected risk of the sample iteration and the minimum expected risk, that is, the expected risk of the regression function:

${\displaystyle {\mathcal {E}}(f_{t}^{\mathbf {z} })-{\mathcal {E}}(f_{\rho })}$

This difference can be rewritten as the sum of two terms: the difference in expected risk between the sample and population iterations and that between the population iteration and the regression function:

${\displaystyle {\mathcal {E}}(f_{t}^{\mathbf {z} })-{\mathcal {E}}(f_{\rho })=\left[{\mathcal {E}}(f_{t}^{\mathbf {z} })-{\mathcal {E}}(f_{t})\right]+\left[{\mathcal {E}}(f_{t})-{\mathcal {E}}(f_{\rho })\right]}$

This equation presents a bias-variance tradeoff, which is then solved to give an optimal stopping rule that may depend on the unknown probability distribution. That rule has associated probabilistic bounds on the generalization error. For the analysis leading to the early stopping rule and bounds, the reader is referred to the original article. [3] In practice, data-driven methods, e.g. cross-validation can be used to obtain an adaptive stopping rule.

Early stopping in Boosting

Boosting refers to a family of algorithms in which a set of weak learners (learners that are only slightly correlated with the true process) are combined to produce a strong learner. It has been shown, for several boosting algorithms (including AdaBoost), that regularization via early stopping can provide guarantees of consistency, that is, that the result of the algorithm approaches the true solution as the number of samples goes to infinity.[5] [6] [7]

L2-Boosting

Boosting methods have close ties to the gradient descent methods described above can be regarded as a boosting method based on the ${\displaystyle L_{2}}$ loss: L2Boost[3].

Early stopping based on cross-validation

These early stopping rules work by splitting the original training set into a new training set and a validation set. The error on the validation set is used as a proxy for the generalization error in determining when overfitting has begun. These methods are most commonly employed in the training of neural networks. Prechelt gives the folowing summary of a naive implementation of cross-validation based early stopping as follows:[8]

1. Split the training data into a training set and a validation set, e.g. in a 2-to-1 proportion.
2. Train only on the training set and evaluate the per-example error on the validation set once in a while, e.g. after every fifth epoch.
3. Stop training as soon as the error on the validation set is higher than it was the last time it was checked.
4. Use the weights the network had in that previous step as the result of the training run.

— Lutz Prechelt, 'Early Stopping - But When?'

This simple procedure is complicated in practice by the fact that the validation error may fluctuate during training, producing multiple local minima. This complication has led to the creation of many ad-hoc rules for deciding when overfitting has truly begun. [8]

References

1. {{#invoke:Citation/CS1|citation |CitationClass=journal }}
2. {{#invoke:Citation/CS1|citation |CitationClass=journal }}
3. {{#invoke:Citation/CS1|citation |CitationClass=journal }}
4. {{#invoke:citation/CS1|citation |CitationClass=conference }}
5. {{#invoke:Citation/CS1|citation |CitationClass=journal }}
6. {{#invoke:Citation/CS1|citation |CitationClass=journal }}
7. {{#invoke:Citation/CS1|citation |CitationClass=journal }}
8. {{#invoke:citation/CS1|citation |CitationClass=book }}

ORIGINAL ARTICLE

Template:Citations missing In machine learning, early stopping is a form of regularization used when a machine learning model (such as a neural network) is trained by on-line gradient descent. In early stopping, the training set is split into a new training set and a validation set. Gradient descent is applied to the new training set. After each sweep through the new training set, the network is evaluated on the validation set. When the performance with the validation test stops improving, the algorithm halts. The network with the best performance on the validation set is then used for actual testing, with a separate set of data (the validation set is used in learning to decide when to stop).

This technique is a simple but efficient hack to deal with the problem of overfitting. Overfitting is a phenomenon in which a learning system, such as a neural network gets very good at dealing with one data set at the expense of becoming very bad at dealing with other data sets. Early stopping is effectively limiting the used weights in the network and thus imposes a regularization, effectively lowering the VC dimension.

Early stopping is a very common practice in neural network training and often produces networks that generalize well. However, while often improving the generalization it does not do so in a mathematically well-defined way.

Method

1. Divide the available data into training and validation sets.
2. Use a large number of hidden units.
3. Use very small random initial values.
4. Use a slow learning rate.
5. Compute the validation error rate periodically during training.
6. Stop training when the validation error rate "starts to go up".

It is crucial to realize that the validation error is not a good estimate of the generalization error. One method for getting an unbiased estimate of the generalization error is to run the net on a third set of data, the test set, that is not used at all during the training process. The error on the test set gives estimate on generalization; to have the outputs of the net approximate target values given inputs that are not in the training set.

• It is fast.
• It can be applied successfully to networks in which the number of weights far exceeds the sample size.
• It requires only one major decision by the user: what proportion of validation cases to use.

Issues

• It's not clear on how many cases to assign to the training and validation sets
• The result might highly depend on the algorithm which is used to split the data into training and validation set
• Notion of "increasing validation error" is ambiguous; it may go up and down numerous times during training. The safest approach is to train to convergence, then determine which iteration had the lowest validation error. This impairs fast training, one of the advantages of early stopping.