[Lane 2 · kotlin-core] Precision metric
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 58/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- kotlin
- Domain
- machine-learning
Research direction
This task is explicitly blocked by #1226, which provides the accumulator and Averaging; check that it is complete before starting. Then read Accuracy.kt and ConfusionMatrixAccumulator, and follow the issue's paths for Precision.kt and PrecisionTest.kt, using AccuracyTest.kt as the test reference. Run the listed apiDump and JVM metric tests; done means the public API is in the dump and all six test cases pass.
Written by the indexing model from the issue text.
Description
Sub-issue of #1222 (Precision, Recall and F1Score metrics).
Lane: 2 · Kotlin core
Skill needed: Kotlin. Read Accuracy.kt and ConfusionMatrixAccumulator first — this task is mostly wiring.
Size: s (~2–3 h)
Blocked by: #1226 (accumulator + Averaging)
What to do
- Add
public class Precision(averaging: Averaging = Averaging.MACRO, dim: Int = -1, threshold: Float? = null) : Metric
inskainet-lang/skainet-lang-core/src/commonMain/kotlin/sk/ainet/lang/nn/metrics/Precision.kt:override val name = "precision";update(...)delegates to a privateConfusionMatrixAccumulator(dim, threshold);compute()=reduce(acc.counts(), averaging) { tp, fp, fn -> if (tp + fp == 0L) 0.0 else tp.toDouble() / (tp + fp) };reset()delegates.
MirrorAccuracy.kt's KDoc style (what the metric means, thedim/thresholdsemantics, whataveragingdoes).
- Add factory functions at the bottom of the file mirroring
accuracy()/binaryAccuracy():
public fun precision(averaging: Averaging = Averaging.MACRO, dim: Int = -1): Metricand
public fun binaryPrecision(threshold: Float = 0.5f): Metric. - Tests in
skainet-backends/skainet-backend-cpu/src/commonTest/kotlin/sk/ainet/exec/metrics/PrecisionTest.kt,
copyingAccuracyTest.kt's tensor helpers. Cover, with hand-computed expected values
(see the parent issue and #1224 for the reference fixturepred [2,0,1,2],target [2,1,1,0]):- macro multi-class with
Int32index targets → 0.5; - micro multi-class → 0.5 (and assert it equals
Accuracyon the same batch); - the same batch with soft (
FP32one-hot) targets gives the same result; - binary with
threshold, 2-class logits; - accumulation across two
update()calls equals one call on the concatenated batch; - zero-division: a class with TP+FP+FN = 0 contributes
0.0(per #1224), and
compute()on a fresh metric returns0.0.
- macro multi-class with
./gradlew :skainet-lang:skainet-lang-core:apiDumpand
./gradlew :skainet-backends:skainet-backend-cpu:jvmTest --tests "sk.ainet.exec.metrics.*".
Acceptance
-
Precision+precision()+binaryPrecision()public and in the API dump - All six test cases above pass on JVM
- No duplicated argmax / iteration logic — everything goes through the accumulator
- PR links this issue and #1222; PR body states "unit tests only; ground-truth wiring tracked in SKEEP-005 (#1223)"
Notes
Precision answers "of what I predicted positive, how much was right". The twin task #1228 (Recall) is the same shape with tp / (tp + fn) — if you take both, fine, but they are filed separately so two people can each ship one.
- 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
-
[Submission] 抖音火山版Opensubmit-adaption submit-adaption-pre
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
BetterAndroid/android-notification-icon-project#744 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
utopia-rise/godot-jvm#1004 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
pedroSG94/RootEncoder#2213 ·
Maintainers usually reply within 2 days
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
dzid26/TeslaBatteryBLE#183 ·
Maintainers usually reply within 1 day