Questions tagged [argmax]

arguments of the maxima: given a function of some arguments, argmax stands for the values of the arguments that maximizes the function.

Case 1

Here we consider a function f that maps from a limited set.

Say,

f(x) := {13, 42, 1981, 9, 11, 0},

so f(x = 1) = 13,and f(x = 2) = 42, so on.

It is easy to see here that the value of x that maximizes the function f is 3; that is f(x = 3) = 1981 is the highest values. Thus, argmax of f(x) is x = 3.

In R

f = c(13, 42, 1981, 9, 11, 0)
which.max(f)
# 3

Case 2

Here we consider a function of a continues variable.

Consider

f(x) = x(4 - x)

for this function the argmax is x = 2. That is the highest value of f(x) is 4 which corresponds to x = 2.

In R, we can use the optimize function for this to find the argmax of f.

f <- function(x) {
     x*(4 - x)
}

optimize(f, interval = c(-100, 100), maximum = TRUE)
# $maximum
# [1] 2
#
#$objective
#[1] 4
170 questions
7
votes
1 answer

Get indices of numpy.argmax elements over an axis

I have N-dimensional matrix which contains the values for a function with N parameters. Each parameter has a discrete number of values. I need to maximize the function over all parameters but one, resulting in a one-dimensional vector of size equal…
Svalorzen
  • 5,353
  • 3
  • 30
  • 54
6
votes
1 answer

Keras - How to use argmax for predictions

I have 3 categories of classes Tree, Stump, Ground. I've made a list for these categories: CATEGORIES = ["Tree", "Stump", "Ground"] When i print my prediction, it gives me the output of [[0. 1. 0.]] I've read up about numpy's Argmax but I'm not…
nenese
  • 93
  • 1
  • 1
  • 5
6
votes
3 answers

cumulative argmax of a numpy array

Consider the array a np.random.seed([3,1415]) a = np.random.randint(0, 10, (10, 2)) a array([[0, 2], [7, 3], [8, 7], [0, 6], [8, 6], [0, 2], [0, 4], [9, 7], [3, 2], [4, 3]]) What is a…
piRSquared
  • 285,575
  • 57
  • 475
  • 624
5
votes
3 answers

Finding the indexes of the N maximum values across an axis in Pandas

I know that there is a method .argmax() that returns the indexes of the maximum values across an axis. But what if we want to get the indexes of the 10 highest values across an axis? How could this be accomplished? E.g.: data =…
user8270077
  • 4,621
  • 17
  • 75
  • 140
5
votes
0 answers

Spawn e2big node

I have a node server that runs on debian and I'm trying to pass data extracted from a file into the command line using exec(). getconf ARG_MAX = 2097152 bytes (2 mb) myFile = 600 kb (contains 600kb worth of parameters) When I call exec() command…
5
votes
3 answers

Pandas: Resample dataframe column, get discrete feature that corresponds to max value

Sample data: import pandas as pd import numpy as np import datetime data = {'value': [1,2,4,3], 'names': ['joe', 'bob', 'joe', 'bob']} start, end = datetime.datetime(2015, 1, 1), datetime.datetime(2015, 1, 4) test = pd.DataFrame(data=data,…
EB88
  • 841
  • 1
  • 10
  • 26
5
votes
1 answer

Does the F# library has a standard function for `argMax`?

I am new to F# and writing some simple algorithm to get used to the language, which needs argMax. Does the standard library come with a function for searching for a list element that maximizes a function? That is, if there's an existing function…
Alex
  • 1,184
  • 7
  • 15
5
votes
2 answers

Why is there a blas subroutine (ISAMAX) for argmax abs but none for argmax?

Why is there a blas subroutine ISAMAX for argmax abs but not for argmax ? In C++ using std::max_element with compiler optimisation flag -O3 I am getting speeds comparable to blas_isamax (16 ms vs 9 ms), so at the moment my question is more out of…
newling
  • 624
  • 6
  • 10
4
votes
3 answers

Find index of maximum element satisfying condition (Julia)

In Julia I can use argmax(X) to find max element. If I want to find all element satisfying condition C I can use findall(C,X). But how can I combine the two? What's the most efficient/idiomatic/concise way to find maximum element index satisfying…
alagris
  • 1,838
  • 16
  • 31
4
votes
2 answers

Index of last occurence of True in every row

I have a 2D array: a = ([[False False False False False True True True True True True True True True True True True True True True True True True True True False False False] [False False False False True True True True …
4
votes
1 answer

index selection in case of conflict in pytorch Argmax

I have been trying to learn tensor operations and this one has thrown me for a loop. Let us say I have one tensor t: t = torch.tensor([ [1,0,0,2], [0,3,3,0], [4,0,0,5] ], dtype = torch.float32) Now this is a rank 2…
darkCoffy
  • 103
  • 9
4
votes
1 answer

Tensorflow Argmax: What's the difference between "axis" and "dimension" parameter?

The current version of Tensorflow Argmax doesn't specify what's the difference between the "axis" and "dimension" arguments. Here is the only information given in the official manual: tf.argmax(input, axis=None, name=None, dimension=None)…
Dr_Zaszuś
  • 546
  • 1
  • 7
  • 15
4
votes
1 answer

Numpy index of the maximum with reduction - numpy.argmax.reduceat

I have a flat array b: a = numpy.array([0, 1, 1, 2, 3, 1, 2]) And an array c of indices marking the start of each "chunk": b = numpy.array([0, 4]) I know I can find the maximum in each "chunk" using a reduction: m = numpy.maximum.reduceat(a,b) >>>…
Benjamin
  • 11,560
  • 13
  • 70
  • 119
4
votes
3 answers

numpy: how to get a max from an argmax result

I have a numpy array of arbitrary shape, e.g.: a = array([[[ 1, 2], [ 3, 4], [ 8, 6]], [[ 7, 8], [ 9, 8], [ 3, 12]]]) a.shape = (2, 3, 2) and a result of argmax over the last…
sygi
  • 4,557
  • 2
  • 32
  • 54
3
votes
1 answer

Python most efficient way to find index of maximum in partially changed array

I have a complex-valued array of about 750000 elements for which I repeatedly (say 10^6 or more times) update 1000 (or less) different elements. In the absolute-squared array I then need to find the index of the maximum. This is part of a larger…
bproxauf
  • 1,076
  • 12
  • 23
1
2
3
11 12