Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
argmin() and argsort()
#1


Hi,

I implemented an algorithm in which I used the argmin() where the index of the smallest number in an array is returned to be used. Now, I would like to generalize my algorithm, and thus I want to return the indices of the smallest k numbers. So, I restored to argsort()[:k]. When I tested it for k = 1, I expected to get the same results as with argmin(), which wasn't the case. I noticed that argsort()[:1] returns an array, while argmin() returns a scalar. Could this be the issue? If not, what else could be?

Thanks
Reply


Messages In This Thread
argmin() and argsort() - by PythonNewbie - Nov-13-2017, 10:16 AM
RE: argmin() and argsort() - by PythonNewbie - Nov-13-2017, 05:29 PM
RE: argmin() and argsort() - by Larz60+ - Nov-13-2017, 05:46 PM
RE: argmin() and argsort() - by DeaD_EyE - Nov-13-2017, 07:13 PM
RE: argmin() and argsort() - by PythonNewbie - Nov-14-2017, 09:05 PM
RE: argmin() and argsort() - by Larz60+ - Nov-14-2017, 10:40 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020