In this recipe, we will implement Deming regression (total regression), which means we will need a different way to measure the distance between the model line and data points.
If least squares linear regression minimizes the vertical distance to the line, Deming regression minimizes the total distance to the line. This type of regression minimizes the error in the y values and the x values. See the following figure for a comparison:
To implement Deming regression, we have to modify the loss
function. The loss
function in regular linear regression minimizes the vertical distance. Here, we want to minimize the total distance. Given a slope and intercept of a line, the perpendicular distance to a point is a known...