Find values and indices of extrema with min(), max(), argmin(), and argmax().
`np.argmin()` and `np.argmax()` return the index position where minimum or maximum values occur. In Deep Learning, `argmax` identifies predicted class labels.
`max()` tells you the highest test score in the class. `argmax()` tells you the roll number of the student who scored it.
In classification models, output probabilities like `[0.05, 0.85, 0.10]` are passed to `np.argmax()` to output class index 1.
best_idx = probs.argmax(axis=1)idx = scores.index(max(scores)) # 🐌 Slow Python list methodidx = scores.argmax() # ⚡ Fast compiled NumPy methodNumPy ndarrays do not have an `.index()` method. Always use `argmax()` or `argmin()`.
Solve the objective below using NumPy vectorized syntax
Given `arr = np.array([12, 85, 45, 99, 23])`, find the index of the maximum value using `.argmax()` and print it.
3