Repository navigation
ETA推定の系統誤差を修正: 迂回係数を経路全体で較正し種別速度倍率を実ダイヤに合わせる - #1590
Conversation
実路線の時刻表(山手線・銀座線・井の頭線・東横線・中央快速/特快・京急快特・ 小田急快急・新快速など16ケース)と突き合わせたところ、推定誤差が±30%超に 散っており、利用頻度の高い都市部の優等列車(東横特急・中央特快・井の頭急行 など)で10〜17%の過小評価(ETAが短すぎる)が出ていた。 原因と修正: 1. 迂回係数αのスライス較正バグ(主因) αを「路線全体の平均実駅間距離(average_distance) ÷ クエリ区間スライスの 直線平均駅間距離」で計算していたため、駅間隔が路線平均と異なる部分区間 (長距離路線の都心側など)でαが上限1.6に張り付き、走行距離を最大60% 水増ししていた(例: 中央快速 東京→新宿 α=1.6、小田急 新宿→町田 α=1.53)。 較正母数を切り出し前の経路全体に変更(estimate_arrival_minutes_calibrated)。 隣接駅間では軌道距離≒直線距離のためαの実態は1.0〜1.05であり、この水増しが 一部路線で速度モデルの過小評価を偶然相殺して誤差の散らばりを生んでいた。 2. 種別速度倍率の見直し 従来はkind≠0の全種別に一律×1.2を掛けていたが、快速系(Branch/Rapid/ CommuterRapid)は各停と同じ車両・線路を走り速達性は通過で表現されるため ×1.0に。急行×1.15・特急×1.2は維持し、130km/h運転の新快速級 (HighSpeedRapid)は×1.5に引き上げ(新快速の+20〜25%過大評価を解消)。 3. 通過駅ペナルティの導入 分岐器・ホーム進入部の曲線で最高速度を維持できないぶんとして通過駅1駅 あたり3秒(pass_penalty_seconds)を加算。 較正ベンチマーク16ケースでの効果: 平均絶対誤差 9.6%→7.4%、最悪の過小評価 -17%→-10%、平均バイアス -2%→+2.7%(わずかに安全側=実際より早く着くと 表示しない方向)。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TsvFBx2rLj486tvj64M9eP
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 51 minutes Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough到着時刻推定モデルに通過駅ペナルティと列車種別速度倍率ロジックを追加し、迂回係数の較正母数を経路全体の駅列から計算する Changes到着時刻推定ロジック変更
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant QueryInteractor
participant estimate_arrival_minutes_calibrated
participant assign_segment_times
QueryInteractor->>estimate_arrival_minutes_calibrated: stops(区間), calibration_stops(route_stops)
estimate_arrival_minutes_calibrated->>estimate_arrival_minutes_calibrated: calibration_stopsから直線距離平均を計算
estimate_arrival_minutes_calibrated->>assign_segment_times: 較正済みdetour_by_lineを渡す
assign_segment_times-->>QueryInteractor: EstimatedStopリストを返す
Possibly related PRs
Suggested labels: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@stationapi/src/domain/arrival_estimation.rs`:
- Around line 505-520: The calibration logic in arrival_estimation’s detour
estimation currently only builds distances for adjacent station pairs, so a
circular route misses the final segment back to the first stop. Update the
calibration path handling in the detour calculation flow around
detour_factors_by_line and the calibration_straight_km setup to include the
closing edge for ring lines, or add a dedicated circular-route regression test
that verifies the full loop is included in average_distance-based calibration.
In `@stationapi/src/use_case/interactor/query.rs`:
- Around line 1204-1210: The circular-route calibration path in query.rs is
using the de-duplicated route_stops, which drops the closing segment from the
calibration basis. Update the is_circular_route branch around
select_circular_arc and estimate_arrival_minutes_calibrated so the calibration
input still accounts for the last-to-first seam on closed loops, instead of
passing only the truncated route_stops; make sure the fix preserves circular arc
handling while keeping the full adjacent-pair coverage needed for ETA
calibration.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: becd75c4-84a3-40b0-888a-3b846fd9337a
📒 Files selected for processing (2)
stationapi/src/domain/arrival_estimation.rsstationapi/src/use_case/interactor/query.rs
average_distance 自体が格納順の隣接ペアのみ(シーム辺なし)から算出されて いるため、分母(直線平均)も同じ母数にするのが整合的であることを記載。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TsvFBx2rLj486tvj64M9eP
概要
到着時間推定(ETA)が実乗車時間より短く出るという報告を受け、実路線の時刻表16ケース(山手線・銀座線・井の頭線・東横線・中央快速/特快・京急快特・小田急快急・新快速など)とモデル出力を突き合わせて系統誤差を較正した。都市部の優等列車(東横特急・中央特快・井の頭急行など)で10〜17%の過小評価が出ていた。
変更の種類
変更内容
average_distance)÷ クエリ区間スライスの直線平均駅間距離」で計算していたため、駅間隔が路線平均と異なる部分区間(長距離路線の都心側など)でαが上限1.6に張り付き、走行距離を最大60%水増ししていた(例: 中央快速 東京→新宿 α=1.6、小田急 新宿→町田 α=1.53)。較正母数を切り出し前の経路全体に変更するestimate_arrival_minutes_calibratedを追加し、estimate_route_arrival_timesの全呼び出し(線形スライス・逆順・環状弧)を切り替え。この水増しが一部路線で速度モデルの過大な速さを偶然相殺しており、誤差が±30%に散る原因になっていたkind != 0の全種別に一律×1.2を掛けていたが、快速系(Branch/Rapid/CommuterRapid)は各停と同じ車両・線路を走り速達性は通過で表現されるため×1.0に。急行×1.15・特急×1.2とし、130km/h運転の新快速級(HighSpeedRapid)は×1.5に引き上げ(新快速の+20〜25%過大評価を解消)pass_penalty_seconds)を走行時間に加算較正ベンチマーク16ケースでの効果: 平均絶対誤差 9.6%→7.4%、最悪の過小評価 -17%→-10%、平均バイアス -2%→+2.7%(「表示より早く着く」側にわずかに倒した設定)。既知の限界として、京急快特・小田急快急は実勢120km/h運転を kind から区別できず+20%ほど長めに出る(安全側)。
テスト
cargo fmt --all -- --checkが通ることcargo clippy -- -D warningsが通ることcargo test(SQLX_OFFLINE=true)が通ること関連Issue
スクリーンショット(任意)
🤖 Generated with Claude Code
https://claude.ai/code/session_01TsvFBx2rLj486tvj64M9eP
Generated by Claude Code
Summary by CodeRabbit
新機能
バグ修正