Add POI feature and imporve the overall backend implementation
This commit is contained in:
@@ -52,6 +52,10 @@ class BakeryForecaster:
|
||||
self.predictor = BakeryPredictor(database_manager)
|
||||
self.use_enhanced_features = use_enhanced_features
|
||||
|
||||
# Initialize POI feature service
|
||||
from app.services.poi_feature_service import POIFeatureService
|
||||
self.poi_feature_service = POIFeatureService()
|
||||
|
||||
if use_enhanced_features:
|
||||
# Import enhanced data processor from training service
|
||||
import sys
|
||||
@@ -167,11 +171,24 @@ class BakeryForecaster:
|
||||
'pressure': [features.get('pressure', 1013.0)]
|
||||
})
|
||||
|
||||
# Fetch POI features if tenant_id is available
|
||||
poi_features = None
|
||||
if 'tenant_id' in features:
|
||||
poi_features = await self.poi_feature_service.get_poi_features(
|
||||
features['tenant_id']
|
||||
)
|
||||
if poi_features:
|
||||
logger.info(
|
||||
f"Retrieved {len(poi_features)} POI features for prediction",
|
||||
tenant_id=features['tenant_id']
|
||||
)
|
||||
|
||||
# Use data processor to create ALL enhanced features
|
||||
df = await self.data_processor.prepare_prediction_features(
|
||||
future_dates=future_dates,
|
||||
weather_forecast=weather_df,
|
||||
traffic_forecast=None, # Will add when traffic forecasting is implemented
|
||||
poi_features=poi_features, # POI features for location-based forecasting
|
||||
historical_data=historical_data # For lagged features
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user