On step 2, why do we have len(x) to define the range of the loop ? I don’t understand the use of the function len() with simple input variables.
On step 3, it’s mentioned that x is an object, could it be the reason why we are allowed to use len(x) since the x variable is an object not an integer ?
Here we are assuming that x is an object such as a list or an array. In this case len(x) returns the number of elements in the list or array x. In general, the len() function can be applied to a wide variety of objects including string, dictionary, etc.
sorry, I am very new to this: what determines the current gradient guess and current intercept guess?
like why are they both zero later in the code, and should they always be zero?
thank you.
Yet another question about -2/N. Why we multiply it by -2?
The line till which i can understand is that we have a sum of losses from y - (m*x+b) and if we divide it by N(number of values that we added as sum) we will get average loss.
So what does the multiplication by -2 and then division by N do?
2 comes from derivative. f(x) = x^2 f’(x) = 2x. This is gradient, it points the max y in our graph, but we need gradient descent, the min point of our loss function. - change the direction of gradient at 180 degrees.
i don´t understand why we use this step by step method (Gradient Descent) and not simply set f´(x)=0 and found in this way the local minimum. And how does is differentiate from the OLS method? Thank you.