tasks.task_demo
tasks.task_demo
Task demo: compare baseline, covariate, and custom LightGBM forecasts against ground truth.
This script executes the baseline N-to-1 task, the covariate-enhanced N-to-1 pipeline, and a custom LightGBM model with optimized hyperparameters, then loads the ground truth from ~/spotforecast2_data/data_test.csv using the safety-critical load_actual_combined function from spotforecast2_safe, and plots Actual vs Predicted using Plotly.
The plot includes
- Actual combined values (ground truth)
- Baseline combined prediction (n2n_predict)
- Covariate combined prediction (n2n_predict_with_covariates, default LGBM)
- Custom LightGBM combined prediction (optimized hyperparameters, Europe/Berlin tz)
Safety-Critical Features
- Uses load_actual_combined from spotforecast2_safe for validated data loading
- DemoConfig provides immutable configuration with sensible defaults
- Path objects ensure cross-platform compatibility
- Comprehensive error handling with file existence checks
Examples
Run the demo:
>>> python tasks/task_demo.pyForce training (case-insensitive boolean):
>>> python tasks/task_demo.py --force_train falseSave the plot as a single HTML file (default: task_demo_plot.html):
>>> python tasks/task_demo.py --htmlSave to a specific path:
>>> python tasks/task_demo.py --html results/plot.htmlFunctions
| Name | Description |
|---|---|
| main | Run the demo, compute predictions for three models, and plot actual vs predicted. |
main
tasks.task_demo.main(force_train=True, html_path=None)Run the demo, compute predictions for three models, and plot actual vs predicted.