← 返回 Skills 市场
sxy799

Electricity Forecasting Framework

作者 sxy799 · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
87
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install electricity-forecasting-framework
功能描述
Comprehensive electricity load and demand forecasting framework. Supports statistical methods (ARIMA, SARIMA), machine learning (XGBoost, LightGBM, Random Fo...
使用说明 (SKILL.md)

Electricity Forecasting Framework

Overview

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

Quick Start

1. Define Your Forecasting Task

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

2. Prepare Your Data

# 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)
  • Optional: humidity, wind_speed, solar_radiation, holiday_flag

3. Select Your Model

See references/model-selection.md for detailed guidance.

Quick recommendation:

  • Baseline: Start with persistence or seasonal-naive
  • Production STLF: Use XGBoost or LightGBM with weather features
  • Research/SOTA: Try Temporal Fusion Transformer (TFT) or iTransformer

4. Train and Evaluate

python scripts/train_model.py --model xgboost --data processed/ --horizon 24

Key metrics to track:

  • MAPE (%): Mean Absolute Percentage Error - business interpretability
  • RMSE (MW): Root Mean Square Error - penalizes large errors
  • MAE (MW): Mean Absolute Error - robust to outliers
  • Coverage (%): Prediction interval coverage probability

Core Workflows

Data Preprocessing

  1. Load raw data with proper datetime parsing
  2. Handle missing values: Forward-fill for short gaps, interpolate for longer
  3. Feature engineering:
    • Temporal: hour, day_of_week, month, is_weekend, is_holiday
    • Lag features: load_t-1, load_t-24, load_t-168 (weekly)
    • Rolling stats: rolling_mean_24h, rolling_std_7d
    • Weather: temperature, humidity, apparent_temperature
  4. Normalization: RobustScaler or MinMaxScaler for deep learning models

See references/feature-engineering.md for complete feature list.

Model Training

# 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)

Hyperparameter Tuning

Use scripts/hyperparameter_search.py for automated tuning:

python scripts/hyperparameter_search.py \
  --model lightgbm \
  --data processed/ \
  --n-trials 50 \
  --study-name stlf-tuning

Uncertainty Quantification

For risk-aware decision making:

  • Quantile Regression: Predict multiple quantiles (0.1, 0.5, 0.9)
  • Conformal Prediction: Distribution-free uncertainty bounds
  • Ensemble Methods: Model disagreement as uncertainty proxy
  • Monte Carlo Dropout: For neural networks

See references/uncertainty.md for implementation details.

Model Reference

Statistical Models

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

Machine Learning Models

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

Deep Learning Models

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.

Evaluation Best Practices

Time Series Cross-Validation

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

Backtesting Framework

python scripts/backtest.py \
  --model xgboost \
  --data processed/ \
  --cv-splits 5 \
  --horizon 24 \
  --metrics mape,rmse,mae

Benchmark Comparison

Always compare against:

  1. Persistence: load_t = load_t-1
  2. Seasonal Naive: load_t = load_t-24 (for hourly data)
  3. Weekly Naive: load_t = load_t-168

Deployment

Production Pipeline

  1. Model serialization: Save with joblib or ONNX
  2. Feature pipeline: Ensure identical preprocessing at inference
  3. Scheduling: Cron or Airflow for automated forecasts
  4. Monitoring: Track forecast drift and retrain triggers

See references/deployment.md for MLOps patterns.

Real-time Inference

from electricity_forecasting import DeploymentModel

model = DeploymentModel.load("models/xgboost-stlf.joblib")
features = prepare_features(latest_data)
prediction = model.predict(features, return_uncertainty=True)

Common Pitfalls

  1. Data leakage: Ensure no future information in features
  2. Holiday handling: Special days need explicit modeling
  3. Temperature nonlinearity: Use heating/cooling degree days
  4. Concept drift: Retrain quarterly or when MAPE degrades >20%
  5. Peak prediction: Models often under-predict peaks - consider quantile loss

Resources

Scripts

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

Example Usage

# 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/
安全使用建议
This package appears coherent for electricity forecasting. Before running it: (1) review the full scripts (especially deploy_model.py, batch_forecast/send_to_downstream and any truncated functions) to confirm any network endpoints they call; (2) supply API keys only for trusted weather/data providers and store them securely (env vars or secret manager), since example code shows placeholders; (3) run in an isolated virtual environment or container and avoid running as root (batch job writes to /var/log and reads/writes models/ and forecasts/ directories); (4) pin dependencies and audit third‑party libraries (PyTorch, LightGBM, joblib, FastAPI, requests, etc.) before deploying to production. If you want, I can scan the specific scripts (deploy_model.py, batch_forecast, send_to_downstream) for any network calls or unexpected behavior.
功能分析
Type: OpenClaw Skill Name: electricity-forecasting-framework Version: 1.0.0 The electricity-forecasting-framework is a comprehensive and professionally structured toolkit for time-series forecasting. It includes a full suite of scripts for data preprocessing (prepare_data.py), model training (train_model.py), hyperparameter optimization (hyperparameter_search.py), and production deployment (deploy_model.py). The framework supports a wide range of models including LightGBM, XGBoost, and PyTorch-based deep learning architectures like LSTMs and Transformers. Analysis of the code and documentation (SKILL.md and various reference files) reveals no evidence of malicious intent, data exfiltration, or unauthorized persistence. While the deployment script uses joblib for model serialization, which is a common but known security risk with untrusted files, its use here is strictly functional and aligned with the stated purpose of the skill.
能力评估
Purpose & Capability
Name/description match the included scripts and reference docs (data prep, training, evaluation, deployment). Nothing in the manifest asks for unrelated cloud credentials, binaries, or config paths.
Instruction Scope
SKILL.md directs the agent to run local Python scripts, prepare data, train models, and run FastAPI/batch jobs. Instructions reference weather/data APIs as examples (with placeholder API keys) but do not instruct reading unrelated system files or exfiltrating secrets.
Install Mechanism
No install spec is provided (instruction-only). All code is included in the package; nothing is downloaded from external URLs or extracted to disk during an install step.
Credentials
The skill declares no required environment variables or credentials. Example snippets show usage of third‑party APIs that would need user-supplied API keys, which is expected for such data sources and not requested by the skill itself.
Persistence & Privilege
always:false and normal agent invocation settings. The skill does not request persistent system privileges or attempt to modify other skills or global agent config in the provided files.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install electricity-forecasting-framework
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /electricity-forecasting-framework 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
- Initial release of a comprehensive electricity load and demand forecasting framework. - Supports statistical (ARIMA, SARIMA), machine learning (XGBoost, LightGBM, Random Forest), and deep learning models (LSTM, GRU, Transformer, TFT). - Includes tools for data preparation, feature engineering, training, evaluation, backtesting, and deployment. - Provides built-in uncertainty quantification and clear best practices for time series validation and benchmarking. - Detailed documentation and scripts provided for end-to-end forecasting pipelines.
元数据
Slug electricity-forecasting-framework
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Electricity Forecasting Framework 是什么?

Comprehensive electricity load and demand forecasting framework. Supports statistical methods (ARIMA, SARIMA), machine learning (XGBoost, LightGBM, Random Fo... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 87 次。

如何安装 Electricity Forecasting Framework?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install electricity-forecasting-framework」即可一键安装,无需额外配置。

Electricity Forecasting Framework 是免费的吗?

是的,Electricity Forecasting Framework 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Electricity Forecasting Framework 支持哪些平台?

Electricity Forecasting Framework 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Electricity Forecasting Framework?

由 sxy799(@sxy799)开发并维护,当前版本 v1.0.0。

💬 留言讨论