Conversation
nhoening
left a comment
There was a problem hiding this comment.
Just taking an early quick look :)
- In the PR description, describe what the new feature is (a CLI command) and any other additions. People do not care too much that this code lived somewhere else before.
- Do we need to use the word "residential" anymore? It is still in package names and the save path, but I don't see a reason to use it.
- We don't have a
srcpackage convention in FlexMeasures, so IMO that can also go. - We usually write tests for code in FlexMeasures, at least outside of the CLI package. Is there a plan how we can test the new code that defines forecasting pipelines? Maybe we can later re-use the current test code for forecasting jobs?
flexmeasures/data/models/forecasting/residential/src/pipelines/base_pipeline.py
Outdated
Show resolved
Hide resolved
flexmeasures/data/models/forecasting/residential/src/custom_models/lgbm_model.py
Show resolved
Hide resolved
flexmeasures/data/models/forecasting/residential/src/pipelines/train_predict_pipeline.py
Outdated
Show resolved
Hide resolved
flexmeasures add forecasts
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new forecasting pipeline system into FlexMeasures, implementing "fixed-view-point forecasting" where models are retrained from scratch with progressively extended training windows. The pipeline supports both autoregressive and regressor-based forecasting modes, with the ability to run forecasting jobs immediately or schedule them in a forecasting queue.
Key changes include:
- New forecasting pipeline architecture with modular components for training, prediction, and combined train-predict cycles
- CLI integration replacing the deprecated
flexmeasures add forecastscommand with new functionality - U8darts library integration for advanced time series forecasting capabilities
Reviewed Changes
Copilot reviewed 20 out of 23 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| requirements/app.in | Adds u8darts[notorch]>=0.29.0 dependency for forecasting capabilities |
| flexmeasures/cli/data_add.py | Replaces deprecated forecasting command with new train_predict_pipeline functionality |
| flexmeasures/data/schemas/forecasting/pipeline.py | Implements comprehensive validation schema for forecasting pipeline parameters |
| flexmeasures/data/models/forecasting/pipelines/ | New modular pipeline architecture with base, train, predict, and train_predict components |
| flexmeasures/data/models/forecasting/custom_models/ | Custom model implementations including LGBM model for multi-horizon forecasting |
Comments suppressed due to low confidence (4)
requirements/app.in:68
- The version 0.29.0 for u8darts appears to be non-existent. The latest available version of u8darts is 0.28.0. Consider using u8darts[notorch]>=0.28.0 instead.
u8darts[notorch]>=0.29.0
flexmeasures/data/models/forecasting/exceptions.py:16
- The parameter name
error_detailis misleading as it expects asysmodule, not error details. Consider renaming it tosys_moduleorerror_sysfor clarity.
_, _, exc_tb = error_detail.exc_info()
flexmeasures/data/models/forecasting/pipelines/base.py:376
- This function appears to be deprecated based on the TODO comment. Consider removing it if the ForecastingPipelineSchema has replaced its functionality, or update the documentation to clarify its current status.
)
flexmeasures/data/models/forecasting/custom_models/lgbm_model.py
Outdated
Show resolved
Hide resolved
nhoening
left a comment
There was a problem hiding this comment.
A review from the train, without ability to install dependencies and run by myself.
Mostly doc&naming but also one part where I believe we might be able to save ourselves some time.
flexmeasures/data/models/forecasting/custom_models/base_model.py
Outdated
Show resolved
Hide resolved
|
Two more questions:
|
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
…orizon validation) Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
…s ID Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: Mohamed Belhsan Hmida <[email protected]>
Signed-off-by: Mohamed Belhsan Hmida <[email protected]>
Signed-off-by: Mohamed Belhsan Hmida <[email protected]>
… PR. This reverts commit f1c9ca7. Signed-off-by: Mohamed Belhsan Hmida <[email protected]>
…e-forecasting-to-flexmeasures # Conflicts: # flexmeasures/cli/data_add.py # flexmeasures/cli/utils.py # requirements/app.in
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
…ast-frequency Signed-off-by: F.N. Claessen <[email protected]>
* feat: add as_job field to ForecasterParametersSchema for job configuration Signed-off-by: Mohamed Belhsan Hmida <[email protected]> * fix: add missing comma dict return Signed-off-by: Mohamed Belhsan Hmida <[email protected]> * test: add test case for as_job field in TrainPredictPipeline Signed-off-by: Mohamed Belhsan Hmida <[email protected]> * fix: merge forecasting job_kwargs into cycle params Signed-off-by: Mohamed Belhsan Hmida <[email protected]> * fix: as_job should not become a DataSource attribute Signed-off-by: F.N. Claessen <[email protected]> --------- Signed-off-by: Mohamed Belhsan Hmida <[email protected]> Signed-off-by: F.N. Claessen <[email protected]> Co-authored-by: F.N. Claessen <[email protected]>
* feat: add max-training-period option to CLI command Signed-off-by: Mohamed Belhsan Hmida <[email protected]> * feat: add max_training_period field to ForecasterParametersSchema and enforce its limit in validation Signed-off-by: Mohamed Belhsan Hmida <[email protected]> * feat: add logging for train-period exceeding max-training-period in ForecasterParametersSchema validation Signed-off-by: Mohamed Belhsan Hmida <[email protected]> * test: add test to verify logging and capping of train_period exceeding max_training_period Signed-off-by: Mohamed Belhsan Hmida <[email protected]> * style: run pre-commit Signed-off-by: Mohamed Belhsan Hmida <[email protected]> --------- Signed-off-by: Mohamed Belhsan Hmida <[email protected]> Signed-off-by: Mohamed Belhsan Hmida <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
…e-forecasting-to-flexmeasures
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
Description
This PR introduces a new forecasting pipelines into FlexMeasures. The pipelines train a model on historical sensor data and then generates forecasts over a specified prediction period. It supports both:
The pipeline works in forecasting cycles:
train-period).predict-period(up tomax-forecast-horizon).end-datehasn't been reached yet, the training window is extended and another cycle is run.end-dateis covered.This design follows the fixed view point forecasting paradigm: each cycle re-trains the model from scratch with a slightly extended training window.
The forecasting jobs can be run immediately or scheduled in the forecasting queue using the
--as-joboption.Key components include:
train_pipeline.py,predict_pipeline.py, andtrain_predict_pipeline.pyfor running forecasting cycles.custom_models/module where ML models (e.g., LGBM) can be plugged in.residentialforecasting module fromsmart-buildings/flexmeasures_smartbuildings/residentialtoflexmeasures/data/models/forecastingdocumentation/changelog.rstdocumentation/cli/change_log.rstLook and Feel
Further Improvements
follow-up PR's:
Related issue
Forecasters #690