A typical way of measuring the difference between observations and results from a predictor.
The formal definition is:
0
For observations we can express it as:
1
Example
import numpy as np
X = 2 * np.random.rand(1000,1)
X_b = np.c_[np.ones((1000,1)), X]
Y = 1 + 2.5 * X + np.random.randn(1000,1)