Did not understand how this gives number of training examples? And shouldn’t the syntax should be X.shape only? Why [0] is there?
What does X.shape[0] mean?
Hey disha,
X is a numpy array with suppose 100 examples and every example has 2 features or say 2 dimensions.
So final shape of X would be a tuple of (100,2) note : tuples are read-only list
Now, if you want to access the first element of this read-only list which is a tuple, we need to use the [0] sqaure bracket first index i.e 0
Therefore X.shape[0] gives you the total examples. If you just write X.shape it would give you both numbers (100,2)
I hope this clears your doubt
Thanks