Skip to content

乗り換え判定の偽陽性を防止 - #5740

Merged
TinyKitten merged 1 commit into
devfrom
claude/fix-route-estimation-NbStJ
Apr 2, 2026
Merged

TinyKitten merged 1 commit into
devfrom
claude/fix-route-estimation-NbStJ

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Apr 2, 2026 •

Copy link
Copy Markdown
Member

概要

ルート推定時の乗り換え判定(isTransferStop)で、先頭エントリの速度が常に0になることによる偽陽性を防止します。また、ポイント数が少ない段階での判定を回避することで、低速移動時の誤検知を削減します。

変更の種類

  • バグ修正

変更内容

1. isTransferStopの判定ロジック修正

  • 問題: 前処理により先頭エントリはdistFromPrev=0, dtFromPrev=0となるため、常にspeed=0になります。これは仕様上の制約であり実際の停車ではないのに、停車判定の開始トリガーになっていました。
  • 対策: ループをindex=1から開始し、先頭エントリをスキップするように変更しました。

2. 推定開始前の最小ポイント数チェック

  • 問題: ポイント数が少ない段階で乗り換え判定を行うと、低速移動時に偽陽性が発生しやすくなります。
  • 対策: preprocessLogs呼び出し前に、バッファのポイント数がMIN_POINTS_FOR_ESTIMATION以上であることを確認するようにしました。

3. テストケースの追加

  • 先頭エントリのspeed=0による偽陽性を起こさないことを確認するテスト
  • 先頭以降のエントリが停車状態の場合に正しく検知することを確認するテスト

テスト

  • npm run lint が通ること
  • npm test が通ること(新規テストケース2つを追加)
  • npm run typecheck が通ること

https://claude.ai/code/session_016392JPYsBVtG4ESh75qRWB

Summary by CodeRabbit

リリースノート

  • バグ修正

    • ルート推定の精度向上 - データが不足している場合の不要な処理を削減し、転送停止の誤検出を防ぐようになりました。
  • テスト

    • ルート推定における転送停止検出のエッジケーステストを追加しました。

@TinyKitten TinyKitten self-assigned this Apr 2, 2026
@github-actions github-actions Bot added the react label Apr 2, 2026
@coderabbitai

coderabbitai Bot commented Apr 2, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d0db0e05-cd44-4a1c-afc1-3aafe6743541

📥 Commits

Reviewing files that changed from the base of the PR and between dd0b1a4 and 4355057.

📒 Files selected for processing (3)
  • src/hooks/useRouteEstimation.ts
  • src/utils/routeEstimation/__tests__/preprocessLogs.test.ts
  • src/utils/routeEstimation/preprocessLogs.ts

📝 Walkthrough

ウォークスルー

ルート推定機能において、バッファサイズが最小ポイント数未満の場合にログ前処理と転送停止検出をスキップするガード条件を追加しました。同時に、転送停止検出のループを最初のエントリをスキップして開始するよう変更し、テストケースを2件追加しました。

変更内容

コホート / ファイル 概要
バッファサイズ検証
src/hooks/useRouteEstimation.ts
buffer.length が MIN_POINTS_FOR_ESTIMATION より小さい場合、preprocessLogs と isTransferStop の処理をスキップするガード条件を追加しました。
転送停止検出ロジック
src/utils/routeEstimation/preprocessLogs.ts
isTransferStop のループをインデックス 1 から開始するよう変更し、最初のログエントリ(前回のデータが0の合成エントリ)を明示的にスキップするようにしました。
テストケース追加
src/utils/routeEstimation/__tests__/preprocessLogs.test.ts
2つの新しい isTransferStop テストケースを追加しました。エントリが2つで初回エントリが停止状態を示す場合、および複数エントリで停止状態を示す場合の動作をカバーしています。

推定コード審査時間

🎯 2 (シンプル) | ⏱️ ~12 分

ポエム

🐰 バッファ小さければ、スキップして進む、
ファーストエントリは置き去り、
転送停止の判定は、今ぞ正確!
テスト追加で信頼性アップ、
ルート推定、さらに磨かれり。

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed プルリクエストのタイトルは「乗り換え判定の偽陽性を防止」で、変更の主要な目的を明確かつ簡潔に表現しており、変更内容と完全に合致しています。
Description check ✅ Passed プルリクエストの説明は必須セクション(概要、変更の種類、変更内容、テスト)をすべて備えており、テンプレート形式に従い、具体的で詳細な情報を含んでいます。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/fix-route-estimation-NbStJ

Comment @coderabbitai help to get the list of available commands and usage tips.

@TinyKitten
TinyKitten merged commit 17540a7 into dev Apr 2, 2026
6 checks passed
@TinyKitten
TinyKitten deleted the claude/fix-route-estimation-NbStJ branch April 2, 2026 04:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants