How you can vectorize the implementation of logistic regression, so they can process an entire training set, that is implement a single elevation of grading descent with respect to an entire training set without using even a single explicit for loop?
If you have m examples, then to make a prediction on the first example, you need to compute followings:
repeat for all m traing examples.
When you stack the lower case x’s corresponding to a different training examples, horizontally you get a variable X.
,
: This is matrix
Turns out,
: This is a vector
⭐ ⭐
: This is a raw vector like .
In order to implement in python you write
Z=np.dot(w.T, x)+b
In python, is a raw number, but if you add this to a matrix vector, python automatically add it up to each element in the matrix. This is called ‘broaccasting’.
: This is also a vector
⭐A= ⭐