Back to Practice
#0135

Argmax Per Row

EasyNumPy15 min10 XP

Problem

Given a 2D NumPy array, return a 1D array of column indexes where each row is largest.

Why This Matters

Argmax over class probabilities is how many classifiers convert scores into predicted labels.

Function Signature

def argmax_rows(scores):

Examples

Example 1
Input[[0.1,0.9],[0.8,0.2]]
Output[1, 0]

First row max is column 1; second row max is column 0.

Constraints

  • Return the exact requested structure.
  • Handle normal edge cases cleanly.
  • Prefer readable code over clever shortcuts.
CodePython
Visible browser tests run here when available.
Testcases1 visible / 3 hidden categories
Core example
Input[[0.1,0.9],[0.8,0.2]]
Expected[1, 0]

First row max is column 1; second row max is column 0.

Hidden Test Categories
three columnsties choose firstsingle row