[Lane 2 · kotlin-core] Precision/Recall/F1 — extract Accuracy's class-matching helpers into a shared internal file
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
- Issue type
- Refactor
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- kotlin
- Domain
- machine-learning
Research direction
Start with Accuracy.kt and its existing tests, then move the listed class-matching helpers into ClassificationSupport.kt in the same package and route Accuracy.update through the shared per-sample entry point. Run ./gradlew :skainet-lang:skainet-lang-core:apiCheck and ./gradlew :skainet-backends:skainet-backend-cpu:jvmTest --tests "sk.ainet.exec.metrics.*". Done means the tests pass, the API dump is unchanged, and Accuracy.kt has no argmax or index-walking code of its own.
Written by the indexing model from the issue text.
Description
Sub-issue of #1222 (Precision, Recall and F1Score metrics).
Lane: 2 · Kotlin core (preparatory refactor)
Skill needed: Kotlin. No tensor-internals knowledge needed — everything you move already exists and already has tests.
Size: s (~2–3 h)
Blocked by: nothing. Unblocks #1226.
What to do
Accuracy.kt (skainet-lang/skainet-lang-core/src/commonMain/kotlin/sk/ainet/lang/nn/metrics/Accuracy.kt)
carries, as private members, all the class-matching machinery the three new metrics also
need: argmax, argmaxTarget, insertClassIndex, validateIndexTargetShapes,
validatePredictions, normalizeDim, iterateOverSamples, plus the "hard Int32 targets
vs. soft FP32/FP16 targets" dispatch and the binary-threshold branch in
computeWithIndexTargets / computeWithSoftTargets. Copying that three more times is the
duplication git blame will ask about in six months.
- Create
ClassificationSupport.ktin the same package. Move the helpers there as
internaltop-level functions (or oneinternal object ClassificationSupport). Keep
names and signatures; keep error messages, but make the"Accuracy …"prefixes
metric-agnostic (pass the metric name in, or drop it). - Add one
internalentry point that does the per-sample walk once for both target
kinds and hands(predictedClass, targetClass)pairs to a callback, e.g.
internal inline fun forEachPrediction(predictions, targets, dim, threshold, action: (predicted: Int, target: Int) -> Unit).
Accuracy.updatebecomes a ~5-line call to it that counts matches. This is what
ConfusionMatrixAccumulator(#1226) will call too. Accuracy's public surface must not change: same constructor, sameaccuracy()/
binaryAccuracy()factories, same behaviour. Run
./gradlew :skainet-lang:skainet-lang-core:apiCheck— the API dump must be unchanged
(everything you add isinternal).- Run the existing tests unchanged:
./gradlew :skainet-backends:skainet-backend-cpu:jvmTest --tests "sk.ainet.exec.metrics.*".
Acceptance
-
Accuracy.ktcontains no argmax / index-walking code of its own -
apiCheckpasses with no dump change -
AccuracyTestpasses unmodified - PR title
refactor(metrics): extract classification helpers from Accuracy (#1222)
Notes
Pure refactor — no new behaviour, so no new tests needed beyond the existing ones passing.
If you find Accuracy has a latent bug while you're in there (for example the
threshold branch reads logit index 1 when classCount == 2 but index 0 when
classCount == 1 — check that this is intended), don't fix it here; open a separate
bug and link it on the parent.
- Dominant language
- Kotlin
- Stars
- 52
- Forks
- 15
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 36
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from SKaiNET-developers/SKaiNET
-
coding good first issue size:xs skill:kotlin-core sub-issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
SKaiNET-developers/SKaiNET#1323 ·
Maintainers usually reply within 1 day
-
coding good first issue platform size:xs skill:js sub-issue
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SKaiNET-developers/SKaiNET#1232 ·
Maintainers usually reply within 1 day
-
skeep tracking
Difficulty 5/5 Over a week Newbie friendliness 15/100
SKaiNET-developers/SKaiNET#1331 ·
Maintainers usually reply within 1 day
-
assessment size:s skill:review sub-issue
Difficulty 4/5 1-2 days Newbie friendliness 18/100
SKaiNET-developers/SKaiNET#1330 ·
Maintainers usually reply within 1 day
-
documentation good first issue size:s skill:docs sub-issue
Difficulty 3/5 1-2 days Newbie friendliness 78/100
SKaiNET-developers/SKaiNET#1329 ·
Maintainers usually reply within 1 day
All issues in SKaiNET-developers/SKaiNET
Similar issues
-
Default book icon displayed while loadingPossibly taken @Bhaskar-Guthula-137 claimed this today. Openbug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
kiwix/kiwix-android#5194 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
jellyfin/jellyfin-androidtv#5885 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 73/100
tortuvshin/open-apps#377 ·
Maintainers usually reply within 1 day
-
contributor: external needs review
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
supabase-community/supabase-kt#1413 ·
Maintainers usually reply within 5 days