Skip to content

[Lane 2 · kotlin-core] Precision/Recall/F1 — Averaging enum + internal ConfusionMatrixAccumulator #1226

Closed

Description

@michalharakal

Sub-issue of #1222 (Precision, Recall and F1Score metrics).

Lane: 2 · Kotlin core
Skill needed: Kotlin; read Accuracy.kt and the helpers from #1225 first.
Size: s (~3–4 h)
Blocked by: #1225 (helpers) and the contract decisions from #1224 (zero-division, macro class set, binary mode).

What to do

  1. Add public enum class Averaging { BINARY, MACRO, MICRO } in
    sk.ainet.lang.nn.metrics (own file, KDoc on each value — this is public API).
    Semantics per [Lane 1 · numerics] Precision/Recall/F1 — averaging-mode and zero-division conventions #1224; the working definitions are:
  2. Add internal class ConfusionMatrixAccumulator(dim: Int = -1, threshold: Float? = null)
    with
  3. Add internal fun reduce(counts, averaging, perClass: (tp: Long, fp: Long, fn: Long) -> Double): Double
    implementing the three averaging modes and the zero-division convention from [Lane 1 · numerics] Precision/Recall/F1 — averaging-mode and zero-division conventions #1224
    in one place, so Precision, Recall and F1Score each contribute only a formula.
  4. Tests: the accumulator is internal to skainet-lang-core, and the metric tests live
    in skainet-backend-cpu (they need DirectCpuExecutionContext to build tensors). Two
    options — pick one and say which in the PR:
  5. ./gradlew :skainet-lang:skainet-lang-core:apiDump — the dump gains Averaging and
    nothing else.

Acceptance

Notes

Don't build Precision / Recall / F1Score here even though it's tempting — they are
separate good first issues (#1227, #1228, #1229) precisely so three people can each
ship one small PR against this accumulator.

Activity

  1. added
    trainingTraining pipeline, optimizers, loss
    sub-issueSub-issue of a tracking issue
    codingImplementation task (DARC: C)
    skill:kotlin-coreKotlin implementation in commonMain
    on Aug 31, 2026
  2. added a commit that references this issue on Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    codingImplementation task (DARC: C)size:sA few hoursskill:kotlin-coreKotlin implementation in commonMainsub-issueSub-issue of a tracking issuetrainingTraining pipeline, optimizers, loss

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions