LESSON 51 OF 52 · CHAPTER 06

Class Score Ties

matvec, argmax first-match behavior and maxval

ORIGINAL SOURCE

10-class-score-ties.srp

bind weights = tile([1.0, 0.0, 0.0, 2.0, -1.0, 1.0], 3, 2);
bind scores = matvec(weights, [2.0, 1.0]);
// Equal best scores choose the first class.
print(scores, argmax(scores), maxval(scores));
EXPECTED OUTPUT

stdout

Verified
[2.0, 2.0, -1.0] 0 2.0

UNDERSTAND THE CODE

Explanation & practice

What this example teaches

matvec, argmax first-match behavior and maxval

Expected behavior

[2.0, 2.0, -1.0] 0 2.0

Practice: Read the source before looking at the output. Predict the values and their order, then use the pinned compiler to execute this lesson and compare the exact fixture. Identify which operation produces the result.

बराबर स्कोर में पहला स्थान

matvec तीन वर्गों के स्कोर [2.0, 2.0, -1.0] देता है। argmax सबसे बड़े स्कोर का पहला इंडेक्स चुनता है और maxval उसका वास्तविक संख्यात्मक मान देता है। इंडेक्स को संभावना समझना गलत होगा।

आउटपुट: [2.0, 2.0, -1.0] 0 2.0।

अभ्यास: एक जैसे दो अधिकतम स्कोर होने पर पहला इंडेक्स 0 क्यों है?

Explanations are sourced from the project's English chapter guide and हिन्दी अध्याय. The Scarp program and output are unchanged.

TRY IT LOCALLY

Verify, then execute

Use the pinned compiler from the course root. Keep any imported _support files next to the source.

scarp verify examples/06-ai-foundations/10-class-score-ties.srp scarp exec examples/06-ai-foundations/10-class-score-ties.srp

The website does not run code. Read the CLI guide ↗

Pinned compiler: Scarp v0.0.6-alpha.3 · ceff07d9014f. No simulated output.