5 1 5 Finding The Best Fit Line - Applied Statistics for Machine Learning | Evolv
5.1.5 Finding the Best Fit Line
OLS is a linear regression technique used to determine the optimal values
for the slope and intercept that minimises the sum of squared errors. We have already discussed the
sum of squared errors in detail in the previous section (5.1.4). For any element in the data points where = 1, 2, …..n, the SSE equation can be written as:
(5.1)
Here represents the predicted value of , and therefore can be written as:
(5.2)
where and are the estimated regression coefficients of .
Thus, the SSE equation w.r.t and becomes:
(5.3)
Ordinary Least Squares (OLS) aims to determine the values of the estimated
regression coefficients and that minimise the Sum of Squared Errors (SSE) and to solve an optimization
problem in OLS we will need the concept of partial derivative.
Just as a quick introduction, a partial derivative of a multivariable
function is its derivative with respect to one of those variables, with the
others held constant. The partial derivative of a function with respect to the variable is variously denoted as:
It can be thought of as the rate of change in function with a small change in .
Minimising the SSE requires taking the partial derivatives of the SSE
function w.r.t both the coefficients and , equating them to zero and solving it for and .
SSE equation w.r.t is:
(5.4)
After applying the derivative concepts, equation (5.4) is transformed
into:
(5.5)
Similarly, the SSE equation w.r.t is
(5.6)
After applying the derivative concepts, equation (5.6) is transformed
into:
(5.7)
On solving equations (5.5) and (5.7), we get and :