QBoard » Artificial Intelligence & ML » AI and ML - Python » why gradient descent when we can solve linear regression analytically

why gradient descent when we can solve linear regression analytically

  • what is the benefit of using Gradient Descent in the linear regression space? looks like the we can solve the problem (finding theta0-n that minimum the cost func) with analytical method so why we still want to use gradient descent to do the same thing?

      August 26, 2021 11:33 PM IST
    0
  • Other reason is that gradient descent is immediately useful when you generalize linear regression, especially if the problem doesn't have a closed-form solution, like for example in Lasso (which adds regularization term consisting on sum of absolute values of weight vector).

     
      October 12, 2021 9:53 PM IST
    0
  • The main reason why gradient descent is used for linear regression is the computational complexity: it's computationally cheaper (faster) to find the solution using the gradient descent in some cases. Here, you need to calculate the matrix X′X then invert it (see note below). It's an expensive calculation
      November 2, 2021 2:52 PM IST
    0
  • Other reason is that gradient descent is immediately useful when you generalize linear regression, especially if the problem doesn't have a closed-form solution, like for example in Lasso (which adds regularization term consisting on sum of absolute values of weight vector).
      November 2, 2021 7:18 PM IST
    0
  • When you use the normal equations for solving the cost function analytically you have to compute:

    enter image description here

    Where X is your matrix of input observations and y your output vector. The problem with this operation is the time complexity of calculating the inverse of a nxn matrix which is O(n^3) and as n increases it can take a very long time to finish.

    When n is low (n < 1000 or n < 10000) you can think of normal equations as the better option for calculation theta, however for greater values Gradient Descent is much more faster, so the only reason is the time :)

      August 27, 2021 7:09 PM IST
    0