Simple linear regression is a type of regression analysis where the number of independent variables is one and there is a linear relationship between the independent(x) and dependent(y) variable.
A Simple Linear Equation
y = a_0 + a_1 * x
The motive of the linear regression algorithm is to find the best values for a_0
and a_1
.
The cost function helps us to figure out the best possible values for a_0
and a_1
which would provide the best fit line for the data points.
Since we want the best values for a_0
and a_1
, we convert this search problem into a minimization problem where we would like to minimize the error between the predicted value and the actual value.
Gradient descent is a method of updating a_0
and a_1
to reduce the cost function(MSE). The idea is that we start with some values for a_0
and a_1
and then we change these values iteratively to reduce the cost.
In the gradient descent algorithm, the number of steps you take is the learning rate. This decides on how fast the algorithm converges to the minima.
Sometimes the cost function can be a non-convex function where you could settle at a local minima but for linear regression, it is always a convex function.
Alpha is the learning rate which is a hyperparameter that you must specify. A smaller learning rate could get you closer to the minima but takes more time to reach the minima, a larger learning rate converges sooner but there is a chance that you could overshoot the minima.