Max and Argmax — full transcript
Value vs. Location
You’ll learn that max tells you the best value, while argmax tells you where that best value occurs.
Max and Argmax are a simple pair: one names the best value, the other names where that value appears. By the end, you'll know: the largest number, the position it sits in, and how to tell them apart. Let’s start with the split itself. Max and argmax look almost the same, but they answer different questions. One asks, what is the best value? The other asks, which input gives that value? So if you have a function, max gives you the biggest output you can get. Argmax gives you the input where that biggest output happens. Before you use either one, ask yourself which part you actually need. If you care about the size of the best result, use max. It returns the largest output itself, so it tells you how good the best case is, not where it came from. If you care about the place where the best result happens, use argmax. It returns the input that produces the largest output, so it tells you where the best case lives.
Examples Make It Click
A function and a real-world temperature example show how max and argmax separate the score from the place or time it happens.
Take a tiny function: f(x) = -(x-2)^2 + 5. You can check a few inputs and see the highest output is 5. That means max f(x) = 5, while argmax f(x) = 2. Same function, two different answers: the score is 5, and the input that earns it is 2. Now use a temperature list for the day. If the warmest reading is 31 degrees at 3 PM, max gives 31, and argmax gives 3 PM. One is the value, the other is the time.
How ML Uses Both
In machine learning, max helps optimize models, while argmax turns scores into a final prediction.
Machine learning uses both parts. During training, max can describe the best score a model reaches, while argmax helps track which setting or prediction gives that score. During prediction, argmax is often the final step. The model may output several scores, and argmax turns those scores into one choice by picking the biggest one. Prediction question: if a model gives class scores of 0.2, 0.7, and 0.1, what do you report? max gives 0.7, but argmax gives the second class, because that is the input with the highest score.
Separate the Question
The main habit is to ask whether you want the best value or the input that produces it, because max and argmax answer different questions.
So keep the two questions separate. First ask for the best value. Then ask for the input that achieves it. If you blur them together, you lose the difference between the result and the place it came from. A quick way to check yourself is to say the output out loud. If you want the number itself, you want max. If you want the x-value, the hour, or the class label that produced it, you want argmax. And that is the habit to keep: one question for value, one question for location. Max answers how high. Argmax answers where. So, here’s what you now know about max and argmax. You’ve learned: best value, location of best value, and score versus choice. The next time you check a temperature chart or a model prediction, you’ll see max and argmax working side by side — one gives the peak, the other gives where it happened. The world looks a little different now. That's a good thing.