Movatterモバイル変換


[0]ホーム

URL:


SciPy

numpy.argmax

numpy.argmax(a,axis=None,out=None)[source]

Returns the indices of the maximum values along an axis.

Parameters:
a:array_like

Input array.

axis:int, optional

By default, the index is into the flattened array, otherwisealong the specified axis.

out:array, optional

If provided, the result will be inserted into this array. It shouldbe of the appropriate shape and dtype.

Returns:
index_array:ndarray of ints

Array of indices into the array. It has the same shape asa.shapewith the dimension alongaxis removed.

See also

ndarray.argmax,argmin

amax
The maximum value along a given axis.
unravel_index
Convert a flat index into an index tuple.

Notes

In case of multiple occurrences of the maximum values, the indicescorresponding to the first occurrence are returned.

Examples

>>>a=np.arange(6).reshape(2,3)>>>aarray([[0, 1, 2],       [3, 4, 5]])>>>np.argmax(a)5>>>np.argmax(a,axis=0)array([1, 1, 1])>>>np.argmax(a,axis=1)array([2, 2])

Indexes of the maximal elements of a N-dimensional array:

>>>ind=np.unravel_index(np.argmax(a,axis=None),a.shape)>>>ind(1, 2)>>>a[ind]5
>>>b=np.arange(6)>>>b[1]=5>>>barray([0, 5, 2, 3, 4, 5])>>>np.argmax(b)# Only the first occurrence is returned.1

Previous topic

numpy.argpartition

Next topic

numpy.nanargmax

Quick search

  • © Copyright 2008-2018, The SciPy community.
  • Last updated on Jul 24, 2018.
  • Created usingSphinx 1.6.6.

[8]ページ先頭

©2009-2025 Movatter.jp