This project focuses on predicting electricity load consumption using three different approaches: Statistical (VAR), Machine Learning (XGBoost), and Deep Learning (LSTM). The goal is to identify the most accurate model for short-term energy demand forecasting, which is crucial for grid stability and energy management.
- Source: Electricity Load Diagrams 2011-2014 (UCI Machine Learning Repository).
- Format: Hourly resampled time-series data.
- Features: Load (Target), Temperature, Humidity, Wind speed, and Hour of the day.
Before modeling, I performed Exploratory Data Analysis to understand the data patterns:
- Seasonality: High demand during specific hours of the day (Business hours).
- Correlation: Analyzed the relationship between weather variables (Temperature, Wind) and electricity load.
- Data Preprocessing: Handled missing values (zeros), resampled to hourly frequency, and performed feature scaling using
StandardScaler. - Feature Engineering: Created lag features (1-24h), rolling means, and rolling standard deviations to capture temporal trends.
- Modeling:
- VAR (Vector Autoregression): A traditional statistical model for multivariate time series.
- XGBoost: A powerful gradient boosting algorithm with custom time-series features.
- LSTM (Long Short-Term Memory): A Recurrent Neural Network (RNN) designed to learn long-term dependencies.
| Model | RMSE | MAE | MAPE (%) | Accuracy (%) |
|---|---|---|---|---|
| VAR | 19.94 | 18.28 | 71.29% | 28.71% |
| XGBoost | 0.47 | 0.14 | 0.74% | 99.26% |
| LSTM | 3.63 | 2.87 | 12.01% | 87.99% |
The following chart compares the predictions of all three models against the actual load for the last 100 hours of the test set:
- Model Selection: XGBoost significantly outperformed other models in this specific dataset, making it the most reliable for short-term forecasting.
- Actionable Advice: Energy providers can use the XGBoost model to predict peak loads with >99% accuracy, allowing for better resource allocation and cost reduction.
- Clone the repository:
git clone https://github.com/diphacf/TSD_models.git
- Install dependencies:
pip install -r requirements.txt
- Open TSD_models.ipynb and run all cells.