Electricity Demand and Price Forecasting Using LSTM for Smart Grid Operations
摘要
This work aims to analyze and forecast electricity demand and pricing at the city level using an aggregated dataset that integrates weather and energy data. To enhance data quality, a comprehensive data preprocessing pipeline is employed, which includes handling missing values through forward and backward filling techniques, detecting and addressing outliers using the Inter-Quantile Range (IQR) method, and removing columns with zero-sum null values. The ‘weather_features’ and ‘energy_dataset’ are merged via a left join, followed by feature engineering where additional temporal variables such as ‘hour’, ‘month’, and ‘weekday’ are generated. Categorical data for weather conditions and time-related variables are encoded using label encoding and binary encoding methods. Multiple machine learning models are deployed for predictive analysis, including Linear Regression, Random Forest, Gradient Boosting, and Long Short-Term Memory (LSTM) networks. After a comparative analysis of all these models with the actual data, the LSTM is the most effective for load prediction, with a Mean Squared Error (MSE) of 871,004.26 and an R-squared value of 0.96. LSTM outperformed other models for price prediction, achieving an MSE of 25.24 and an R-squared value of 0.87. The superior performance of LSTM highlights its ability to capture temporal patterns in time series data, making it the optimal model for energy demand and price forecasting. This work provides a reliable framework for electricity demand and price prediction by leveraging the relationship between weather patterns and energy consumption. The approach demonstrates strong potential for application in energy management systems, enabling more accurate forecasting and better decision-making in energy resource planning and pricing.