Python | Numpy matrix.argmax ()



Using the Numpy matrix.argmax () method, we can find the index value of the maximum element in a given matrix that has one or more dimensions.

Syntax: matrix.argmax()

Return: Return index number of maximum element in matrix

Example # 1:
In this example, we can see that using the matrix.argmax () we can find the index of the maximum element in the given matrix.

# import important module into python

import numpy as np

 
# make a matrix with NumPy

gfg = np.matrix ( `[1, 2, 3, 4]` )

 
# using the matrix.argmax () method

geeks = gfg.argmax ()

 

print (geeks)

Exit :

 3 

Example # 2:

# import an important module into python

import numpy as np

 
# make a matrix with NumPy

gfg =   np.matrix ( `[1, 2, 3; 4, 5, 6; 7, 8, 9] ` )

  
# using the matrix.argmax () method

geeks = gfg.argmax ()

 

print (geeks)

Exit :

 8