Start fixing forecast service 16
This commit is contained in:
@@ -220,7 +220,7 @@ class PredictionService:
|
||||
# Add numeric features with safe conversion
|
||||
numeric_features = [
|
||||
'temperature', 'precipitation', 'humidity', 'wind_speed',
|
||||
'traffic_volume', 'pedestrian_count', 'pressure' # ✅ FIX: Added pressure
|
||||
'traffic_volume', 'pedestrian_count', 'pressure'
|
||||
]
|
||||
|
||||
for feature in numeric_features:
|
||||
@@ -313,15 +313,13 @@ class PredictionService:
|
||||
df['is_heavy_rain'] = int(precip > 10.0)
|
||||
df['rain_intensity'] = int(self._get_rain_intensity(precip))
|
||||
|
||||
# Traffic-based features (if available)
|
||||
# Traffic-based features
|
||||
if 'traffic_volume' in df.columns and df['traffic_volume'].iloc[0] > 0:
|
||||
traffic = df['traffic_volume'].iloc[0]
|
||||
# Simple categorization since we don't have historical data for quantiles
|
||||
df['high_traffic'] = int(traffic > 150) # Assumption based on typical values
|
||||
df['low_traffic'] = int(traffic < 50)
|
||||
df['traffic_normalized'] = float((traffic - 100) / 50) # Simple normalization
|
||||
|
||||
# ✅ FIX: Add additional traffic features that might be in training
|
||||
df['congestion_level'] = int(min(5, max(1, traffic // 50)))
|
||||
df['traffic_squared'] = traffic ** 2
|
||||
df['traffic_log'] = float(np.log1p(traffic)) # log(1+traffic) to handle zeros
|
||||
else:
|
||||
@@ -330,6 +328,7 @@ class PredictionService:
|
||||
df['traffic_normalized'] = 0.0
|
||||
df['traffic_squared'] = 0.0
|
||||
df['traffic_log'] = 0.0
|
||||
df['congestion_level'] = 1
|
||||
|
||||
# Interaction features (common in training)
|
||||
if 'is_weekend' in df.columns and 'temperature' in df.columns:
|
||||
|
||||
Reference in New Issue
Block a user