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.py

Force training (case-insensitive boolean):

>>> python tasks/task_demo.py --force_train false

Save the plot as a single HTML file (default: task_demo_plot.html):

>>> python tasks/task_demo.py --html

Save to a specific path:

>>> python tasks/task_demo.py --html results/plot.html

Functions

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.