Collect several independent training sets from the same process, fit one regression procedure to each, and query every fitted model at the same input. The predictions disagree with one another, their average can sit away from the true mean outcome at that input, and the new outcome itself scatters around that mean. How much of the expected squared error does each of these three effects contribute? This lesson splits the expected squared error at a fixed input into squared bias, prediction variance and irreducible error, states exactly what the averages range over, and shows why the familiar tradeoff between bias and variance is a tendency to check rather than a law.
Key terms
Bias-variance decomposition
Definition Fix an input and let be a new outcome at this input. Write , where is the conditional mean, so the noise has , and assume its variance is finite. A learning procedure trained on a random training set , possibly with further random choices during training, returns a predictor . Assume that is finite and that the new outcome is independent of the training set and of every random choice made in training. The average fitted prediction is
where averages over training sets and training randomness. At the fixed input abbreviate , , and . Then the expected squared prediction error, averaged over the training randomness and the new outcome, is
which is squared bias plus prediction variance plus irreducible error. To derive it, write the error as and square. The first part is a constant at this input, the second has expectation by the definition of , and the noise has mean and is independent of , so all three cross terms have expectation . If the input of a new case is drawn independently of the training data, averaging the three terms over its distribution gives the integrated decomposition of the expected squared error, provided these expectations are finite. The identity belongs to squared loss. For class labels under zero-one loss, bias and variance are commonly defined through the most frequent prediction, and those terms do not add up to the error rate. Extra variability can even lower the error there. If , a classifier that always predicts errs with probability . One that predicts for percent of training draws still predicts the wrong label most often, yet it errs with probability .
In plain words A prediction can miss for three different reasons. The procedure can aim at the wrong value on average, its aim can wobble from one training set to the next, and the outcome can land away from its own mean. Under squared loss these three costs simply add, because each is measured around a different center and the mixed terms average out. The averages run over many possible training sets, so no single fitted model shows its own bias or variance.
Example The numbers in this lesson are constructed. At a fixed input the conditional mean is , and a new outcome is or with probability each, so . Learner A draws two independent training outcomes from the same process at this input and predicts their mean minus . The four equally likely ordered training pairs , , and give the predictions , , and . The average prediction is , so the squared bias is . The deviations from are , so the prediction variance is . The decomposition gives squared units. A direct check pairs each of the four predictions with each of the two outcomes. The eight equally likely squared errors are , and their average is .
Squared bias
Definition Under the setup of the decomposition, the bias of a learning procedure at the input is
the average fitted prediction minus the conditional mean, and the squared bias is its square. A positive and a negative bias of the same size give the same squared bias. Bias belongs to the whole experiment, the procedure together with the data-generating process, the training-set size and the training randomness. It is not a property of one fitted model, which gives a single prediction at and no average. It usually changes with the input, so a procedure can be unbiased at some inputs and biased at others, and the integrated squared bias averages it over the input distribution. Computing it requires , which is known in simulations and constructed examples but unknown for real data.
In plain words Bias asks where the procedure aims on average. Retrain it on endless fresh training sets, average its predictions at the input, and measure how far that average lands from the true mean outcome. A model too rigid to follow the true shape tends to miss in the same direction on every training set.
Example Learner A averages against the conditional mean , so its bias is and its squared bias is . The bias comes entirely from subtracting . Learner B uses the same two training outcomes and , in the order drawn, and predicts . For the pairs , , and it predicts , , and . These average to , so learner B is unbiased at this input. So is the plain mean of the two training outcomes, whose predictions are , , and .
Prediction variance
Definition With the abbreviations of the decomposition, the prediction variance of a procedure at the input is
the expected squared distance of a fitted prediction from the average fitted prediction, with the expectation over the training set and all training randomness. It is the variance of a fully specified probability experiment, so when finitely many equally likely predictions are possible, the average of their squared deviations divides by their number and not by one less. It measures how sensitive the fitted prediction is to the particular training sample and to random choices in training. It contains no noise from the new outcome. It equals exactly when the prediction at is the same for every training draw, apart from events of probability .
In plain words Variance asks how much the prediction at this input would move if a different training set had been collected or training had been rerun with another seed. A procedure that follows the details of its sample closely gives scattered predictions, even when they are right on average.
Example Learner A’s deviations from its average give the variance . Learner B’s predictions deviate from by , so its variance is . The difference comes from the weights on the two independent training outcomes, each of variance . Learner B weights them by and , whose squares add to , and learner A by and , whose squares add to . The variances are and , and the subtracted constants play no part.
Irreducible error
Definition The irreducible error at the input is the conditional variance of the outcome. With the two expectations below taken conditionally on , it is
For every number , the expected squared error of the constant prediction at this input is
and only reaches . The same holds for a random prediction, such as a fitted model’s, that is independent of the new outcome. Its expected squared error at this input is plus the expected squared distance of the prediction from , so no such prediction gets below . The floor is irreducible relative to the information in and to squared loss. It does not depend on the learning procedure, so procedures compared at the same input under the same outcome process differ only in squared bias plus variance. A further feature known at prediction time changes the conditional distribution, and by the law of total variance , so new information can lower the floor on average and can never raise it on average.
In plain words Even the true conditional mean misses individual outcomes, because cases with the same input still differ. That spread is the floor for squared error with this information. More training data or a better algorithm cannot push below it, but a new measurement that is available at the time of prediction can.
Example With outcomes or and conditional mean , even the perfect prediction has squared error on every outcome, so , and this accounts for of learner A’s squared units. A constant prediction of would score . If a second feature known at prediction time revealed which of the two outcomes is coming, the conditional variance given both features would be . With the original input alone, no predictor gets below .
Bias-variance tradeoff
Definition The bias-variance tradeoff is the frequently observed tendency, within a family of models indexed by a complexity setting, for more flexible settings to lower squared bias and raise prediction variance, and for restrictions such as a larger ridge penalty, fewer features or more neighbors in nearest-neighbor regression to do the opposite, so that expected squared error is often smallest at an intermediate setting. It is a tendency and not a theorem. Neither term has to move monotonically with the number of parameters or any other complexity count, and the error curve need not be U-shaped. The amount of data, the optimization method, the architecture, the regularization and the training randomness all change both terms. One procedure can have both smaller bias and smaller variance than another, so lowering the error does not always require giving up one term for the other. The decomposition behind the picture is the squared-loss identity under the conditions stated above.
In plain words A rigid model tends to miss in the same way on every training set, and a flexible one tends to chase the quirks of each set. That picture suggests which direction to adjust a model, but whether a given change helps has to be checked with honest validation, not assumed.
Example At the constructed input, learner A has expected squared error and learner B has . Removing the bias made learner B worse, because its variance rose by while its squared bias fell by only . The plain mean of the two training outcomes has squared bias , variance and expected squared error , below both. It has the bias of learner B and the variance of learner A at the same time, so in this comparison nothing had to be traded.
Training randomness
Definition Training randomness is every source of chance that makes the fitted predictor random. It includes the draw of the training set itself and random choices inside training, such as initial weights, the order of mini-batches, random subsamples of rows or features and random fold assignments inside a tuning search. The expectation in the decomposition averages over all the sources that are allowed to vary, so a statement of bias or variance has to say which sources were varied and which were held fixed, for example by recording a seed. A single trained model on a single data set is one draw from this experiment, and it reveals neither nor the variance. Estimating them needs repeated training on fresh samples from a process whose is known, as in a simulation, or further assumptions. Rerunning training with new seeds on one fixed data set measures only the part of the variance that the seeds cause.
In plain words A fitted model is the outcome of a random experiment, and a new sample or a new seed would have produced a different one. Bias and variance describe that experiment as a whole, which is why one trained model cannot report its own bias and variance.
Example Give learner A an extra random step, standing in for a random initialization that leaves a trace in the final model. After averaging its two training outcomes and subtracting , it adds or with probability each, independently of the data and of the new outcome. The average prediction stays , the variance becomes , and the expected squared error becomes . Averaging the predictions of independently seeded runs on the same training set cuts the seed part of the variance to and leaves the sample part , for an expected squared error of . Rerunning on one training set with new seeds would expose only the seed part, never the sample part.
Check yourself
- At the constructed input with conditional mean and new outcomes or with probability each, learner C produces the predictions , and with probability each, independently of the new outcome. Find its bias, prediction variance and expected squared error, check the result directly, and compare learner C with learner A.
Show the answer
The average prediction is , so the bias and the squared bias are . The deviations from are , so the prediction variance is . Adding the irreducible error gives
squared units.
For the direct check, pair each prediction with each outcome. The six equally likely squared errors are and for the prediction , and for , and and for . They add to , and .
Learner C beats learner A’s although its variance is larger than A’s , because it has no squared bias where A has . The comparison holds for this input, this outcome process and squared loss, not for every input or every cost of error.
- A team fits one model and finds a training MSE of and a validation MSE of . A colleague reports that the model’s squared bias is and its variance is . What is wrong with this reading, and what would it take to estimate squared bias and variance?
Show the answer
Squared bias and variance describe the distribution of fitted predictions over repeated training sets and training randomness, measured against the true conditional mean. One fitted model gives one prediction at each input, so neither quantity can be read from it. For this fixed fitted model and a new outcome independent of its training data, the expected squared error at an input is
with no variance term at all, and the validation MSE estimates the average of this over the validation inputs, irreducible error included.
The training MSE is not a squared bias either. It is computed on the cases that shaped the model, so it tends to understate the error on new cases, and it also reflects the noise in the training outcomes, part of which the model has fitted. The gap of therefore mixes the optimism of training error with sampling noise in both numbers, and it is not the variance.
Estimating the components needs repeated training on independent samples from a process with known , as in a simulation, or strong extra assumptions. With real data, the honest diagnostics are comparisons of training and validation behavior, repeated splits and learning curves, described in those terms and not as measured bias and variance.
- Constructed training data have one outcome at each of the fixed inputs . The outcome at input is , so the conditional mean is , and the noise terms are independent with mean and variance . A new outcome at follows the same model, independently of the training data. Nearest-neighbor regression predicts at the average of the training outcomes at the nearest inputs. Find the squared bias, the variance and the expected squared error for , and say which is best. Which would be best if the conditional mean were constant instead?
Show the answer
The distances from to the training inputs are , so there are no ties, and the nearest inputs are . The inputs are fixed, so the only training randomness is the noise in the training outcomes. The average prediction is the mean of over those inputs, , and , so the squared bias is . The prediction averages independent outcomes of variance , so its variance is . The expected squared error is
For it is . For it is . For it is . So is best of the three, and and give and . Here squared bias rises with and variance falls, and the error dips and then rises.
If the conditional mean were constant, every neighbor would have the same mean, so the bias would be for every and the error would fall all the way to at . Averaging more neighbors would then cost nothing. Whether more flexibility pays depends on the shape of and the size of the noise, which is why the tradeoff is a tendency to check and not a rule.