CoffePrice generates next-business-day FNC coffee price predictions using a machine-learning pipeline that runs outside the main Node.js server. Results are written to static files that the backend reads on demand — keeping prediction delivery fast and decoupled from ML execution. Every prediction comes with a price range, a directional trend signal, and a confidence score so producers can quickly judge whether to act on a prediction or wait.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/JaiderT/CoffeePrice/llms.txt
Use this file to discover all available pages before exploring further.
What a Prediction Contains
Each prediction object exposes the following fields:| Field | Type | Description |
|---|---|---|
fecha | string (ISO date) | Target business day for the prediction (YYYY-MM-DD) |
precioestimado | number | Point estimate of the FNC price (COP/carga) |
preciominimo | number | Lower bound of the expected range |
preciomaximo | number | Upper bound of the expected range |
tendencia | string | Direction signal: "sube", "baja", or "estable" |
confianza | number (0–100) | Model confidence score (see calculation) |
modelVersion | string | Always "fnc_hibrido" for production predictions |
explicacion | string | Human-readable explanation generated by the pipeline |
estrategiaAplicada | string | Which strategy drove this prediction (e.g. "naive", "ensemble") |
holdoutMape | number | MAPE of the selected strategy on the holdout set |
generatedAt | string (ISO) | Timestamp when the pipeline produced this prediction |
Model Strategy
The prediction pipeline is a hybrid ensemble that blends four strategies. Ensemble weights and holdout metrics come directly fromml-service-experimental/modelos/metricas_fnc_hibrido.json:
Naive (45.16%)
Carries the largest weight. Predicts that tomorrow’s price will equal today’s. Lowest holdout MAPE on the current dataset: 0.88% (MAE: 19,714 COP/carga).
Formula (35.77%)
A calibrated regression formula applied to recent FNC price history. Holdout MAPE: 1.21% (MAE: 26,986 COP/carga).
Prophet (9.87%)
Facebook Prophet time-series model. Performs well on training data (MAPE 1.45%) but has higher holdout MAPE (4.37%), so it carries the second-lowest weight.
XGBoost / Hybrid (9.20%)
Gradient-boosted tree model using engineered lag features. Best training MAPE (0.40%), but highest holdout MAPE (4.69%), indicating overfitting on short series; carries the lowest ensemble weight.
naive with a MAPE of 0.88%. The pipeline automatically selects the strategy with the lowest holdout MAPE as estrategia_seleccionada and uses that selection to drive estrategiaAplicada in individual predictions.
Ensemble metrics summary (holdout set, 361 records, 354 supervised):
| Strategy | Holdout MAPE | Holdout MAE (COP) |
|---|---|---|
| naive | 0.88% | 19,714 |
| formula | 1.21% | 26,986 |
| ensemble | 1.52% | 33,784 |
| prophet | 4.37% | 96,647 |
| hybrid | 4.69% | 103,733 |
How Predictions Are Served
The backend reads predictions from flat files first; MongoDB is used only as a fallback.Latest prediction file
The controller reads
backend/datos/predicciones_fnc.json. If the file exists and passes schema validation (required fields: fecha_prediccion, precio_estimado, precio_minimo, precio_maximo, tendencia — all must be finite numbers and valid ISO dates), it is returned immediately.Historical CSV
backend/datos/historial_predicciones_fnc.csv stores all previous daily predictions. The controller parses it, cross-references ml-service-experimental/datos/evaluacion_predicciones_fnc.csv for actual-price evaluations, and merges the result with the latest JSON.Prediction Endpoints Overview
All endpoints are public (no authentication required). For full request/response schemas see the API → Predictions reference.| Endpoint | Description |
|---|---|
GET /api/predicciones/ultima | Latest available prediction |
GET /api/predicciones/resumen | Next-business-day summary (identical to /ultima from the file) |
GET /api/predicciones/rango?dias=7 | Last N days of predictions (valid values: 7, 15, 30) |
GET /api/predicciones/dia?offset=1 | Prediction for day +N (valid values: 1, 7, 15, 30) |
GET /api/predicciones/fecha?fecha=YYYY-MM-DD | Prediction for a specific calendar date |
GET /api/predicciones | All available predictions sorted by date ascending |
Confidence Calculation
The confidence score is derived from the holdout MAPE of the selected strategy:Example Prediction Object
Predictions always target the next business day. The pipeline skips weekends — if today is Friday, the prediction covers the following Monday. The
fecha field will reflect this skip automatically.