From 8b921624666141c09cf20e2e0ee3cbe260a6412d Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Mon, 24 Aug 2026 09:27:29 +0200 Subject: Add type filtering, drop hard-coded filters and route filter, tune backtest --- cli/cli.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'cli/cli.go') diff --git a/cli/cli.go b/cli/cli.go index bd54b35..e2138cd 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -28,11 +28,6 @@ var ( enablePprof = flag.Bool("pprof", false, "expose pprof endpoints at /debug/pprof") ) -const ( - backtestMinimumDistanceM = 10_000 - backtestMinimumMovingRatio = 0.8 -) - func Run(db *sql.DB, configPath string, appConfig config.Config) { switch { case *fetchOSM: @@ -127,16 +122,21 @@ func runBacktest(db *sql.DB) error { fmt.Fprintf(table, "p%g\t%.1f\n", p, distribution[p]) } table.Flush() - slog.Info("Moving time backtest", "rides", len(samples), "min_distance_m", backtestMinimumDistanceM, "min_moving_ratio", backtestMinimumMovingRatio, "mean_err_pct", math.Round(meanAbsErr(absErrors)*10)/10, "stderr_pct", math.Round(stdErrAbsErr(absErrors)*10)/10) + slog.Info("Moving time backtest", "rides", len(samples), "mean_err_pct", math.Round(meanAbsErr(absErrors)*10)/10, "stderr_pct", math.Round(stdErrAbsErr(absErrors)*10)/10) return nil } func isBacktestEligible(item ride.StoredRide) bool { - return item.GPXPath != "" && - item.DistanceM >= backtestMinimumDistanceM && - item.ExternalMovingTimeS > 0 && - item.ElapsedTimeS > 0 && - float64(item.ExternalMovingTimeS)/float64(item.ElapsedTimeS) >= backtestMinimumMovingRatio + if item.GPXPath == "" || item.ExternalMovingTimeS <= 0 || item.ElapsedTimeS <= 0 { + return false + } + if !item.IsCategorised() { + return false + } + if item.RideType == ride.RideTypeIndoor || item.RideType == ride.RideTypeTransport { + return false + } + return true } func meanAbsErr(absErrors []float64) float64 { -- cgit v1.3