Finds the optimal regression line using the gradient descent method