In both cases, it is assumed that the training set consists of a sample of independent and identically distributed pairs, ( x i , y i ) {\displaystyle (x_{i},\;y_{i})} . In order to measure how well a function fits the training data, a loss function L : Y × Y → R ≥ 0 {\displaystyle L:Y\times Y\to {\mathbb {R}}^{\geq 0}} is defined. For training example ( x i , y i ) {\displaystyle (x_{i},\;y_{i})} , the loss of predicting the value y ^ {\displaystyle {\hat {y}}} is L ( y i , y ^ ) {\displaystyle L(y_{i},{\hat {y}})} .