Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

[Lane 2 · kotlin-core] F1Score metric

オープン
#1,229 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜3時間
初心者へのやさしさ
57/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
静か
技術スタック
kotlin

調査の方向性

Read Precision.kt and Recall.kt from the blocking issues, then inspect the accumulator and Metric.kt before implementing F1Score.kt at the specified core path. Add the specified tests in F1ScoreTest.kt and run the JVM metrics tests plus the API dump command. Done means the listed cases pass and the public API appears in the dump; this issue is blocked by #1227 and #1228 (or at least #1226).

索引モデルが issue の本文から書いたものです。

説明

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

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

Lane: 2 · Kotlin core
Skill needed: Kotlin. Read Precision.kt / Recall.kt from #1227 / #1228 first — F1Score composes their formulas over one accumulator.
Size: s (~2–3 h)
Blocked by: #1227 and #1228 (or at least #1226 — F1 only needs the accumulator, but its tests cross-check against Precision/Recall).

What to do

  1. Add public class F1Score(averaging: Averaging = Averaging.MACRO, dim: Int = -1, threshold: Float? = null) : Metric
    in skainet-lang/skainet-lang-core/src/commonMain/kotlin/sk/ainet/lang/nn/metrics/F1Score.kt:
    • override val name = "f1";
    • one private ConfusionMatrixAccumulator — do not hold a Precision and a
      Recall and call update() on both; that walks every batch twice;
    • compute() = reduce(acc.counts(), averaging) { tp, fp, fn -> per-class F1 } where
      per-class F1 = 2·tp / (2·tp + fp + fn) (algebraically 2PR/(P+R), but this form has
      a single zero-division check: 0.0 when 2·tp + fp + fn == 0).
    • Note that for MACRO, F1 is the mean of per-class F1s — not the F1 of macro-P and
      macro-R. Say so in the KDoc; it is the most common F1 implementation mistake.
  2. Factories: public fun f1Score(averaging: Averaging = Averaging.MACRO, dim: Int = -1): Metric
    and public fun binaryF1Score(threshold: Float = 0.5f): Metric.
  3. Tests in skainet-backends/skainet-backend-cpu/src/commonTest/kotlin/sk/ainet/exec/metrics/F1ScoreTest.kt,
    reference fixture pred [2,0,1,2], target [2,1,1,0]:
    • macro F1 → 0.4444 (per-class [0, 0.667, 0.667]), and assert it is not
      2·0.5·0.5/(0.5+0.5) = 0.5 — the mean-of-F1s vs. F1-of-means trap;
    • micro F1 → 0.5, equal to micro precision, micro recall and accuracy;
    • binary with threshold on 2-class logits, hand-computed;
    • a class with TP+FP+FN = 0 contributes 0.0; fresh metric compute() is 0.0;
    • accumulation across two update() calls equals one concatenated call;
    • computeForBatch (from Metric.kt) round-trips through reset().
  4. ./gradlew :skainet-lang:skainet-lang-core:apiDump and
    ./gradlew :skainet-backends:skainet-backend-cpu:jvmTest --tests "sk.ainet.exec.metrics.*".

Acceptance

  • F1Score + f1Score() + binaryF1Score() public and in the API dump
  • All test cases above pass on JVM
  • Batches are walked once per update()
  • PR body states "unit tests only; ground-truth wiring tracked in SKEEP-005 (#1223)"

Notes

Reference: sklearn f1_score docs — https://scikit-learn.org/stable/modules/generated/sklearn.metrics.f1_score.html ;
torchmetrics F1Score — https://lightning.ai/docs/torchmetrics/stable/classification/f1_score.html .
Closing this issue is what unblocks the platform-parity lane (#1230–#1233) and review (#1235).

主要言語
Kotlin
スター
52
フォーク
15
平均マージ
1日 15時間
マージ済み PR(30日)
36

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

SKaiNET-developers/SKaiNET のほかの issue

SKaiNET-developers/SKaiNET の issue をすべて見る

似ている issue

Kotlin の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。