Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[Lane 2 · kotlin-core] Precision/Recall/F1 — extract Accuracy's class-matching helpers into a shared internal file

未关闭
#1,225 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-3 小时
新手友好度
76/100
Issue 类型
重构
描述清晰度
描述清楚
活跃度
冷清
技术栈
kotlin

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

coding good first issue refactor size:s skill:kotlin-core sub-issue training

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.

  1. Create ClassificationSupport.kt in the same package. Move the helpers there as
    internal top-level functions (or one internal object ClassificationSupport). Keep
    names and signatures; keep error messages, but make the "Accuracy …" prefixes
    metric-agnostic (pass the metric name in, or drop it).
  2. Add one internal entry 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.update becomes a ~5-line call to it that counts matches. This is what
    ConfusionMatrixAccumulator (#1226) will call too.
  3. Accuracy's public surface must not change: same constructor, same accuracy() /
    binaryAccuracy() factories, same behaviour. Run
    ./gradlew :skainet-lang:skainet-lang-core:apiCheck — the API dump must be unchanged
    (everything you add is internal).
  4. Run the existing tests unchanged:
    ./gradlew :skainet-backends:skainet-backend-cpu:jvmTest --tests "sk.ainet.exec.metrics.*".

Acceptance

  • Accuracy.kt contains no argmax / index-walking code of its own
  • apiCheck passes with no dump change
  • AccuracyTest passes 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.

主要语言
Kotlin
星标
52
派生
15
平均合并
1 天 10 小时
30 天内合并 PR
59

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

SKaiNET-developers/SKaiNET 的其他 Issue

查看 SKaiNET-developers/SKaiNET 的全部 Issue

相似的 Issue

更多 Kotlin Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。