@@ -38,12 +38,12 @@ class BaseForecaster(ABC):
3838
3939** Model Types Implemented** :
4040
41- | Model | Class | Description | Key Parameter |
41+ | Model| Class| Description| Key Parameter|
4242| -------| -------| -------------| ---------------|
43- | ` naive ` | ` NaiveForecaster ` | Predicts last observed value for all horizons | None |
44- | ` seasonal_naive ` | ` SeasonalNaiveForecaster ` | Predicts value from same season in previous cycle | ` season_length ` (default: 7) |
45- | ` moving_average ` | ` MovingAverageForecaster ` | Predicts mean of last N observations | ` window_size ` (default: 7) |
46- | ` lightgbm ` | (Placeholder) | LightGBM regressor (feature-flagged) | ` n_estimators ` , ` max_depth ` , ` learning_rate ` |
43+ | ` naive ` | ` NaiveForecaster ` | Predicts last observed value for all horizons| None|
44+ | ` seasonal_naive ` | ` SeasonalNaiveForecaster ` | Predicts value from same season in previous cycle| ` season_length ` (default: 7)|
45+ | ` moving_average ` | ` MovingAverageForecaster ` | Predicts mean of last N observations| ` window_size ` (default: 7)|
46+ | ` lightgbm ` | (Placeholder)| LightGBM regressor (feature-flagged)| ` n_estimators ` , ` max_depth ` , ` learning_rate ` |
4747
4848** FitResult Dataclass** :
4949``` python
@@ -62,18 +62,18 @@ class FitResult:
6262
6363Pydantic v2 schemas with frozen configs for reproducibility:
6464
65- | Schema | Purpose |
65+ | Schema| Purpose|
6666| --------| ---------|
67- | ` ModelConfigBase ` | Base with ` schema_version ` and ` config_hash() ` |
68- | ` NaiveModelConfig ` | Config for naive forecaster |
69- | ` SeasonalNaiveModelConfig ` | Config with ` season_length ` (1-365) |
70- | ` MovingAverageModelConfig ` | Config with ` window_size ` (1-90) |
71- | ` LightGBMModelConfig ` | Config for LightGBM (n_estimators, max_depth, learning_rate) |
72- | ` TrainRequest ` | API request with store_id, product_id, date range, config |
73- | ` TrainResponse ` | Response with model_path, n_observations, duration_ms |
74- | ` PredictRequest ` | Request with horizon (1-90), model_path |
75- | ` PredictResponse ` | Response with forecast points |
76- | ` ForecastPoint ` | Single forecast with date, value, optional bounds |
67+ | ` ModelConfigBase ` | Base with ` schema_version ` and ` config_hash() ` |
68+ | ` NaiveModelConfig ` | Config for naive forecaster|
69+ | ` SeasonalNaiveModelConfig ` | Config with ` season_length ` (1-365)|
70+ | ` MovingAverageModelConfig ` | Config with ` window_size ` (1-90)|
71+ | ` LightGBMModelConfig ` | Config for LightGBM (n_estimators, max_depth, learning_rate)|
72+ | ` TrainRequest ` | API request with store_id, product_id, date range, config|
73+ | ` TrainResponse ` | Response with model_path, n_observations, duration_ms|
74+ | ` PredictRequest ` | Request with horizon (1-90), model_path|
75+ | ` PredictResponse ` | Response with forecast points|
76+ | ` ForecastPoint ` | Single forecast with date, value, optional bounds|
7777
7878** Key Features** :
7979- Frozen models (` frozen=True ` ) for immutability
@@ -150,10 +150,10 @@ class ForecastingService:
150150
151151** File** : ` app/features/forecasting/routes.py `
152152
153- | Endpoint | Method | Description |
153+ | Endpoint| Method| Description|
154154| ----------| --------| -------------|
155- | ` /forecasting/train ` | POST | Train a forecasting model |
156- | ` /forecasting/predict ` | POST | Generate forecasts using trained model |
155+ | ` /forecasting/train ` | POST| Train a forecasting model|
156+ | ` /forecasting/predict ` | POST| Generate forecasts using trained model|
157157
158158** Train Request Example** :
159159``` json
@@ -204,12 +204,12 @@ class ForecastingService:
204204
205205** Directory** : ` app/features/forecasting/tests/ `
206206
207- | File | Tests | Coverage |
207+ | File| Tests| Coverage|
208208| ------| -------| ----------|
209- | ` test_schemas.py ` | 20 | Schema validation, config hash, frozen models |
210- | ` test_models.py ` | 24 | Model fit/predict, edge cases, params |
211- | ` test_persistence.py ` | 15 | Save/load bundles, version compatibility |
212- | ` test_service.py ` | 20 | Service integration, validation, logging |
209+ | ` test_schemas.py ` | 20 | Schema validation, config hash, frozen models|
210+ | ` test_models.py ` | 24 | Model fit/predict, edge cases, params|
211+ | ` test_persistence.py ` | 15 | Save/load bundles, version compatibility|
212+ | ` test_service.py ` | 20 | Service integration, validation, logging|
213213
214214** Total** : 79 tests
215215
@@ -223,11 +223,11 @@ class ForecastingService:
223223
224224** Directory** : ` examples/models/ `
225225
226- | File | Description |
226+ | File| Description|
227227| ------| -------------|
228- | ` baseline_naive.py ` | Naive forecaster demo |
229- | ` baseline_seasonal.py ` | Seasonal naive with weekly seasonality |
230- | ` baseline_mavg.py ` | Moving average with configurable window |
228+ | ` baseline_naive.py ` | Naive forecaster demo|
229+ | ` baseline_seasonal.py ` | Seasonal naive with weekly seasonality|
230+ | ` baseline_mavg.py ` | Moving average with configurable window|
231231
232232---
233233
@@ -246,19 +246,19 @@ forecast_model_artifacts_dir: str = "./artifacts/models"
246246forecast_enable_lightgbm: bool = False
247247```
248248
249- | Setting | Default | Description |
249+ | Setting| Default| Description|
250250| ---------| ---------| -------------|
251- | ` forecast_random_seed ` | 42 | Random seed for reproducibility |
252- | ` forecast_default_horizon ` | 14 | Default forecast horizon in days |
253- | ` forecast_max_horizon ` | 90 | Maximum allowed horizon |
254- | ` forecast_model_artifacts_dir ` | ` ./artifacts/models ` | Directory for saved models |
255- | ` forecast_enable_lightgbm ` | False | Feature flag for LightGBM models |
251+ | ` forecast_random_seed ` | 42 | Random seed for reproducibility|
252+ | ` forecast_default_horizon ` | 14 | Default forecast horizon in days|
253+ | ` forecast_max_horizon ` | 90 | Maximum allowed horizon|
254+ | ` forecast_model_artifacts_dir ` | ` ./artifacts/models ` | Directory for saved models|
255+ | ` forecast_enable_lightgbm ` | False| Feature flag for LightGBM models|
256256
257257---
258258
259259## Directory Structure
260260
261- ```
261+ ``` text
262262app/features/forecasting/
263263├── __init__.py # Module exports
264264├── models.py # BaseForecaster + implementations
@@ -284,7 +284,7 @@ examples/models/
284284
285285## Validation Results
286286
287- ```
287+ ``` bash
288288$ uv run ruff check app/features/forecasting/
289289All checks passed!
290290
@@ -302,16 +302,16 @@ $ uv run pytest app/features/forecasting/tests/ -v
302302
303303## Logging Events
304304
305- | Event | Description |
305+ | Event| Description|
306306| -------| -------------|
307- | ` forecasting.train_request_received ` | Train request received |
308- | ` forecasting.train_request_completed ` | Training completed successfully |
309- | ` forecasting.train_request_failed ` | Training failed |
310- | ` forecasting.predict_request_received ` | Prediction request received |
311- | ` forecasting.predict_request_completed ` | Prediction completed |
312- | ` forecasting.predict_request_failed ` | Prediction failed |
313- | ` forecasting.model_saved ` | Model bundle saved to disk |
314- | ` forecasting.model_loaded ` | Model bundle loaded from disk |
307+ | ` forecasting.train_request_received ` | Train request received|
308+ | ` forecasting.train_request_completed ` | Training completed successfully|
309+ | ` forecasting.train_request_failed ` | Training failed|
310+ | ` forecasting.predict_request_received ` | Prediction request received|
311+ | ` forecasting.predict_request_completed ` | Prediction completed|
312+ | ` forecasting.predict_request_failed ` | Prediction failed|
313+ | ` forecasting.model_saved ` | Model bundle saved to disk|
314+ | ` forecasting.model_loaded ` | Model bundle loaded from disk|
315315
316316---
317317
0 commit comments