Refactor the traffic fetching system
This commit is contained in:
@@ -639,10 +639,17 @@ class EnhancedForecastingService:
|
||||
if precipitation > 2.0:
|
||||
adjustment_factor *= 0.7
|
||||
|
||||
# Apply adjustments
|
||||
# Apply adjustments to prediction
|
||||
adjusted_prediction = max(0, base_prediction * adjustment_factor)
|
||||
adjusted_lower = max(0, lower_bound * adjustment_factor)
|
||||
adjusted_upper = max(0, upper_bound * adjustment_factor)
|
||||
|
||||
# For confidence bounds, preserve relative interval width while respecting minimum bounds
|
||||
original_interval = upper_bound - lower_bound
|
||||
adjusted_interval = original_interval * adjustment_factor
|
||||
|
||||
# Ensure minimum reasonable lower bound (at least 20% of prediction or 5, whichever is larger)
|
||||
min_lower_bound = max(adjusted_prediction * 0.2, 5.0)
|
||||
adjusted_lower = max(min_lower_bound, adjusted_prediction - (adjusted_interval / 2))
|
||||
adjusted_upper = max(adjusted_lower + 10, adjusted_prediction + (adjusted_interval / 2))
|
||||
|
||||
return {
|
||||
"prediction": adjusted_prediction,
|
||||
|
||||
Reference in New Issue
Block a user