Add POI feature and imporve the overall backend implementation
This commit is contained in:
@@ -210,9 +210,23 @@ class EnhancedBakeryMLTrainer:
|
||||
# Process data for each product using enhanced processor
|
||||
logger.info("Processing data using enhanced processor")
|
||||
processed_data = await self._process_all_products_enhanced(
|
||||
sales_df, weather_df, traffic_df, products, tenant_id, job_id, session
|
||||
sales_df, weather_df, traffic_df, products, tenant_id, job_id, training_dataset.poi_features, session
|
||||
)
|
||||
|
||||
# Validate that we have processed data
|
||||
if not processed_data or len(processed_data) == 0:
|
||||
error_msg = f"No products could be processed successfully. Found {len(products)} products in sales data but all failed during processing."
|
||||
logger.error("Training aborted - no processed data",
|
||||
tenant_id=tenant_id,
|
||||
job_id=job_id,
|
||||
products_found=len(products),
|
||||
products_processed=0)
|
||||
raise ValueError(error_msg)
|
||||
|
||||
logger.info(f"Successfully processed {len(processed_data)} out of {len(products)} products",
|
||||
products_processed=len(processed_data),
|
||||
products_found=len(products))
|
||||
|
||||
# Categorize all products for category-specific forecasting
|
||||
logger.info("Categorizing products for optimized forecasting")
|
||||
product_categories = await self._categorize_all_products(
|
||||
@@ -491,6 +505,7 @@ class EnhancedBakeryMLTrainer:
|
||||
products: List[str],
|
||||
tenant_id: str,
|
||||
job_id: str,
|
||||
poi_features: Dict[str, Any],
|
||||
session=None) -> Dict[str, pd.DataFrame]:
|
||||
"""Process data for all products using enhanced processor with repository tracking"""
|
||||
processed_data = {}
|
||||
@@ -515,6 +530,7 @@ class EnhancedBakeryMLTrainer:
|
||||
weather_data=weather_df,
|
||||
traffic_data=traffic_df,
|
||||
inventory_product_id=inventory_product_id,
|
||||
poi_features=poi_features, # POI features for location-based forecasting
|
||||
tenant_id=tenant_id,
|
||||
job_id=job_id,
|
||||
session=session # Pass the session to avoid creating new ones
|
||||
@@ -1132,6 +1148,7 @@ class EnhancedBakeryMLTrainer:
|
||||
weather_data=test_weather_df,
|
||||
traffic_data=test_traffic_df,
|
||||
inventory_product_id=inventory_product_id,
|
||||
poi_features=test_dataset.poi_features, # POI features for location-based forecasting
|
||||
tenant_id=tenant_id
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user