Install
openclaw skills install electricity-forecasting-frameworkComprehensive electricity load and demand forecasting framework. Supports statistical methods (ARIMA, SARIMA), machine learning (XGBoost, LightGBM, Random Forest), and deep learning (LSTM, GRU, Transformer, TFT). Use when building short-term load forecasting (STLF) systems, predicting electricity demand for energy trading, analyzing consumption patterns, integrating weather features, evaluating forecasts with MAPE/RMSE/MAE, or deploying production pipelines with uncertainty quantification.
openclaw skills install electricity-forecasting-frameworkThis skill provides end-to-end support for electricity load/demand forecasting projects, from data preprocessing to model deployment. It covers traditional statistical methods, modern machine learning approaches, and state-of-the-art deep learning architectures.
| Horizon | Type | Typical Use |
|---|---|---|
| 1-48 hours | Short-term (STLF) | Grid operations, unit commitment |
| 1 week - 1 month | Medium-term | Maintenance scheduling, fuel planning |
| 1-12 months | Long-term (LTLF) | Capacity planning, infrastructure investment |
# Run the data preparation script
python scripts/prepare_data.py --input raw_load.csv --output processed/
Required data columns:
timestamp: Datetime index (hourly or sub-hourly)load: Target variable (MW or kWh)temperature: Weather feature (°C)See references/model-selection.md for detailed guidance.
Quick recommendation:
persistence or seasonal-naiveXGBoost or LightGBM with weather featuresTemporal Fusion Transformer (TFT) or iTransformerpython scripts/train_model.py --model xgboost --data processed/ --horizon 24
Key metrics to track:
See references/feature-engineering.md for complete feature list.
# Example training workflow
from electricity_forecasting import ForecastPipeline
pipeline = ForecastPipeline(
model_type="xgboost",
horizon=24,
lookback=168 # 1 week of history
)
pipeline.fit(train_data, val_data)
predictions, uncertainty = pipeline.predict(test_data)
metrics = pipeline.evaluate(predictions, actuals)
Use scripts/hyperparameter_search.py for automated tuning:
python scripts/hyperparameter_search.py \
--model lightgbm \
--data processed/ \
--n-trials 50 \
--study-name stlf-tuning
For risk-aware decision making:
See references/uncertainty.md for implementation details.
| Model | Best For | Pros | Cons |
|---|---|---|---|
| ARIMA | Stable series | Interpretable, fast | Assumes linearity |
| SARIMA | Strong seasonality | Captures daily/weekly patterns | Manual parameter tuning |
| Prophet | Multiple seasonalities | Handles holidays well | Less accurate for STLF |
| TBATS | Complex seasonality | Automatic parameter selection | Slower training |
| Model | Best For | Pros | Cons |
|---|---|---|---|
| XGBoost | Production STLF | Fast, accurate, handles missing | No native uncertainty |
| LightGBM | Large datasets | Faster than XGBoost, memory efficient | Sensitive to hyperparameters |
| Random Forest | Baseline ML | Robust, easy to tune | Lower accuracy than boosting |
| CatBoost | Categorical features | Handles categoricals natively | Slower training |
| Model | Best For | Pros | Cons |
|---|---|---|---|
| LSTM | Sequential patterns | Captures long-term dependencies | Slow training, hard to tune |
| GRU | Similar to LSTM | Faster convergence | Similar limitations |
| Transformer | Long sequences | Parallel training, attention | Data-hungry, complex |
| TFT | Multi-horizon | Interpretable attention, uncertainty | Complex implementation |
| N-BEATS | Pure deep learning | Strong baseline, interpretable | Less flexible than TFT |
| iTransformer | SOTA performance | Inverted transformer architecture | Recent, less battle-tested |
See references/deep-learning-models.md for architecture details and PyTorch implementations.
Never use random k-fold! Use expanding or sliding window:
# Expanding window CV
from sklearn.model_selection import TimeSeriesSplit
tscv = TimeSeriesSplit(n_splits=5, test_size=168) # 1 week test
for train_idx, test_idx in tscv.split(data):
train, test = data[train_idx], data[test_idx]
# Train and evaluate
python scripts/backtest.py \
--model xgboost \
--data processed/ \
--cv-splits 5 \
--horizon 24 \
--metrics mape,rmse,mae
Always compare against:
See references/deployment.md for MLOps patterns.
from electricity_forecasting import DeploymentModel
model = DeploymentModel.load("models/xgboost-stlf.joblib")
features = prepare_features(latest_data)
prediction = model.predict(features, return_uncertainty=True)
| Script | Purpose |
|---|---|
scripts/prepare_data.py | Data cleaning and feature engineering |
scripts/train_model.py | Model training with validation |
scripts/hyperparameter_search.py | Automated hyperparameter optimization |
scripts/backtest.py | Time series cross-validation |
scripts/evaluate.py | Comprehensive metric calculation |
scripts/deploy_model.py | Export model for production |
# Complete workflow example
# 1. Prepare data
python scripts/prepare_data.py --input data/load_2024.csv --output data/processed/
# 2. Train model
python scripts/train_model.py --model lightgbm --data data/processed/ --horizon 48
# 3. Hyperparameter tuning
python scripts/hyperparameter_search.py --model lightgbm --data data/processed/ --n-trials 100
# 4. Backtest
python scripts/backtest.py --model lightgbm-best --data data/processed/ --cv-splits 5
# 5. Deploy
python scripts/deploy_model.py --model lightgbm-best --output models/production/