Pomme de Pain ML
Forecasting sales and waste for every product in a store, and recommending the right quantities to order.
- Deep Learning
- LSTM
- PyTorch
- FastAPI
- React
- Recharts
- Forecasting

Context
In a fast-food store, orders follow a fixed rule from head office: the average of the same weekdays, plus a safety margin. That rule ignores weather, public holidays, school breaks and local events. The result: unsold products thrown away on some days, stock-outs on others.
This project covers the full chain for a store in Saint-Quentin-en-Yvelines: data → model → API → interface, across 50 products and two years of history.
The data is simulated (fictional but realistic): no real data from the brand is used.
Problem
Forecast sales and waste for every product and every day, turn those forecasts into order quantities, and prove the gain over the current rule, in euros, on a period the model has never seen.
Architecture
- Data preparation (pandas): loading, validation, cleaning, feature engineering and a time-based split. A single feature definition is shared between training and the API.
- Model: a 2-layer LSTM with temporal attention and a residual connection, with three heads: sales, waste and a waste-risk class. It reads a 28-day window combining recent sales, the calendar, weather, local event impact and product attributes. Beyond the next day, forecasting is recursive.
- Recommendations and alerts: the recommended order comes from the forecast. Stock-out or waste alerts are raised when head office’s order falls outside the forecast interval over the next 3 days, with resolved alerts tracked.
- FastAPI backend: dashboard, forecasts, accuracy backtest, waste analysis, head office vs AI comparison, alerts, products, events and an assistant.
- React interface (Vite, Tailwind, Recharts): dashboard, forecasts with intervals, waste analysis, head office vs AI simulation, alerts, product pages and a Model & method page exposing the evaluation.
- Assistant: answers natural-language questions (a product’s forecast, alerts, waste, best sellers, events) from the data and forecasts.
- Industrialisation: Docker Compose, pytest tests, GitHub Actions CI and a Makefile.
Results
Evaluated on October–December 2023, a period never seen during training:
- Accuracy: forecast error (WAPE) of 14.8%, versus 22.4% for the same-weekday average and 25.7% for the naive “D-7” method.
- Ordering simulation over the same period: unsold-stock cost cut by about 20% and margin lost to stock-outs reduced more than 2.5× compared with head office’s rule.
- Limits documented in the app: the forecast interval needs recalibrating for the year-end period, and demand lost during past stock-outs can’t be observed.
Screenshots


