coolride-telegram / docs /ML_Architecture_Update.md
Swaminaatha krishna
feat(routing): replace heuristic cooling bonuses with ML-derived weights
11df42f
|
Raw History Blame Contribute Delete
2 kB

ML Architecture Update: Data-Driven Cooling Bonus

The original get_cool_cost_fast function used hand-tuned, arbitrary weights to calculate a cooling_bonus for each road edge: +0.3 for tree proximity, +0.1 for water proximity, and +0.4 for park connector (PCN) overlap. These values were chosen by intuition rather than empirical measurement and treated all three factors as roughly equal in their thermal comfort impact, which the field pilot data does not support.

A Random Forest Regressor was trained on 15 waypoints collected across three Singapore microclimates (Upper Changi, CBD, Punggol) during the February 2026 pilot. The model's target was a blended score combining normalised WBGT readings (70% weight) and subjective thermal comfort surveys (30% weight). Feature importances extracted from the trained model (n_estimators=100, max_depth=3) revealed a clear hierarchy: Water Proximity dominates at 0.325, followed by PCN Proximity at 0.257, Canopy Density at 0.119, and Urban Canyon / SVF at 0.110. Macro air temperature (NEA baseline) scored 0.188 but is already captured dynamically by the existing weather_amplifier and was therefore excluded from the static bonus.

These four RF-derived weights now replace the old constants directly in the edge_static_costs pre-computation loop (src/main.py), stored under the key ml_cooling_bonus. The same STRtree spatial distance thresholds (17 m for trees, 33 m for water, 11 m for PCN) are preserved so no spatial logic changed — only the magnitude of the reward signal. The SVF term is approximated as a binary proxy (primary/secondary road type) for the prototype, pending integration of a full building-density spatial join. The Dijkstra cost floor was tightened from max(0.5, weight) to max(0.1, weight) to allow highly cool corridors (e.g., waterfront PCN paths) to be more aggressively preferred without risking a zero or negative edge weight that would break the shortest-path algorithm.