Household Energy Consumption Forecasting

Using LSTM and ARIMA Models: A

Comprehensive Analysis

Alex Bandlamudi

*Electronics and Communication, Lovely Professional University, Chaheru, Phagwara, 144411, Punjab, India.

Corresponding author(s). E-mail(s): alexbandlamudi14@gmail.com;

Abstract

Accurately forecasting residential energy consumption is essential for efficient energy management and optimization. This study aims to develop predictive models to forecast household energy consumption for the next 15 days (multi-step ahead forecasting) of a given month, based on the previous 15 days of data. Using minute-level data collected over 15 days from a residential setup with an ESP32 microcontroller and a PZEM-004T energy monitoring module, this study examines the capabilities of ARIMA and LSTM models in predicting future energy consumption. The data underwent extensive preprocessing, including normalization, differencing, and stationarity tests, to ensure suitability for modeling. The ARIMA model, configured with an order of (1, 2, 15), and the LSTM model, featuring four LSTM layers with varying dropout rates, were evaluated for their forecasting accuracy. The ARIMA model achieved a Root Mean Squared Error (RMSE) of 0.0217 and a Mean Squared Error (MSE) of 0.0009. Conversely, the LSTM model demonstrated superior performance with an RMSE of 0.0196, a test loss of 0.000851, and a lower Mean Absolute Error (MAE) of 0.015, compared to the ARIMA model’s MAE of 0.025. Additionally, the LSTM model achieved a more favorable Mean Absolute Percentage Error (MAPE) of 3.0%. These findings highlight the effectiveness of LSTM models in capturing complex temporal patterns and improving forecasting accuracy compared to traditional ARIMA models. This research provides valuable insights into advanced energy forecasting methodologies, laying the groundwork for future work in residential energy optimization. Article Highlights

• LSTM models outperform ARIMA in predicting household energy usage by capturing complex patterns.

• Minute-level data enhances the accuracy of short-term energy consumption forecasting.

• Real-time LSTM-based predictions could optimize energy management in smart

homes.

Keywords: Energy Consumption Prediction, LSTM, ARIMA,Time-Series Forecasting

1 Introduction

Forecasting energy usage is essential to contemporary energy management, enabling households to optimize energy use, reduce costs, and contribute to sustainable practices [1, 2]. As smart home technologies evolve, the ability to accurately predict energy consumption at a granular level becomes increasingly important. Traditional forecasting methods, such as the AutoRegressive Integrated Moving Average (ARIMA) statistical analysis model [3] are popular tools for time series analysis and prediction because of their simplicity and statistical rigor. However, these methods often struggle to capture the complex, non-linear patterns inherent in high-resolution energy consumption data.

With the advent of deep learning, new opportunities have emerged to improve forecasting accuracy. Long Short-Term Memory (LSTM) networks, a specialized form of recurrent neural networks (RNNs), have demonstrated significant potential in capturing long-range dependencies and complex temporal dynamics [4–7]. In this study, we leverage both ARIMA and LSTM models to predict household energy consumption using minute-level data collected over a 15-day period.

The data, obtained via an ESP32 microcontroller and a PZEM module, offers a high-resolution view of household energy usage, providing a rich dataset of around 21,600 samples for model training and evaluation. By training the models on 12 days of data and testing them on the remaining 3 days, we aim to assess the strengths and limitations of each approach in forecasting energy consumption for the next 15 days. This paper explores the predictive capabilities of these models and highlights the importance of data granularity in achieving accurate short-term energy forecasts.

In this study, I initially selected the statistical model called AutoRegressive Integrated Moving Average (ARIMA) as the benchmark for several reasons. First, ARIMA has a long-standing history of application in time-series forecasting, particularly in energy consumption, where it provides insights into trends and seasonality. Additionally, its simplicity makes it an excellent baseline statistical model against which more complex neural Networks, like LSTM, can be compared. However, it is also essential to recognize ARIMA’s limitations, especially its inability to capture complex, non-linear relationships inherent in high-resolution energy data. This limitation is particularly relevant when considering datasets with minute-level granularity. In my analysis, this recognized deficiency underscores the necessity of deploying more sophisticated models, such as LSTM, which can effectively learn from intricate patterns over time.

This study presents a novel approach to forecasting household energy consumption by predicting future energy usage for the next 15 days based on the preceding 15 days of data of a particular month, utilizing a novel dataset collected at minutelevel granularity via an ESP32 micro-controller and a PZEM module. Ultimately, this research underscores the significance of leveraging high-resolution data to enhance the accuracy and reliability of energy consumption forecasts, contributing to the evolving field of energy management. The findings of this study contribute to the growing body of research in energy forecasting [8, 9] and smart home technology, offering valuable insights for both researchers and practitioners aiming to enhance the efficiency of energy management systems.

In this paper, I present a structured analysis of minute-level energy consumption forecasting using ARIMA and LSTM models. The introduction provides an overview of the background and significance of energy management systems. Following this, Section 2 reviews the relevant literature and theoretical foundations that underpin my research. Section 3 outlines the methodology employed, detailing the data collection techniques, preprocessing steps, and specific modeling approaches utilized in this study. In Section 4, a comparative analysis of both forecasting models is conducted, focusing on their performance metrics and the implications of the findings. Finally, Section 5 concludes the paper by summarizing the key insights gained from my research and suggesting avenues for future exploration, thereby offering a comprehensive understanding of the methodologies, results, and their relevance to the field.

2 Related Work

Energy consumption forecasting has garnered significant attention in recent years, particularly due to the growing importance of energy management and sustainability. Various methods, ranging from traditional statistical models to advanced machine learning techniques, have been explored to predict energy usage patterns.

2.1 Traditional Time-Series Models

ARIMA is one of the most widely used statistical methods for time-series forecasting. It has been successfully applied in various domains, including energy consumption forecasting, due to its ability to model linear relationships and capture trends and seasonality. For instance, the authors of [10] utilized ARIMA to forecast electricity consumption and demonstrated its effectiveness in capturing temporal patterns. However, its limitations in handling non-linear dependencies and complex temporal dynamics have been acknowledged by several researchers.

2.2 Deep Learning Models

With the advent of machine learning, more sophisticated models like Artificial Neural Networks (ANNs) and Long Short-Term Memory (LSTM) networks have been introduced. Deep learning models, particularly LSTM networks, have shown promise in handling large-scale, high dimensional time-series data. These models are capable of capturing non-linear relationships and long-term dependencies in time-series data, making them particularly suitable for energy forecasting. For example, the authors of [11] employed an LSTM model to predict residential energy consumption and reported significant improvements in accuracy over traditional models. Similarly, as shown in [12], many researchers explored different approaches such as combining ARIMA and LSTM to leverage the strengths of both models, achieving enhanced predictive performance. The work of [13, 14] further emphasizes the role of LSTM in real-time energy monitoring systems, where precise and timely predictions are crucial for optimizing energy usage. Recent advancements in machine learning techniques have provided more granular insights into energy consumption patterns. For instance, some studies have used spectral clustering and the Temporal Fusion Transformers (TIME-TFT) architecture to break down building energy usage into subsequences, offering a more detailed understanding of the data [15]. In other work, feature selection methods have been applied in short-term photovoltaic (PV) power forecasting, ensuring that only the most relevant features contribute to model performance [16].While these approaches enhance forecasting accuracy, they often come with increased model complexity.

Despite advancements in energy forecasting, challenges remain in improving the accuracy and scalability of these models. This study contributes to the existing literature by conducting a comparative analysis of ARIMA and LSTM models on minute-level energy consumption data, a granularity often underexplored in previous research. By focusing on high-resolution data, this work aims to provide insights into the effectiveness of these models in capturing both short-term fluctuations and long-term trends in energy consumption.

3 Methodology

3.1 Data Collection

Energy consumption data was collected using an ESP32 microcontroller coupled with a PZEM module [17] and SD card module. The dataset consists of minute-level measurements of energy usage over a period of 15 days within a specific month. This high resolution data enable models to recognize short-term variations in energy usage, such as spikes due to high voltage appliances or dips during off-peak hours. Such insights are crucial for effective forecasting and energy management. While minute-level data has its advantages, using lower-frequency data (e.g., hourly or daily) may still achieve acceptable forecasting accuracy. Using lower-frequency data reduces the volume of data processed, leading to faster training times and lower memory requirements. This can be advantageous for real-time applications where resources are constrained. However, in this study, I proceeded with minute-level data due to its ability to capture the intricate dynamics of energy consumption patterns that may be lost with lower-frequency datasets.

3.1.1 Hardware Setup

• ESP32-WROOM-32: It is a high-performance microcontroller with integrated Wi-Fi and Bluetooth capabilities, ideal for IoT projects. Its dual-core processor and sufficient memory enable efficient data processing and transmission, allowing constant monitoring and logging of energy consumption data with minimal delay. Additionally, the ESP32’s minimal power usage is essential for extended operation in homes without adding substantial energy costs. This microcontroller served as the core of the data collection system, managing the acquisition and storage of energy data [18].

• PZEM-004T Energy Monitoring Module: The PZEM-004T module is specially designed to measure electrical characteristics like voltage, current, power, and energy. It offers precise real-time information, crucial for accurate analysis of energy consumption. Its ability to work with microcontrollers such as the ESP32 and its simple integration through UART communication, makes it a perfect option for this research. It was connected to the main power line entering the house, allowing it to capture comprehensive data on overall energy usage.

• SD Card Module: The ESP32 was interfaced with an SD card module to enable local storage of the collected data. A high-capacity SD card was used to store the minute-level energy consumption readings over the 15-day period.

3.1.2 Data Logging and Storage

The ESP32-WROOM-32 microcontroller continuously monitored energy consumption using the PZEM-004T module. Every minute, a new data point was recorded, capturing the energy consumed within that specific time interval. The data was structured into three main columns: energy (KWh), time, and date. The time and date columns were combined into a single datetime column, which was used as the index for the dataset. This datetime column ensured that the data was in a proper time-series format, allowing the models to capture temporal dependencies. This format provided a clear and organized dataset, where each row represented the energy consumption at a specific minute on a particular day.

I did not create additional seasonal parameters (e.g., hour of the day, day of the week), as the models were trained directly on the datetime column and energy (KWh). However, the datetime format allowed the models, particularly LSTM, to effectively learn temporal patterns over time without explicitly separating out seasonal features.

The collected data was stored locally on an SD card connected to the ESP32 [19]. The SD card module was programmed to store the data in CSV format, ensuring that it could be easily retrieved and analyzed. This approach allowed for uninterrupted data logging, even in the absence of a network connection, and provided a reliable backup of the recorded energy consumption data. The complete dataset is made available in the Data Availability Section.

3.2 Data Preprocessing(ARIMA)

The raw minute-level data was compiled into a single dataset, with each entry representing the energy consumption at a specific minute. The date and time columns were combined into a single datetime column. This was essential to create a proper time-series index for the dataset. The datetime column was then set as the index of the DataFrame, which enabled efficient time-based slicing and plotting. An initial plot of energy consumption over time was created to visually inspect the data as shown in Figure 1. This step is crucial for understanding any visible trends, seasonality, or anomalies in the dataset.

3.2.1 Augmented Dickey-Fuller (ADF) Test

Since ARIMA models are designed for stationary data, testing and potentially transforming the energy consumption data is an essential preprocessing step. The stationarity of the time series data is a critical aspect to ensure that the ARIMA model can produce reliable predictions. To assess the stationarity of the energy consumption time series data, we performed the Augmented Dickey-Fuller (ADF) test [20]. The ADF test is used to determine whether a time-series has a unit root, which indicates non-stationarity.The ADF test is an extension of the Dickey-Fuller test that includes lagged differences of the time series to account for autocorrelation. The test equation

Fig. 1: Initial plot of energy consumption over time.

can be expressed as:

Δy_{t} = α + βt + γy_{t−1} + δ ∑_{i=1}^{p} Δy_{t−i} + ϵ_{t}  (1)

where:

• Δ is the difference operator,

• y_{t} is the time series, • α is a constant,

• βt is a trend term,

• γy_{t−1} represents the lagged level of the time series,

• δ ∑_{i=1}^{p} Δy_{t−i} includes the lagged differences,

• ϵ_{t} is the error term.

The test statistic for the ADF test is derived from the coefficient γ of y_{t−i}. Hence we can compute the ADF test statistic using the formula:

ADF Statistic = \frac{γ̂}{SE(γ̂)}  (2)

Where γ̂ is the estimated coefficient of y_{t−1}, and SE(γ̂) is the standard error of γ̂. The test statistic is used to assess the null hypothesis that γ = 0, indicating the presence of a unit root and thus non-stationarity. If the test statistic is less than the critical value from the Dickey-Fuller table, the null hypothesis can be rejected, suggesting that the time series is stationary. If the p-value is less than the significance level, the null hypothesis is rejected, suggesting that the time series is stationary. The results of the Augmented Dickey-Fuller (ADF) test performed on the energy consumption time series data are presented below:

• ADF Statistic: 0.9178

• p-value: 0.9933

In this case, the high p-value and the positive ADF statistic indicate that the null hypothesis is not rejected. This suggests that the energy consumption data is non-stationary. As a result, further preprocessing steps, such as differencing will be necessary to achieve stationary.

3.2.2 Differencing

Differencing is a technique used to transform a non-stationary time series into a stationary one, so that the time series has constant mean, variance, and autocorrelation structure overtime [21]. The first-order difference of a time series y_{t} is defined as:

Δy_{t} = y_{t} − y_{t−1}  (3)

where Δy_{t} represents the first difference at time t, y_{t} is the value of the time series at time t, and y_{t−1} is the value of the time series at the previous time point t − 1. After the First-order differencing the ADF statistic of -6.005518849824479 with a p-value of 1.6190487967598555e-07 indicates that the time series has become stationary. The extremely small p-value suggests that we can reject the null hypothesis of a unit root at a reasonable confidence level, indicating that the series is likely stationary after this differencing.

But, Second-order differencing was performed to achieve stationarity with greater confidence, The Second-order difference of a time series y_{t} is defined as:

Δ^{2}y_{t} = Δy_{t} − Δy_{t−1}  (4)

where Δ^{2}y_{t} is the second difference at time t, Δy_{t} is the first difference at time t, and Δy_{t−1} is the first difference at the previous time point t − 1. The ADF statistic of -29.412180384964813 with a p-value of 0.0 is even more extreme, further reinforcing that the time series is stationary. The p-value of 0.0 (essentially indicating a value very close to zero) confirms that we can reject the null hypothesis with even greater confidence.

The transition from first to second differencing is often undertaken to address persistent non-stationarity in the data. In our case, both differencing approaches indicate that the series is stationary. However, the second-order differencing provides a stronger confirmation, showing that any remaining non-stationarity has been adequately addressed. This step ensures that the data is properly preprocessed for modeling, reducing the risk of violating stationarity assumptions in subsequent analyses. The plots of First and Second order differencing are shown in Figure 2.

Fig. 2: plot of Differenced energy consumption over time.

3.3 Data Preprocessing(LSTM)

As mentioned earlier in section 3.2 the date and time column were combined into a single datetime column. There are no missing values or NaN values present in the dataset. After that, Normalization is performed to scale the features to a range that the model can handle effectively. The energy consumption values were normalized using Min-Max scaling, which scales the data to a range between 0 and 1 [22]. The normalization was performed using the following formula:

x_{normalized} = \frac{x − min(x)}{max(x) − min(x)}  (5)

Where: x is the original energy consumption value, min(x) and max(x) are the minimum and maximum values in the dataset. Before normalization, the energy consumption values ranged from a minimum of 0.002 to a maximum of 238.4908. This normalization process ensures that the LSTM model can learn more effectively without being skewed by the original scale of the data. The Table 1 shows the statistics of energy consumption and the table 2 shows the statistics of normalized energy consumption.

Table 1: Descriptive Statistics of Energy Consumption Data

Statistic  Value
Count  21,600
Mean  87.419164
Standard Deviation  71.189139
Minimum Value  0.002
25th Percentile  27.177307
50th Percentile (Median)  66.464524
75th Percentile  161.547067
Maximum Value  238.490833

Min-Max scaling was applied to the energy consumption data to bring all values into a consistent range between 0 and 1. This normalization was crucial for stable training in the LSTM model, as it prevents large gradients from skewing the learning

Table 2: Descriptive Statistics of Normalized Energy Consumption Data

Statistic  Value
Count  21600.000000
Mean  0.366546
Standard Deviation  0.298501
Minimum Value  0.000000
25th Percentile  0.113948
50th Percentile (Median)  0.278682
75th Percentile  0.677370
Maximum Value  1.000000

process, which could lead to issues such as exploding or vanishing gradients. The choice of Min-Max scaling is particularly effective for time-series data like energy consumption, where the values are bounded within a certain range. An alternative preprocessing method such as log transformation, could have been considered. Log transformations are often applied to handle skewed data distributions by compressing the range of large values and expanding the range of small values. Mathematically, a log transformation is expressed as:

x_{log-transformed} = log(x + 1)

Where x is the original energy consumption value, and adding one ensures that zero values do not become undefined during the transformation. This method would reduce the impact of extreme values, making the data more symmetric and potentially improving the model’s ability to generalize. However, log transformations may introduce challenges when dealing with small energy values or zeros, which could skew the model ability to capture minute-level variations in consumption. Furthermore, while log transformations work well for linear models or models with skewed distributions, LSTM models are known to handle a wide range of data as long as they are scaled appropriately. In our case, Min-Max scaling provided an effective way to prepare the data for sequential modeling, without introducing complexities related to very small or zero values.

3.4 Model Selection and Specification

3.4.1 ARIMA Model

After the preprocessing, Diagnostic tools like the Autocorrelation Function (ACF) and Partial Autocorrelation Function (PACF) plots are utilized to determine the appropriate parameters, such as P and Q. These tools helps us to find the relation between the timeseries and its lagged values [23].

Autocorrelation Function (ACF) Analysis: The ACF plot helps in determining the order of the Moving Average (MA) component of the ARIMA model. It helps in identifying the extent of autocorrelation and the pattern of lagged relationships. The autocorrelation function (ACF) at lag k is defined as:

ACF(k) = \frac{Cov(y_{t}, y_{t−k})}{Var(y_{t})}  (6)

Where Cov(y_{t}, y_{t−k}) is the covariance between y_{t} and y_{t−k}, and Var(y_{t}) is the variance of the series. Figure 3 shows a sharp cut-off after the first lag suggesting that the series is stationary and that there’s no significant autocorrelation between observations more than one time period apart. The absence of significant spikes or patterns beyond the first lag indicates that the first difference has adequately captured the dependence structure in the data. The ACF plot supports the conclusion from the ADF test. The sharp cut-off at lag 1 suggests that an AR(1) model might be appropriate for forecasting. However, it’s also important to consider the PACF plot to make a more definitive determination.

Fig. 3: plot of ACF-Differenced energy consumption.

Partial Autocorrelation Function (PACF) Analysis: The PACF plot helps in determining the order of the AutoRegressive (AR) component of the ARIMA model. It reveals the direct relationship between the series and its lags, excluding the effects of intermediate lags. The partial autocorrelation function at lag k is defined as:

PACF(k) = Corr (y_{t}, y_{t−k} | y_{t−1}, …, y_{t−k+1})  (7)

where Corr(·) denotes the partial correlation, accounting for the influence of all intermediate lags. Figure 4 shows that the PACF plot shows a significant spike at lag 1, indicating a strong correlation between the current value and the previous value. After the first lag, the PACF values quickly decay to zero. This suggests that the correlation between the current value and values more than one lag behind is negligible.

Fig. 4: plot of PACF-Differenced energy consumption.

Based on the ACF and PACF analysis, the ARIMA model was specified with the following order, p (AR term): 1, d (Differencing order): 2, q (MA term): 15. The second-order differenced data was used as the input to the ARIMA model. The training process involved fitting the model to the data, which included estimating the parameters for the AR (p), differencing (d), and MA (q) components [24].

3.4.2 LSTM(Long short-term memory) Model

The LSTM model consists of four LSTM layers followed by a Dense output layer. This architecture is designed to handle sequential data and make predictions based on the past 60 time steps.

• Input Layer: The input to the model consists of a sequence of 60 time steps with one feature. Mathematically, if x_{t} represents the input at time step t, then the input shape is (60, 1).

• LSTM Layers: Each LSTM layer is defined by the following equations [25]:

– The forget gate is defined by the following equation:

f_{t} = σ (W_{f} · [h_{t−1}, x_{t}] + b_{f})  (8)

– The input gate is defined by the following equations:

i_{t} = σ (W_{i} · [h_{t−1}, x_{t}] + b_{i})  (9)
C̃_{t} = tanh (W_{C} · [h_{t−1}, x_{t}] + b_{C})  (10)

– The cell state update is defined by the following equation:

C_{t} = f_{t} · C_{t−1} + i_{t} · C̃_{t}  (11)

– The output gate is defined by the following equations:

o_{t} = σ (W_{o} · [h_{t−1}, x_{t}] + b_{o})  (12)
h_{t} = o_{t} · tanh(C_{t})  (13)

Where:

– σ is the sigmoid activation function,

– tanh is the hyperbolic tangent activation function,

– W_{f}, W_{i}, W_{C}, W_{o} are the weight matrices for the forget, input, cell, and output gates, respectively,

– b_{f}, b_{i}, b_{C}, b_{o} are the biases for each gate.

Fig. 5: Sequential LSTM Network.

The LSTM model network shown in Figure 5 consists of four layers, each with 50 units. The first two LSTM layers are configured to return sequences, enabling the propagation of the full sequence to subsequent layers. Both of these layers include L2 regularization with a coefficient of 0.0001 to prevent overfitting, and dropout rate of 0.0001 is applied. The third LSTM layer also consists of 50 units and applies a dropout rate of 0.01 but does not include regularization. The fourth LSTM layer, which outputs the final sequence without returning sequences, has a dropout rate of 0.1. This architecture is designed to capture complex temporal dependencies while mitigating overfitting through regularization and dropout techniques.

• Dense Output Layer: The Dense layer takes the final output from the last LSTM layer and transforms it into the desired output format. It produces a single scalar value (the predicted energy consumption) for each input sequence. The output of the Dense layer, y_{t}, is calculated using a linear transformation of the LSTM layer’s output, h_{t}. Mathematically:

y_{t} = W_{out} · h_{t} + b_{out}  (14)

Where:

– h_{t}: The output vector from the last LSTM layer. It has dimensions corresponding to the number of units in the final LSTM layer, which in your model is 50.

– W_{out}: The weight matrix for the Dense layer. This matrix transforms the LSTM output vector into the final prediction. Its dimensions are (50, 1), where 50 is the number of units in the last LSTM layer and 1 is the number of output units.

– b_{out}: The bias vector for the Dense layer. This bias is added to the weighted sum of the LSTM outputs. Its dimension is (1), corresponding to the single output unit.

The LSTM model is compiled with the Adam optimizer and Mean Squared Error loss function. It is trained for 10 epochs with a batch size of 64, and 10% of the data is used for validation.

• Hyper parameter Optimization: Hyper parameter optimization is crucial for enhancing the performance of the LSTM model used in forecasting household energy consumption. To enhance the performance of the LSTM model and avoid over-fitting, a thorough hyper parameter optimization was conducted. The above mentioned LSTM model was chosen after tuning key parameters such as LSTM units, Dropout rate, Batch size, Learning rate, using randomized grid search technique. This approach allowed for the systematic evaluation of various configurations. The LSTM units are tested in a range from 30 to 100 in increments of 10. The Dropout rates are examined from 0.0 to 0.3 in increments of 0.01. The evaluated Batch sizes are 32,64,128. The Learning rates are assessed in a range from 0.0001 to 0.01 in multiplicative factors. From the Table 3 the optimal hyper parameter

Table 3: Configuration and Performance of LSTM Models

Hyperparameter Configuration LSTM Units Dropout Rate Batch Size Learning Rate RMSE MAPE%
Configuration 1  30  0.05  64  0.001  0.0231  3.5
Configuration 2  50  0.01  64  0.0001  0.0196  3.0
Configuration 3  70  0.15  128  0.0005  0.0212  3.6
Configuration 4  90  0.2  32  0.001  0.0204  3.1
Configuration 5  100  0.25  64  0.002  0.0208  3.4

configuration identified was configuration 2, yielding the best RMSE and MAPE. In order to balance the over-fitting control and model complexity, varying dropout rates were applied across all the four layers. The first and second layers are tasked with learning the foundational temporal patterns in the sequence data.The smaller dropout rates(0.0001) for the first two layers as shown in figure 5 keeps the most of the information intact, ensuring that the foundational patterns aren’t disrupted too early in the network. As we move deeper into the network, the third layer starts handling more refined and abstract representations. By this point, the model has already captured some general temporal dependencies, so we can afford to apply a higher dropout rate (0.01). This rate helps prevent overfitting by forcing the model to learn more robust patterns instead of relying on specific neuron connections. The final LSTM layer is the most abstract layer, which synthesizes all the temporal patterns learned in the previous layers and feeds them into the output layer. A significantly higher dropout rate (0.1) is applied here to ensure that the model generalizes well. This is the most critical point for preventing over-fitting, as the final layer is prone to over-adaptation to the training data. The higher dropout rate helps ensure that the network does not rely too much on specific neuron activation and produces more generalized patterns.

4 Results and Discussion

4.1 ARIMA Model Performance

After training/fitting the ARIMA model with the specified order (1, 2, 15) on the energy consumption data, the model’s performance was evaluated on the test dataset (3 days of minute-level data).

Root Mean Squared Error (RMSE): It is a standard metric used to measure the accuracy of predictions made by a model. It provides a single measure of how far the predictions deviate from the actual values, with a lower RMSE indicating better model performance. Mathematically, RMSE is defined as:

RMSE = \sqrt{\frac{1}{n} ∑_{i=1}^{n} (y_{i} − ŷ_{i})^{2}}  (15)

Where y_{i} represents the actual observed values of the energy consumption, ŷ_{i} represents the predicted values produced by the ARIMA model, and n is the number of observations in the test dataset.

In case of ARIMA model, the RMSE was calculated to be 0.0217. This value signifies that, on average, the predictions made by the model deviate from the actual observed energy consumption values by approximately 0.0217 units (in the same units as the energy data, e.g., kWh). The small RMSE indicates that the model’s predictions closely match the actual data, suggesting high accuracy in capturing the minute-to-minute variations in energy consumption.

Residual Analysis: The residuals plot shows a random scatter around the zero line, indicating that the model is capturing the main patterns in the data. There is no clear trend or pattern, suggesting that the model is not systematically underestimating or overestimating the values. The variance of the residuals appears to be relatively constant, indicating homoscedasticity. While there are a few outliers, they do not significantly affect the overall pattern. Therefore, the residuals plot shown in the Figure 6 suggests that the ARIMA model is a reasonable fit for the data.

Fig. 6: Residuals plot.

To visually assess the accuracy of the ARIMA model, the model’s forecast are plotted against the actual energy consumption data from the test set. The plot compares the predicted values (generated by the ARIMA model) to the observed values in the testing period as shown in Figure 7 and Figure 8

Fig. 7: ARIMA Forecast vs Testing Data.

Fig. 8: ARIMA Forecast vs Testing Data(Normal Scale).

This plot as shown in Figure 8 demonstrates how well the ARIMA model aligns with the actual energy consumption data over the 3-day testing period. A close alignment between the forecast and the observed data confirms the model’s accuracy and reliability, as indicated by the low RMSE and the residual analysis.

4.2 LSTM Model Performance

After training the LSTM model on the normalized energy consumption data, the model performance was evaluated on the test dataset(3 days of minute-level data). The test loss is key metric used for evaluating the performance of a model on unseen data, In this case, the test loss is computed using the Mean Squared Error (MSE), which is defined as: The Mean Squared Error (MSE) is defined as:

MSE = \frac{1}{N} ∑_{i=1}^{N} (ŷ_{i} − y_{i})^{2}  (16)

where N is the number of observations in the test dataset, ŷ_{i} represents the predicted value for the i-th observation, and y_{i} represents the actual value for the i-th observation. The MSE measures the average squared difference between the predicted and actual values.

The test loss value of 0.000851 is quite small, indicating minor squared differences between the predicted and actual values. This suggests that the model’s predictions are, on average, very close to the actual values in the test dataset. A low test loss is indicative of a model that generalizes well to new data, providing accurate predictions. The Figure 9 shows the comparison between actual and predicted values for both the training and testing datasets.

Fig. 9: Comparison of Actual vs. Predicted Values for Training and Testing Data.

• Training Data Plot (Top): This plot shows the actual versus predicted values for the training dataset. A close alignment of the predicted values with the actual values indicates good model performance on the training data.

• Testing Data Plot (Bottom): This plot displays the actual versus predicted values for the testing dataset. The model also performs well on the testing data, though the fit is not as tight as on the training data. This is expected, as models often perform slightly worse on unseen data with more seasonality changes.

In addition to RMSE and MSE, the model performance was evaluated using Mean Absolute Error (MAE) and Mean Absolute Percentage Error (MAPE). The MAE measures the average magnitude of the errors between the predicted and actual values without considering their direction. It gives a clear idea of how much error to expect from the model on average. The formula for MAE is as follows:

MAE = \frac{1}{n} ∑_{i=1}^{n} |y_{i} − ŷ_{i}|

where:

• y_{i} represents the actual observed values,

• ŷ_{i} represents the predicted values,

• n is the number of observations.

A lower MAE value indicates that the model’s predictions are, on average, close to the actual values. The MAPE is a percentage-based metric that expresses the magnitude of the error in relative terms. It provides a way to understand the model?s prediction error as a percentage of the actual values. The formula for MAPE is:

MAPE = \frac{1}{n} ∑_{i=1}^{n} (\frac{|y_{i} − ŷ_{i}|}{y_{i}}) × 100

where:

• y_{i} represents the actual observed values,

• ŷ_{i} represents the predicted values,

• n is the number of observations.

MAPE offers a clearer picture of how significant the errors are in proportion to the actual values. A lower MAPE value indicates better model performance in relative terms.

The two models are compared with accuracy metrics such as MAE, MSE, RMSE, MAPE. The MAPE expresses accuracy as a percentage. It is useful for understanding the error in relative terms. MAE measures the average magnitude of errors in a set of predictions, without considering their direction. It is a straightforward measure of prediction accuracy.

Table 4: Comparison of ARIMA and LSTM Model Metrics

Metric  ARIMA Model LSTM Model
Mean Absolute Error (MAE)  0.025  0.015
Mean Squared Error (MSE)  0.0009  0.000851
Root Mean Squared Error (RMSE)  0.0217  0.0196
Mean Absolute Percentage Error (MAPE)  5.0%  3.0%

The LSTM model outperforms the ARIMA model across all key metrics such as MAE, MSE, RMSE, and MAPE as shown in Table 4. The lower values in these metrics for the LSTM model indicate:

• Higher Accuracy: LSTM predictions are closer to actual values on average.

• Better Error Handling: LSTM manages both small and large deviations more effectively.

• More Reliable Forecasts: LSTM offers better relative accuracy in its predictions.

An RMSE of 0.0196 means that, on average, the LSTM model’s predictions deviate from the actual values by about 0.0196 kWh per time step(per minute).A 0.0196 kWh error translates to about 0.2% of daily energy consumption (considering a daily usage of 10 kWh). This level of accuracy is quite impressive, especially for energy management, where even small deviations can impact decisions on energy efficiency measures. A MAPE of 3% means that the LSTM model’s predictions are, on average, 3% off from the actual consumption values. A 3% error margin in energy forecasting is generally regarded as excellent in energy management contexts. For instance, if a household’s actual energy consumption is 10 kWh for a day, a 3% MAPE indicates that the forecast might vary by ±0.3 kWh (3% of 10 kWh).

Given that the LSTM model accurately predicted energy consumption for the 3day test period based on the preceding 12 days, it demonstrates a strong ability to capture and generalize temporal patterns in the data. This suggests that the model is well-suited for extending its predictive capabilities to forecast the energy consumption for the next 15 days based on the previous 15 days of data. The model demonstrated accuracy and robustness make it a reliable tool for predicting short-term residential energy usage, which is essential for efficient energy management and planning.

The LSTM model, beyond its ability to predict short-term energy consumption, also holds potential for real-time forecasting applications. Given that the model can handle minute-level data, it could be deployed in smart home systems where realtime prediction and continuous adaptation to new data are crucial. By retraining or fine-tuning the model periodically with the latest data, the model’s performance can be maintained or improved as energy consumption patterns evolve over time. This capability makes the LSTM model suitable for dynamic environments, where it is critical to adapt to changing energy usage trends. Future work should explore this real-time retraining process and how frequently the model should be updated during deployment.

4.3 Computational Cost and Scalability Analysis

In terms of real-time energy forecasting, the computational cost and scalability of predictive models are critical considerations. For this study, the ARIMA and LSTM models were both trained and tested on a server environment equipped with an NVIDIA RTX 3060 GPU Laptop to handle the computational load efficiently. This server-based deployment allowed for faster training and evaluation, particularly for the deep learning-based LSTM model, which requires substantial computational resources.

The ARIMA model, being a relatively simple statistical method, trained in about 5 minutes 27 seconds on the minute-level training data of 12 days, with minimal memory usage. This makes ARIMA highly efficient in terms of both computational time and memory, but with limitations in capturing non-linear relationships. Whereas the LSTM model required significantly more computational power. Training the LSTM model with approximately 21,600 data points (minute-level data over 12 days) took around 2 hours on the server, utilizing GPU acceleration by consuming around 4.7GB of memory. The model complexity due to its recurrent layers and large number of parameters results in a much higher memory and computation footprint compared to ARIMA. The increase in computational power will certainly raise the cost of deploying smart power meters. However, this increased cost is justified by the LSTM model’s ability to capture complex temporal patterns, as evidenced by its improved predictive accuracy.

When it comes to the scalability, if the LSTM model is deployed on the server, then the meter can be easily installed in almost all of the rural and urban households. This would be beneficial for the consumers to conserve and utilize the energy sufficiently. In the Future research, for real-time applications, deploying the LSTM model on devices such as Raspberry Pi would be a game changer in field of EDGE AI but it may introduce some additional challenges, including potential compromises in accuracy and an increase in the cost of the meter. In such scenarios only the upper middle class or above them could afford the AI powered smart meter.

4.4 Transfer Learning in Energy Forecasting

Using transfer learning could be a way to improve the scalability and generalization of the LSTM model in energy forecasting. Transfer learning enables adapting a model trained on one dataset to effectively work on a related, but different dataset. Transfer learning in household energy consumption involves utilizing a pre-trained model on energy data from one household or region and adjusting it to match the consumption patterns of a different household. This would decrease the requirement for extensive retraining on fresh data while still upholding high precision.

Differences in energy consumption among households can vary greatly based on factors such as household size, appliance usage, climate, and seasonal changes. Utilizing transfer learning enables a pre-trained LSTM model on a specific household’s data to be easily adjusted for use in various settings, enhancing the model’s ability to perform well across a variety of regions and residences. The success of this method in previous time-series forecasting tasks suggests it could offer a scalable solution for energy management systems in smart homes.

While the transfer learning is not implemented in this study, In the future, researchers could investigate transfer learning by first training models on extensive data from various homes and areas, and then adjusting them specifically for each household. This method would lessen the requirement for thorough data gathering and training duration while upholding model efficacy in various settings.

5 Conclusion

In this study, a statistical model (ARIMA) and a deep learning model (LSTM) were developed and compared for predicting minute-level energy consumption. The ARIMA model (1, 2, 15) effectively captured linear patterns in the time series data, yielding an RMSE of 0.0217. However, the LSTM model, which leveraged its ability to learn complex, non-linear temporal dependencies, outperformed ARIMA with an RMSE of 0.0196 and demonstrated superior accuracy across all evaluated metrics, including MAE and MAPE.

The LSTM model’s ability to handle sequential data with long-term dependencies along with its robustness to data irregularities, makes it an ideal choice for predicting energy consumption. The findings of this research underscore the importance of model selection based on the specific characteristics of the data and highlight the potential of deep learning techniques, such as LSTM, for more accurate time series forecasting in energy management applications. Future research may explore the integration of these large LSTM network in edge devices such as Raspberry pi, to bring the power of AI into every home. This integration would enable homeowners to easily assess, manage, and predict their future power requirements, ultimately conserving energy and using it more judiciously. Although this study focuses on the static evaluation of the LSTM model, its adaptability and potential for real-time retraining remain important areas for future exploration. Implementing real-time retraining mechanisms would enhance the model’s capability to adjust to new patterns in energy consumption, making it highly relevant for smart home systems where energy usage patterns shift frequently.

However, this study has limitations. First, the models were evaluated on a relatively small dataset collected over 15 days, which may not capture seasonal variations and long-term trends in energy consumption. Future research should aim to incorporate larger and more diverse datasets to validate the generalizability of the models. Additionally, while this study focused on static evaluations of the LSTM model, its adaptability and real-time retraining potential remain important areas for exploration. Implementing real-time retraining mechanisms would enhance the model’s capability to adjust to new patterns in energy consumption, making it highly relevant for smart home systems where energy usage patterns shift frequently. Furthermore, examining the interplay of external factors such as weather conditions and occupancy patterns could provide additional context for improving the models predictive accuracy.

This work contributes to the growing body of knowledge on the application of deep learning and statistical methods for energy forecasting in connection with IoT. It offers practical insights for the development of more accurate and reliable predictive models, which are essential for informed decision-making in the energy sector.

6 Data Availability

The Dataset is made available at : https://github.com/AlexBandlamudi/AI-Smart-Power-meter.git

References

[1] Rambabu, M., Ramakrishna, N., Polamarasetty, P.K.: Prediction and analysis of household energy consumption by machine learning algorithms in energy management. In: E3S Web of Conferences, vol. 350, p. 02002 (2022). EDP Sciences

[2] Gassar, A.A.A., Cha, S.H.: Energy prediction techniques for large-scale buildings towards a sustainable built environment: A review. Energy and Buildings 224, 110238 (2020)

[3] Mahia, F., Dey, A.R., Masud, M.A., Mahmud, M.S.: Forecasting electricity consumption using arima model. In: 2019 International Conference on Sustainable Technologies for Industry 4.0 (STI), pp. 1–6 (2019). IEEE

[4] Mahjoub, S., Chrifi-Alaoui, L., Marhic, B., Delahoche, L.: Predicting energy consumption using lstm, multi-layer gru and drop-gru neural networks. Sensors 22(11), 4062 (2022)

[5] Ullah, F.U.M., Ullah, A., Haq, I.U., Rho, S., Baik, S.W.: Short-term prediction of residential power energy consumption via cnn and multi-layer bi-directional lstm networks. IEEE Access 8, 123369–123380 (2019)

[6] Yan, K., Li, W., Ji, Z., Qi, M., Du, Y.: A hybrid lstm neural network for energy consumption forecasting of individual households. Ieee Access 7, 157633–157642 (2019)

[7] Mpawenimana, I., Pegatoquet, A., Roy, V., Rodriguez, L., Belleudy, C.: A comparative study of lstm and arima for energy load prediction with enhanced data preprocessing. In: 2020 IEEE Sensors Applications Symposium (SAS), pp. 1–6 (2020). IEEE

[8] Pierre, A.A., Akim, S.A., Semenyo, A.K., Babiga, B.: Peak electrical energy consumption prediction by arima, lstm, gru, arima-lstm and arima-gru approaches. Energies 16(12), 4739 (2023)

[9] Silva, D.G., Geller, M.T.B., Santos Moura, M.S., Moura Meneses, A.A.: Performance evaluation of lstm neural networks for consumption prediction. e-Prime-Advances in Electrical Engineering, Electronics and Energy 2, 100030 (2022)

[10] Elsaraiti, M., Ali, G., Musbah, H., Merabet, A., Little, T.: Time series analysis of electricity consumption forecasting using arima model. In: 2021 IEEE Green Technologies Conference (GreenTech), pp. 259–262 (2021). IEEE

[11] Wang, X., Meng, M.: A hybrid neural network and arima model for energy consumption forcasting. J. Comput. 7(5), 1184–1190 (2012)

[12] Elsaraiti, M., Merabet, A.: A comparative analysis of the arima and lstm predictive models and their effectiveness for predicting wind speed. Energies 14(20), 6782 (2021)

[13] Lu, C., Li, S., Lu, Z.: Building energy prediction using artificial neural networks: A literature survey. Energy and Buildings 262, 111718 (2022)

[14] Ediger, V.Ş., Akar, S.: Arima forecasting of primary energy demand by fuel in turkey. Energy policy 35(3), 1701–1708 (2007)

[15] Zheng, P., Zhou, H., Liu, J., Nakanishi, Y.: Interpretable building energy consumption forecasting using spectral clustering algorithm and temporal fusion transformers architecture. Applied Energy 349, 121607 (2023)

[16] Zhou, H., Zheng, P., Dong, J., Liu, J., Nakanishi, Y.: Interpretable feature selection and deep learning for short-term probabilistic pv power forecasting in buildings using local monitoring data. Applied Energy 376, 124271 (2024)

[17] Satria, H., Lubis, M.M.G., Putri, S.M.: Design of household electricity protection and monitoring automation with iot esp32. Andalasian International Journal of Applied Science, Engineering and Technology 2(3), 133–139 (2022)

[18] Abed, I.A., Naser, H.Y.: Esp32 microcontroller based smart power meter system design and implementation. Al-Rafidain Engineering Journal (AREJ) 25(2), 136– 143 (2020)

[19] Ivan Danu, T., Akhmad Ahfas, A.A., Jamaaluddin, J., et al.: Home surveillance monitoring with esp32-cam and sd card for data storage. Journal of Computer Networks, Architecture and High Performance Computing 6(1), 419–429 (2024)

[20] Xue, D.-m., Hua, Z.-q.: Arima based time series forecasting model. Recent Advances in Electrical & Electronic Engineering (Formerly Recent Patents on Electrical & Electronic Engineering) 9(2), 93–98 (2016)

[21] Solo, V.: The order of differencing in arima models. Journal of the American Statistical Association 79(388), 916–921 (1984)

[22] Yu, Y., Si, X., Hu, C., Zhang, J.: A review of recurrent neural networks: Lstm cells and network architectures. Neural computation 31(7), 1235–1270 (2019)

[23] Alfaki, M.M.A., Masih, S.B.: Modeling and forecasting by using time series arima models. International Journal of Engineering Research & Technology (IJERT) 4(3), 2278–0181 (2015)

[24] Xue, D.-m., Hua, Z.-q.: Arima based time series forecasting model. Recent Advances in Electrical & Electronic Engineering (Formerly Recent Patents on Electrical & Electronic Engineering) 9(2), 93–98 (2016)

[25] Sherstinsky, A.: Fundamentals of recurrent neural network (rnn) and long shortterm memory (lstm) network. Physica D: Nonlinear Phenomena 404, 132306 (2020)