DOI QR코드

DOI QR Code

Machine Learning-Based Power Demand Forecasting: Model Development and Key Feature Analysis

머신러닝 기반 전력 수요 예측: 모델 개발 및 핵심 특성 분석

  • 차주호 (청운대학교 스마트시티전문대학원 및 공과대학 멀티미디어학과) ;
  • 류민우 (현대자동차 남양연구소 AVP 본부)
  • Received : 2025.11.15
  • Accepted : 2025.12.15
  • Published : 2025.12.30

Abstract

This study aims to develop a high-performance model for forecasting UK electricity demand (TSD) from 2009 to 2024 using machine learning. We implemented Random Forest, XGBoost, and LightGBM as individual models and a Stacking Ensemble model combining them. After the hyperparameter optimization using GridSearchCV, the Stacking Ensemble model achieved the best performance with an R2 score of 0.9926. Furthermore, Explainable AI (XAI) analysis using SHAP identified 'settlement_period' (time of day), 'month', and 'year' as the most critical features. This research demonstrates the superiority of the ensemble approach and provides transparent, interpretable grounds for predictions, contributing to data-driven decision-making in power system operations.

Keywords

Ⅰ. Introduction

Electricity is a core element of national infrastructure and daily life, but it has the physical characteristic of being difficult to store, requiring simultaneous production and consumption. Consequently, maintaining a real-time balance between electricity supply and demand is a central challenge for power system operation. If demand forecasts are lower than actual demand, it can lead to large-scale blackouts; conversely, if forecasts are too high, it results in unnecessary generation costs and energy waste [1]. Recently, the increasing share of highly variable renewable energy sources, such as solar and wind power, to address climate change has heightened the uncertainty of power supply, making accurate demand forecasting more important than ever [2]. In the past, statistical time-series analysis methods such as ARIMA (Autoregressive Integrated Moving Average) were widely used. However, these models had limitations in accurately reflecting the complex, non-linear patterns of electricity demand, which are influenced by a combination of various external factors such as temperature, holidays, and economic activity.

To overcome these limitations, this study utilizes machine learning (ML) techniques that can independently learn complex patterns from large-scale data [3]. Specifically, we build and forecast the long-term (2009-2024) electricity demand in the UK using modern ensemble models such as Random Forest [4], XGBoost [5], and LightGBM [6], as well as a Stacking Ensemble [7] model that combines their strengths. This study goes beyond merely achieving high prediction accuracy; it also deeply interprets the basis for the model's predictions using the Explainable AI (XAI) technique SHAP (Shapley Additive Explanations) [8]. Through this, we aim to secure the model's reliability, identify the key factors influencing electricity demand, and propose a practical methodology that enables power system operators to make data-driven, rational decisions.

The structure of this paper is as follows. Chapter 2 reviews prior research related to this study. Chapter 3 describes the data preparation, processing, model generation, and hyperparameter tuning for the machine learning-based power demand forecast. Chapter 4 provides a discussion of the performance evaluation results for the models. Finally, Chapter 5 presents the conclusions of this study and directions for future work.

Ⅱ. Related Work

Research on electricity demand forecasting has evolved from traditional statistical time-series models to studies based on machine learning and deep learning.

Statistical models like ARIMA and SARIMA (Seasonal ARIMA), which led early research, assume the stationarity of the data and predict the future based on the autocorrelation and moving averages of past data [9]. While these models were useful for capturing linear trends, they had clear limitations in effectively reflecting the complex non-linearities inherent in electricity demand or the impact of various external factors like temperature, holidays, and economic activity.

To overcome these limitations, machine learning models such as Artificial Neural Networks (ANN) and Support Vector Machines (SVM) began to be introduced in the 2000s [10]. These models could learn the non-linear relationships between input and output variables, often demonstrating superior performance to time-series models.

Recently, ensemble techniques based on Decision Trees have been widely favored due to their high prediction accuracy and stability. An ensemble method is a methodology that creates a single strong learner by combining multiple weak learners. Random Forest, a representative Bagging algorithm, effectively prevents overfitting by training numerous decision trees independently and then aggregating their results [11]. Boosting-based algorithms like XGBoost and LightGBM are known to provide top-tier performance in the current prediction field by sequentially training models where each new model corrects the errors (residuals) of the previous one.

The author's previous research [12] predicted building energy consumption using Random Forest, XGBoost, LightGBM, and Stacking Ensemble, demonstrating the superiority of the Stacking model. However, this study is differentiated by dealing with national grid demand rather than individual buildings, which involves a much larger scale and complexity of data, including macroscopic system operation elements like inter-country electricity trading and synchronization of large-scale power sources. Furthermore, while many existing studies stop at presenting model prediction performance, this study focuses on providing practical insights for system operators by enhancing the reliability of the prediction results through an in-depth interpretation of the model's 'judgment basis' via SHAP analysis.

Ⅲ. Research Methods

3.1 Data Preparation

This study used a public dataset provided by a UK power system operation data analysis platform [14]. This dataset contains 279,255 records of UK electricity demand and related information at 30 minute intervals from January 1, 2009 to December 5, 2024. The main variables are as follows:

• settlement_date: The date the data was recorded (used as a basis for feature engineering).

• settlement_period: The period dividing the day into 30-minute intervals (1-48).

• tsd: The power demand of the transmission system (MW). This is the prediction target (target variable) of this study. It is a critical metric from an actual grid operation perspective, calculated by adding power plant's own consumption, pumped storage consumption, and exports through inter-country power grids to the national demand (nd).

• embedded_wind_generation: The amount of electricity generated from small-scale wind power plants (MW).

• embedded_solar_generation: The amount of electricity generated from small-scale solar power plants (MW).

• is_holiday: Indicates whether the date is a public holiday (0: Weekday, 1: Holiday).

3.2 Feature Engineering

To enhance the model's learning performance, data cleaning and feature engineering were performed on the raw data.

1. Data Cleaning (Handling Missing Values): Some missing values in the dataset can cause errors in model training. In this study, missing values were uniformly replaced with 0. This approach was considered reasonable, as the missing values mostly appeared in specific generation-related fields (e.g., ifa2_flow) from the early days before data recording had fully begun.

2. Derived Variable Creation: Date and time information contains crucial periodic patterns for power demand forecasting. Therefore, the following time-related derived variables were generated from the settlement_date variable to enable the model to capture temporal patterns:

• year: Year information

• month: Month information

• day: Day information

• weekday: Day of the week information (0: Monday, 6: Sunday)

3. Final Feature Selection: A total of 8 variables (settlement_period, embedded_wind_generation, embedded_solar_generation, year, month, day, weekday, is_holiday) were used as input features for model training, with tsd set as the prediction target.

4. Correlation and Multicollinearity Analysis: A heatmap analysis of the linear relationships between variables showed that the target tsd had a very high positive correlation (0.99+) with nd (national demand) and england_wales_demand. This implies these variables contain almost identical information. Therefore, to prevent multicollinearity, nd and england_wales_demand were excluded from the input features. Meanwhile, the year variable showed a negative correlation of -0.36 with tsd, reflecting a long-term trend of decreasing power demand, possibly due to energy efficiency improvements. <Fig. 1> shows the Pearson correlation heatmap between key variables. The Variance Inflation Factor (VIF), a metric that measures how much an independent variable is explained by other independent variables, was calculated for the 8 selected input features. The VIF values for all features were in the 1.0-1.3 range, significantly lower than the general threshold of 10. This indicates that there are no serious multicollinearity problems among the selected features, and all can be used independently for model training.

DGTSA8_2025_v21n4_27_4_f0001.png 이미지

<Fig. 1> Pearson correlation heatmap between key variables

3.3 Model Generation

In this study, 3 individual machine learning models and 1 ensemble model were used to predict power demand and compare their performance.

1. Random Forest (RF): An ensemble algorithm based on Bagging (Bootstrap Aggregating). Bagging involves creating multiple subsets (bootstrap samples) from the original training data with replacement and training an independent decision tree model on each subset. RF adds 'feature randomness' by considering only a random subset of features when finding the best split at each node. These two types of randomness reduce the correlation between individual trees, improving the model's generalization capability and effectively preventing overfitting.

2. XGBoost (Extreme Gradient Boosting): A model that highly optimizes the Gradient Boosting algorithm from the perspectives of parallel processing and regularization. Gradient Boosting is a sequential learning method where the next model learns from the prediction errors (residuals) of the previous model to progressively reduce errors. XGBoost adds L1 (Lasso) and L2 (Ridge) regularization terms to the loss function to control model complexity and prevent overfitting. It also supports parallel processing, which enables fast training speeds and high prediction accuracy even on large datasets.

3. LightGBM (Light Gradient Boosting Machine): A gradient boosting framework that offers high performance similar to XGBoost but focuses on improving training speed on large datasets. Its key features are a 'Leaf-wise Tree Growth' method, which creates an optimal tree faster and more efficiently by focusing on splitting the leaf nodes with the largest loss change. It also enhances training speed through GOSS (Gradient-based One-Side Sampling) and EFB (Exclusive Feature Bundling) techniques.

4. Stacking Ensemble: An advanced, 2-stage ensemble technique that combines several different types of models to maximize predictive performance.

• Base Models (Stage 1): This study uses Random Forest, XGBoost, and LightGBM as the base models. These models are trained on the original training data and generate predictions.

• Meta Model (Stage 2): Another model, the meta-model, is trained using the predictions generated by the base models in Stage 1 as new input features to make the final prediction. This study uses Linear Regression as the meta-model to stably combine the predictions of the powerful Stage 1 models and minimize the risk of overfitting.

3.4 Hyperparameter Tuning

The performance of a machine learning model heavily depends on its internally set hyperparameters. In this study, the GridSearchCV technique was used to draw out the maximum potential performance of each model. GridSearchCV systematically searches for the optimal combination by creating a grid of user-defined hyperparameter values and performing cross-validation for all possible combinations in that grid. The key optimal hyperparameters for each model, derived through cross-validation, are shown in <Table 1>.

<Table 1> Optimal Hyperparameters for Each Model

DGTSA8_2025_v21n4_27_5_t0001.png 이미지

Instead of separate hyperparameter tuning, the Stacking Ensemble model used the 3 individual models with their optimized hyperparameters (from the table above) as its Stage 1 base models.

Ⅳ. Performance Evaluation

4.1 Evaluation Metrics and Experimental Results

To quantitatively evaluate the predictive performance of the models, three metrics widely used in regression model evaluation were employed.

1. Coefficient of Determination (R2 score): Has a value between 0 and 1, indicating how well the model explains the variance of the actual values. A value closer to 1 signifies a perfect prediction. It is calculated by Equation (1).

\(\begin{align}R^{2}=1-\frac{\sum_{i=1}^{n}\left(y_{i}-\hat{y_{i}}\right)^{2}}{\sum_{i=1}^{n}\left(y_{i}-\bar{y}\right)^{2}}\end{align}\)       (1)

Here, yi is the actual value, ŷiis the predicted \(\begin{align}\bar{y}\end{align}\)value, is the mean of the actual values, and n is the number of data points.

2. Root Mean Square Error (RMSE): The square root of the average of the squared differences (errors) between actual and predicted values. It penalizes large errors more heavily due to squaring. A smaller value indicates better performance. It is calculated by Equation (2), and its unit is MW, the same as the target variable.

\(\begin{align}R M S E=\sqrt{\frac{1}{n} \sum_{i=1}^{n}\left(y_{i}-\hat{y_{1}}\right)^{2}}\end{align}\)       (2)

3. Mean Absolute Error (MAE): The average of the absolute differences between actual and predicted values. Unlike RMSE, it is less sensitive to outliers and allows for an intuitive interpretation of the average error magnitude. A smaller MAE indicates a better model, as shown in Equation (3).

\(\begin{align}M A E=\frac{1}{n} \sum_{i=1}^{n}\left|y_{i}-\hat{y_{i}}\right|\end{align}\)       (3)

The performance evaluation results for each model on the test dataset are shown in <Table 2>. The evaluation results indicate that all models achieved high prediction accuracy, with R2 scores above 0.98. Among the individual models, XGBoost demonstrated the best performance with an R2 of 0.9923 and an RMSE of 764.55 MW. Random Forest and LightGBM also showed respectable performance, but their error values were slightly higher compared to XGBoost on this test set.

<Table 2> Predictive Performance Comparison by Models

DGTSA8_2025_v21n4_27_7_t0001.png 이미지

The most noteworthy result is that the Stacking Ensemble model achieved the best performance across all evaluation metrics, with an R2 score of 0.9926, RMSE of 749.87 MW, and MAE of 471.56 MW, surpassing all individual models. This can be interpreted as the meta-model (Linear Regression) effectively compensating for the bias or errors of any single model and enhancing the prediction's robustness and generalization performance by comprehensively considering the prediction results from the RF, XGBoost, and LightGBM models, which all learn the data in different ways.

4.2 Feature Importance Analysis via SHAP

In this study, the XAI technique SHAP was applied to the LightGBM model to interpret the model's prediction results and identify key features. SHAP quantitatively measures how much each feature contributed to a specific prediction based on the game-theory-based Shapley Value.

<Fig. 2> shows the feature importance analyzed by SHAP. As a result of averaging the absolute values of each feature's impact on the model's prediction, settlement_period was found to be the most important feature for power demand forecasting. This signifies that the specific time of day (e.g., commute times, evening peak) has a decisive impact on power consumption. Following this, month, year, weekday, and embedded_solar_generation were identified as the next most important features in descending order. <Fig. 3> shows not only feature importance but also the direction (positive/negative) and magnitude of each feature's impact on the prediction. The specific meanings are as follows:

DGTSA8_2025_v21n4_27_7_f0001.png 이미지

<Fig. 2> SHAP Feature Importance: Average impact of features on prediction

DGTSA8_2025_v21n4_27_7_f0002.png 이미지

<Fig. 3> SHAP Summary: Distribution of prediction impact by feature value

1. settlement_period: Points with high feature values (red, later times) are distributed in the positive SHAP value area (increasing demand), while points with low values (blue, earlier times) are in the negative area (decreasing demand). This perfectly matches the daily pattern where power demand peaks in the afternoon and evening.

2. month: Cases with low (blue, Jan-Feb) or high (red, Nov-Dec) feature values show positive SHAP values (increasing demand), while intermediate values (spring, autumn) show negative SHAP values (decreasing demand). This indicates the model accurately learned the seasonal pattern of increased demand during winter (due to heating) and decreased demand in milder seasons.

3. year: Points with high feature values (red, recent years) are predominantly in the negative SHAP value area. This shows a trend of the predicted power demand decreasing as the year increases, confirming that the model accurately reflects the long-term demand reduction trend (due to energy efficiency improvements, etc.) identified in the correlation analysis.

4. weekday: Points with low feature values (blue, Monday=0) are in the positive SHAP value area (increasing demand), while those with high values (red, Sunday=6) are concentrated in the negative area (decreasing demand). This demonstrates a strong weekly pattern where demand is high on weekdays and low on weekends.

5. embedded_wind_generation/embedded_solar_generation: For both features, higher values (red, more generation) are distributed in the negative SHAP value area. This means that as small-scale wind/solar generation increases, the transmission system demand (tsd) that needs to be supplied centrally decreases, clearly explaining the impact of renewable energy supply on overall demand.

This SHAP analysis allows us to verify that the model is making rational judgments consistent with real-world power system operating principles, rather than just confirming the model's performance.

4.3 Actual vs. Predicted Trend Analysis

To visually confirm how well the models follow the actual power demand trends, we compared the predicted values (blue crosses) and actual values (red circles) for each model using the 2024 test dataset. In <Fig. 3>, the X-axis represents the data index sorted by the actual value (in ascending order), and the Y-axis represents the power demand (MW). The predictions for Random Forest and LightGBM follow the general trend of the actual values, but their variance is somewhat large. There is a tendency for relatively larger errors at the extreme low and high ends of power demand. XGBoost shows its predictions are much more tightly clustered around the actual value line compared to Random Forest or LightGBM, visually demonstrating its lower error. This aligns with the quantitative results in <Table 2>. Stacking Ensemble demonstrates the best performance. The red crosses (predicted) almost perfectly cover the blue circles (actual) line, showing that the prediction error is very small and consistent across the entire range, from low to high demand. This is a result of effectively compensating for the prediction biases or errors of individual models, clearly supporting the superiority of the Stacking Ensemble model.

DGTSA8_2025_v21n4_27_8_f0001.png 이미지

<Fig. 3> Actual vs. Predicted Trend Analysis for Each Model

Ⅴ. Conclusion

This study developed high-performance models for forecasting UK electricity demand using Random Forest, XGBoost, LightGBM, and Stacking Ensemble machine learning models, and identified key influential features using SHAP analysis. The research found that the Stacking Ensemble model, which combines the strengths of individual models, achieved the highest prediction accuracy with an R2 score of 0.9926. This demonstrates that ensemble techniques are highly effective for predicting complex and volatile power demand. Furthermore, SHAP analysis confirmed that settlement_period, month, and year are the most critical features for prediction. It also verified that these features influence the model's predictions in a way that aligns with real-world power system principles (e.g., evening peak demand, seasonal heating/cooling needs, long-term efficiency gains).

This study is significant in that it empirically demonstrated the superiority of a high-performance Stacking Ensemble model and enhanced the reliability and interpretability of ML-based forecasting research by transparently presenting the model's predictive basis through XAI techniques. It also suggests that the developed model and key factor analysis can be utilized as a data-driven tool to support efficient operational planning and rational decision-making by power system operators.

References

  1. M. Al-Hamad, I. S. Qamber, "A comprehensive review of electrical power demand forecasting," Energy Reports, Vol. 7, 2021, pp. 3413-3432.
  2. T. Hong, P. Pinson, S. Fan, H. Zareipour, A. Troccoli, R. J. Hyndman, "Probabilistic energy forecasting: Global Energy Forecasting Competition 2014 and beyond," International Journal of Forecasting, Vol. 32, No. 3, 2016, pp. 896-913. https://doi.org/10.1016/j.ijforecast.2016.02.001
  3. N. Amjady, F. Keynia, "A new neural network based feature selection strategy for electricity load forecasting," International Journal of Electrical Power & Energy Systems, Vol. 33, No. 3, 2011, pp. 434-444.
  4. L. Breiman, "Random Forests," Machine Learning, Vol. 45, No. 1, 2001, pp. 5–32. https://doi.org/10.1023/A:1010933404324
  5. T. Chen, C. Guestrin, "XGBoost: A Scalable Tree Boosting System," in Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, New York, NY, USA, Aug. 2016, pp. 785–794.
  6. G. Ke, Q. Meng, T. Finley, T. Wang, W. Chen, W. Ma, T. Y. Liu, "LightGBM: A highly efficient gradient boosting decision tree," Advances in Neural Information Processing Systems, Vol. 30, 2017, pp. 3146-3154.
  7. J. Brownlee, "Ensemble Learning Algorithms With Python: Make Better Predictions with Bagging, Boosting, and Stacking," Machine Learning Mastery, 2021.
  8. S. M. Lundberg, S. I. Lee, "A Unified Approach to Interpreting Model Predictions," Advances in Neural Information Processing Systems, Vol. 30, 2017.
  9. J. W. Taylor, P. E. McSharry, "Short-term load forecasting methods: An evaluation based on European data," IEEE Transactions on Power Systems, Vol. 22, No. 4, 2007, pp. 2213-2219. https://doi.org/10.1109/TPWRS.2007.907583
  10. L. Hernandez, C. Baladron, J. M. Aguiar, B. Carro, A. Sanchez-Esguevillas, J. Lloret, "A multi-agent system architecture for smart grid management and forecasting of energy demand in virtual power plants," IEEE Communications Magazine, Vol. 51. No. 1, 2013, pp. 106-113. https://doi.org/10.1109/MCOM.2013.6400446
  11. L. Breiman, "Random forests," Machine learning, Vol. 45, No. 1, 2001, pp. 5-32. https://doi.org/10.1023/A:1010933404324
  12. J. Cha, "Machine learning-based prediction of building energy consumption and influential factor analysis," Intelligent Information Convergence and Future Education, Vol. 4, No. 19, 2025, pp. 1-13. https://doi.org/10.59482/iicfe.2025.4.19.01
  13. Electricity consumption UK 2009-2024. https://www.kaggle.com/datasets/albertovidalrod/electricity-consumption-uk-20092022.