ORIGINAL RESEARCH article

Front. Comput. Sci., 15 October 2026

Sec. Software

Volume 8 - 2026 | https://doi.org/10.3389/fcomp.2026.1972880

An integrated AI-based software architecture for load forecasting, controlled anomaly detection, and predictive energy management

  • 1. School of Information Technologies and Intelligent Systems, D. Serikbayev East Kazakhstan Technical University, Oskemen, Kazakhstan

  • 2. Faculty of Electrical Engineering and Computer Science, Lublin University of Technology, Lublin, Poland

  • 3. Department of Information Technology and Natural Sciences, Sarsen Amanzholov East Kazakhstan University, Oskemen, Kazakhstan

  • 4. Competence Center “Smart Engineering”, D. Serikbayev East Kazakhstan Technical University, Oskemen, Kazakhstan

  • 5. Department “Aviation Equipment and Technologies”, Civil Aviation Academy, Almaty, Kazakhstan

  • 6. Higher School of Information Technology, University Turan, Almaty, Kazakhstan

  • 7. Digital Engineering and IT-Analytics, Karaganda University of Kazpotrebsoyuz, Karaganda, Kazakhstan

Abstract

The increasing deployment of smart meters and Internet of Things technologies has created a demand for intelligent computational systems capable of jointly forecasting electricity consumption, detecting abnormal behavior, and optimizing load management. This study proposes an integrated artificial intelligence-based framework for automated energy metering and consumption management in smart-grid environments. The framework combines a Long Short-Term Memory network for short-term load forecasting, an autoencoder-based model for anomaly detection, and Model Predictive Control for demand-side optimization. The system architecture includes data acquisition, communication, preprocessing, predictive analytics, anomaly monitoring, and decision-support layers. The primary empirical evaluation used 4,380 measured hourly observations (approximately 6 months) from a single administrative building. A separately flagged synthetic temporal extension was retained only as an auxiliary dataset and was excluded from all primary performance metrics. Across five independent model initializations, the final LSTM achieved a MAPE of 3.423 ± 0.555%, an RMSE of 0.336 ± 0.048 kW, and an R2 of 0.973 ± 0.007 on the 633-sequence independent measured test subset. The synthetic extension was maintained as a separately identified auxiliary component and was excluded from all primary training, validation, and independent test metrics. Using a validation-selected reconstruction-error threshold, the autoencoder detected 12 of 30 controlled anomalies in the independent test subset, yielding 100.00% precision, 40.00% recall, and an F1-score of 57.14%. Under the same controlled protocol, One-Class SVM achieved higher recall (53.33%) and F1-score (69.57%), indicating that the autoencoder should be interpreted as an architectural component rather than as the best-performing anomaly detector for the present dataset. A historical proof-of-concept MPC simulation, retained for architectural illustration, reported a 15% reduction in simulated peak demand and a 12% reduction in estimated electricity cost; these values are not interpreted as measured outcomes from the administrative-building experiment. Controlled anomaly injection was used to establish reproducible validation and test labels for the anomaly-detection component. The results demonstrate that the joint integration of forecasting, anomaly detection, and predictive control provides a computationally coherent framework for supporting energy-management efficiency, operational reliability, and data-driven decision-making in intelligent energy systems.

1 Introduction

The digital transformation of the energy sector has accelerated the transition from conventional power networks toward data-driven smart grids. Modern smart-grid environments integrate advanced metering infrastructure, Internet of Things devices, communication networks, cloud platforms, and intelligent decision-support systems to enable bidirectional information exchange between utilities and consumers (Gungor et al., 2011; Fang et al., 2012; Al-Fuqaha et al., 2015). In this context, smart meters provide high-frequency measurements of electricity consumption and create opportunities for real-time monitoring, demand forecasting, anomaly detection, and adaptive load management. However, the increasing volume, velocity, and heterogeneity of metering data also introduce computational challenges related to data quality, nonlinear consumption patterns, model scalability, and reliable decision-making.

Accurate short-term load forecasting is a fundamental component of intelligent energy-management systems because it supports generation scheduling, demand-response planning, peak-load reduction, and efficient allocation of energy resources (Palensky and Dietrich, 2011; Deng et al., 2015). Traditional statistical methods, including autoregressive integrated moving average models, are effective when electricity-consumption data exhibit relatively stable and approximately linear temporal patterns. Nevertheless, their performance may deteriorate in the presence of nonlinear relationships, multiple seasonalities, abrupt behavioral changes, and interactions between consumption and external variables such as temperature, calendar conditions, and equipment-operating schedules.

Machine-learning and deep-learning methods have therefore been increasingly applied to energy forecasting. Ensemble models such as Random Forest and gradient-boosted decision trees can represent nonlinear relationships and interactions among heterogeneous predictors, while recurrent neural networks can explicitly model temporal dependencies (Chen and Guestrin, 2016). In particular, Long Short-Term Memory networks address the vanishing-gradient limitations of conventional recurrent neural networks and can capture both short- and long-term dependencies in sequential data. Previous studies have reported strong LSTM performance in residential and building-load forecasting, especially when weather and calendar variables are included as exogenous inputs (Kong et al., 2019; Wang et al., 2021). Comparative research has also demonstrated that deep-learning architectures can provide accurate load predictions, although their performance depends on data distribution, forecasting horizon, preprocessing strategy, and the occurrence of structural changes in consumption behavior.

Forecasting alone, however, is insufficient for ensuring the reliable operation of smart-metering infrastructures. Electricity-consumption data may contain missing measurements, sensor failures, communication errors, abnormal equipment behavior, or patterns associated with unauthorized consumption. Such anomalies can distort load forecasts and result in inappropriate control decisions. Machine-learning methods have consequently been investigated for electricity-theft and anomaly detection in advanced metering infrastructure (Jokar et al., 2016; Zheng et al., 2018). Autoencoders are especially suitable for unsupervised or semi-supervised anomaly detection because they learn a compact representation of normal operating patterns and identify unusual observations through elevated reconstruction errors. Recent studies have further explored adaptive and dynamic thresholds to improve the robustness of autoencoder-based detection under changing energy-consumption conditions.

Another important requirement is converting forecasts and anomaly-detection outputs into actionable control decisions. Model Predictive Control is well suited to this task because it repeatedly optimizes future control actions over a finite prediction horizon while accounting for operational objectives and system constraints (Camacho and Bordons, 2007). In energy-management applications, MPC can use predicted demand to shift flexible loads, reduce peak consumption, improve load factors, and minimize electricity costs. Nevertheless, the effectiveness of predictive control depends strongly on the accuracy and reliability of the forecasting model. Undetected anomalies or inaccurate forecasts may propagate into the optimization stage and degrade control performance.

Despite substantial progress in forecasting, anomaly detection, and demand-side control, these tasks are frequently investigated as separate computational problems. Many studies focus exclusively on prediction accuracy without integrating forecasts into an operational control mechanism. Other studies address electricity-theft detection without examining its relationship with load forecasting and energy-management decisions. Consequently, there remains a need for an integrated framework that combines data preprocessing, temporal forecasting, controlled anomaly assessment, and predictive decision support within a unified software architecture.

To address this gap, this study proposes an integrated artificial intelligence-based framework for automated electricity metering and predictive energy management. The framework combines an LSTM network for short-term load forecasting, an autoencoder for anomaly detection, and an MPC module for demand-side optimization. The proposed architecture connects smart-meter data acquisition with preprocessing, predictive analytics, anomaly monitoring, and decision-support functions. The research is designed to evaluate not only forecasting accuracy but also the operational effects of integrating predicted demand into an optimization-based control strategy.

The main contributions of this study are as follows:

  • An integrated multilayer architecture is developed to combine smart-meter data acquisition, machine-learning analytics, anomaly monitoring, and predictive energy management.

  • An LSTM-based forecasting model is implemented using historical consumption, environmental variables, calendar characteristics, and equipment-operating information.

  • An autoencoder-based anomaly-detection module is incorporated to identify observations that deviate from learned normal consumption patterns.

  • An MPC-based decision-support module is incorporated as a proof-of-concept component for transforming load forecasts into load-management recommendations aimed at peak-demand and cost reduction.

  • The framework is evaluated through a corrected chronological load-forecasting experiment with repeated-run uncertainty analysis, a controlled anomaly-detection experiment, and a separate proof-of-concept MPC simulation.

  • An integration ablation experiment quantitatively evaluates whether detector-guided anomaly handling improves downstream load forecasting under controlled measurement corruption.

The remainder of the article is organized as follows. Section 2 reviews related research on load forecasting, anomaly detection, and intelligent energy management. Section 3 describes the proposed system architecture, dataset, preprocessing procedures, predictive models, MPC formulation, and evaluation protocol. Section 4 presents the experimental results. Section 5 discusses the findings, limitations, and practical implications, while Section 6 concludes the study and outlines directions for future research.

2 Literature review

2.1 Smart metering and intelligent energy-management systems

The development of smart grids has transformed conventional electricity networks into cyber–physical infrastructures capable of supporting bidirectional communication, distributed sensing, automated control, and data-driven decision-making. Advanced Metering Infrastructure constitutes one of the key components of this transformation because it connects smart meters, communication networks, data-management platforms, and utility applications within a unified information environment. Smart meters continuously collect electricity-consumption data and enable utilities to perform remote monitoring, dynamic pricing, demand-response management, and more accurate billing (Gungor et al., 2011; Fang et al., 2012).

Communication technologies are essential to the reliability and scalability of smart-metering systems. Power-line communication, cellular networks, wireless sensor networks, and Internet of Things protocols are widely used to transmit metering data from end users to local concentrators and central analytical platforms. However, communication delays, packet losses, device heterogeneity, and cybersecurity risks may reduce data quality and affect the operation of downstream forecasting and control modules (Gungor et al., 2011; Al-Fuqaha et al., 2015). Reliability-oriented modeling is also important in emerging communication technologies. Recent research on visible-light communication has emphasized the need to model data-transmission reliability and identify mechanisms for improving communication performance under variable transmission conditions (Alibekkyzy et al., 2025).

The integration of smart meters into smart-grid environments also supports the transition from passive consumers to active participants who can adapt their energy use in response to price signals, demand-response programs, and local generation conditions. Demand-side management can reduce peak loads, improve network stability, and support the integration of distributed renewable-energy resources (Mohsenian-Rad et al., 2010; Palensky and Dietrich, 2011). Nevertheless, the effectiveness of these mechanisms depends on the availability of reliable forecasts, accurate anomaly-detection methods, and optimization models capable of converting analytical outputs into operational decisions.

2.2 Electricity-load forecasting

Electricity-load forecasting is a central task in energy-management systems because it supports generation planning, network scheduling, tariff optimization, and demand-response control. Forecasting methods are generally divided into statistical, machine-learning, and deep-learning approaches.

Traditional statistical models, including autoregressive integrated moving average methods, exponential smoothing, and regression models, have been widely used for short-term electricity forecasting. Their main advantages include interpretability, relatively low computational cost, and suitability for stationary or approximately linear time series (Box et al., 2015). However, energy-consumption data often contain nonlinear dependencies, multiple seasonal cycles, abrupt changes, and interactions between historical demand, weather conditions, calendar variables, and consumer behavior. These characteristics can limit the forecasting accuracy of conventional statistical approaches.

Machine-learning models provide greater flexibility in representing nonlinear relationships. Random Forest, support vector regression, and gradient-boosting methods can process heterogeneous predictors and are generally robust to noise and complex feature interactions. XGBoost, for example, is an efficient scalable implementation of gradient-boosted decision trees and has been applied to many forecasting and classification tasks involving structured data (Chen and Guestrin, 2016). Nevertheless, conventional machine-learning models usually require explicit lagged features and may not fully capture long-term temporal dependencies unless the input representation is carefully engineered.

Deep-learning methods have increasingly been adopted for short-term load forecasting. Recurrent neural networks are designed for sequential data, but standard recurrent architectures may experience vanishing or exploding gradients when learning long-range dependencies. Neural-network-based approaches have also been investigated for integrated monitoring and control of energy-consumption systems, demonstrating the relevance of intelligent models not only for prediction but also for operational energy management (Shvets et al., 2023). Long Short-Term Memory networks address this limitation through memory cells and gating mechanisms that regulate the retention and transfer of information across time steps.

Kong et al. (2019) demonstrated that an LSTM-based architecture can effectively model residential electricity-consumption patterns and capture complex temporal relationships. Wang et al. (2021) further showed that the inclusion of weather-related variables can improve short-term residential load forecasting because temperature and other environmental conditions influence heating, cooling, and appliance use. Deep neural networks have also been successfully applied to building-energy forecasting, where operational schedules and environmental conditions create complex nonlinear load profiles (Marino et al., 2016).

Although LSTM models often outperform traditional forecasting methods, their performance is sensitive to the quality and volume of training data, sequence length, network architecture, hyperparameter selection, and forecasting horizon. In addition, high forecasting accuracy does not automatically produce operational energy savings unless the predictions are integrated with an appropriate decision-making or control mechanism.

2.3 Anomaly detection and electricity-theft identification

Smart-meter data may contain anomalies caused by faulty sensors, communication failures, data corruption, equipment malfunctions, abrupt behavioral changes, or unauthorized electricity consumption. Detecting such abnormalities is important because anomalous observations may distort forecasting models, reduce billing accuracy, and cause inappropriate management decisions.

Supervised methods such as support vector machines, decision trees, and neural networks have been applied to electricity-theft detection when labeled examples of normal and fraudulent behavior are available. Jokar et al. (2016) proposed a consumption-pattern-based method for identifying electricity theft in Advanced Metering Infrastructure. Their results demonstrated that machine-learning techniques can distinguish abnormal consumption profiles from legitimate customer behavior.

However, labeled anomaly datasets are often limited because theft events and equipment failures are relatively rare, difficult to verify, and potentially sensitive. For this reason, unsupervised and semi-supervised methods have become increasingly important. Autoencoders are particularly suitable for this setting because they can be trained primarily on normal observations. The encoder maps the input data into a lower-dimensional latent representation, while the decoder reconstructs the original input. Observations with reconstruction errors above a selected threshold can then be classified as anomalous.

Zheng et al. (2018) developed a deep-learning approach for electricity-theft detection using wide and deep convolutional neural networks. Their work showed that deep architectures can extract complex patterns from smart-meter data and improve classification performance. Nevertheless, deep anomaly-detection systems remain sensitive to class imbalance, threshold-selection procedures, changes in normal operating conditions, and differences between synthetic and real-world anomaly patterns.

A further limitation is that anomaly detection is frequently studied as an isolated classification problem. In practical energy-management systems, abnormal data should also influence forecasting reliability and control decisions. For example, suspicious readings may need to be filtered, flagged, replaced, or excluded before being passed to a forecasting or optimization module. Therefore, anomaly detection should be treated as an integral component of the complete analytical pipeline rather than as a separate diagnostic function.

2.4 Demand response and model predictive control

Demand-response strategies aim to modify electricity-consumption patterns in response to operational requirements, electricity prices, network constraints, or incentive mechanisms. Demand-side management can shift flexible loads away from peak periods, reduce infrastructure stress, and improve the utilization of available generation resources (Siano, 2014; Palensky and Dietrich, 2011; Deng et al., 2015).

Game-theoretic approaches have been used to coordinate consumption schedules among multiple users. Mohsenian-Rad et al. (2010) proposed an autonomous demand-side management framework in which consumers optimize their consumption schedules while accounting for interactions with other participants. Such approaches can reduce aggregate peak demand, although their implementation may require assumptions about consumer behavior, communication availability, and participation incentives.

Model Predictive Control provides another systematic approach to energy management. MPC uses a mathematical model of the controlled system to predict future behavior over a finite horizon. At each control step, an optimization problem is solved to determine the sequence of control actions that minimizes a specified objective while satisfying operational constraints. Only the first action is implemented, after which the optimization is repeated using updated measurements (Camacho and Bordons, 2007).

In energy applications, the objective function may include electricity cost, peak-load penalties, deviations from desired demand levels, equipment constraints, and user-comfort requirements. MPC is therefore suitable for combining predicted electricity demand with real-time operational decisions. However, its performance depends strongly on forecasting accuracy and model reliability. Forecasting errors, undetected anomalies, or inaccurate system constraints may lead to suboptimal control actions.

2.5 IoT, cloud platforms, and digital twins

Internet of Things technologies extend the functionality of smart-metering systems by connecting meters, sensors, gateways, appliances, and control devices through interoperable communication protocols. IoT-based energy platforms support real-time monitoring, remote configuration, automated data collection, and integration with cloud or edge-computing services (Al-Fuqaha et al., 2015).

Related research in autonomous cyber–physical systems has likewise demonstrated the importance of computational modeling for coordinated decision-making and adaptive control, including the modeling of obstacle-avoidance strategies in groups of unmanned aerial vehicles (Keribayeva et al., 2025). Although the application domain differs from energy management, such studies illustrate the broader role of intelligent software architectures in integrating sensing, prediction, and decision-making functions.

Cloud platforms offer scalable storage and computational resources for processing large volumes of smart-meter data. They can host forecasting models, anomaly-detection services, dashboards, and optimization algorithms. At the same time, centralized cloud processing may introduce latency, privacy, and communication-dependence concerns. Edge-computing architectures can partially address these limitations by performing selected analytical tasks closer to the data source.

Cloud-based software architectures have also been applied to monitoring and forecasting tasks in other environmental and cyber-physical domains, demonstrating the feasibility of integrating data acquisition, analytical services, forecasting modules, and user-facing interfaces within a scalable service-oriented platform (Madiyarov et al., 2026).

Digital twins represent another promising direction for intelligent energy management. A digital twin is a virtual representation of a physical system that is continuously updated using operational data. It can be used to simulate alternative scenarios, evaluate control strategies, predict failures, and support maintenance decisions. Tao et al. (2019) emphasized the role of digital twins in connecting physical equipment with data-driven models and intelligent services. In energy systems, digital twins can potentially integrate forecasting, anomaly detection, and predictive control within a unified virtual environment.

2.6 Recent integrated forecasting and anomaly-detection frameworks

Recent research increasingly considers energy forecasting and anomaly detection within integrated analytical frameworks rather than as completely independent tasks. For example, Wu et al. (2025) proposed a DA-LSTM framework combining power-load forecasting with residual-based anomaly detection and demonstrated the approach on the GEFCom2014 and PJM datasets. Their study shows that high-accuracy forecasting and anomaly identification can be implemented within a unified data-driven pipeline (Wu et al., 2025).

More recently, Cai et al. (2026) proposed an integrated smart-building framework combining Transformer-based energy forecasting, dual-stream anomaly diagnosis, and SHAP-based explainability. The framework was evaluated on two buildings from the Building Data Genome Project 2 and included explicit ablation analysis and cross-building evaluation (Cai et al., 2026).

These recent studies demonstrate that integration of forecasting and anomaly analysis is no longer, by itself, sufficient to establish novelty. The contribution of the present work therefore lies not in proposing a new standalone forecasting or anomaly-detection algorithm, but in organizing anomaly assessment, short-term forecasting, and predictive-control decision support within a modular software architecture while explicitly separating measured data, controlled anomaly injections, auxiliary synthetic data, and simulation-level control evidence.

2.7 Research gap

Existing research demonstrates substantial progress in smart-metering infrastructure, electricity-load forecasting, anomaly detection, and demand-side optimization. Nevertheless, several limitations remain.

First, many studies investigate load forecasting independently from operational control. They report improvements in MAPE, RMSE, or related metrics but do not evaluate whether the forecasts lead to measurable reductions in peak demand or electricity cost.

Second, electricity-theft and anomaly-detection studies commonly treat abnormal-consumption identification as a separate classification task. The relationship between anomalous observations, forecasting reliability, and optimization-based decision-making is often insufficiently examined.

Third, some proposed energy-management architectures remain conceptual and do not provide a complete computational pipeline connecting data acquisition, preprocessing, prediction, anomaly monitoring, and control.

Fourth, reproducibility remains a concern because studies do not always report dataset characteristics, chronological splitting procedures, preprocessing parameters, model configurations, random seeds, and threshold-selection strategies in sufficient detail.

Against this background, the novelty of the present study does not lie in introducing a fundamentally new LSTM, autoencoder, or MPC algorithm. Instead, the study contributes a modular software architecture in which validation-based anomaly assessment is positioned upstream of short-term forecasting and validated forecasting outputs can subsequently support predictive-control decision making.

A further methodological contribution is the explicit separation of evidence according to provenance: measured building observations are used for primary forecasting evaluation, controlled anomaly injection is used for reproducible anomaly-detection assessment, the synthetic temporal extension is treated only as auxiliary data, and the MPC results are identified separately as historical proof-of-concept simulation evidence. In addition, an integration ablation experiment is used to quantify the downstream effect of anomaly handling on forecasting robustness.

3 Materials and methods

This section describes the complete computational protocol used to evaluate the proposed intelligent energy-management framework. The primary controlled computational evaluation is based on the measured portion of the supplied hourly dataset and includes chronological preprocessing, one-step-ahead load forecasting, controlled anomaly injection, reconstruction-based anomaly detection, and component-level integration analysis. The synthetically extended half-year is treated as a separately identified auxiliary dataset and is not used for primary model training, validation, or independent real-world testing.

3.1 System architecture

The proposed system is organized as a five-layer architecture consisting of a measurement layer, communication layer, data-management layer, intelligent-analytics layer, and control and decision-support layer. The overall architecture is shown in Figure 1.

Figure 1

The measurement layer contains electricity meters and contextual sensors associated with the monitored administrative building. The analytical dataset is sampled at 1-hour intervals and contains active power, reactive power, outdoor temperature, calendar information, and equipment operating status. Each record is timestamped to preserve temporal order and to support sliding-window sequence construction.

The communication layer represents the data-transfer interface between field devices and the analytical environment. The architecture is compatible with Power Line Communication, GSM/LTE, and lightweight IoT messaging such as MQTT. These communication options define the deployment architecture; the forecasting and anomaly-detection experiments reported in this study operate on the supplied hourly analytical dataset rather than on packet-level communication traces.

The data-management layer performs timestamp alignment, quality control, missing-value treatment, feature construction, scaling, chronological partitioning, and storage of measurements, forecasts, anomaly scores, and control outputs. PostgreSQL is used as the relational storage component in the proposed deployment architecture.

The intelligent-analytics layer contains two data-driven models. An LSTM network produces one-step-ahead electricity-demand forecasts from the preceding 24 h of multivariate observations, whereas a fully connected autoencoder models normal operating behavior and assigns a reconstruction-error score to each evaluated observation.

The control and decision-support layer receives validated forecasts and uses them as predictive inputs for a receding-horizon Model Predictive Control formulation. The MPC output is interpreted as a decision-support signal for flexible and controllable loads rather than as direct autonomous control of the entire electrical network. Anomaly flags are evaluated before automated recommendations are accepted so that suspicious measurements can be excluded, corrected, or referred for manual inspection. The complete computational workflow is summarized in Figure 2.

Figure 2

3.2 Dataset and preprocessing

3.2.1 Dataset description and provenance

The study uses a 12-month hybrid hourly dataset containing 8,760 consecutive observations from 25 July 2025 at 00:00 to 24 July 2026 at 23:00. The dataset consists of two explicitly separated components. The measured component contains 4,380 hourly observations from an administrative building in Ust-Kamenogorsk, Kazakhstan, covering 25 July 2025 at 00:00 to 23 January 2026 at 11:00. The second component contains 4,380 pre-generated synthetic-extension observations covering 23 January 2026 at 12:00 to 24 July 2026 at 23:00.

The prediction target is Total Active Power, expressed in kilowatts. The available explanatory variables are Total Reactive Power (kvar), outdoor temperature (°C), hour of day, day of week, weekend status, month, season, holiday status, and equipment operating mode. The fields Data Origin, Synthetic Flag, and Split are provenance and experiment-management variables only and are never used as predictive inputs.

The supplied analysis file distinguishes measured rows from the synthetic extension using Data Origin and Synthetic Flag. The primary dataset consisted of 4,380 consecutive measured hourly observations collected from an administrative building in Ust-Kamenogorsk, Kazakhstan, between 25 July 2025 at 00:00 and 23 January 2026 at 11:00. The dataset contained Total Active Power, Total Reactive Power, outdoor temperature, calendar variables, and equipment operating status.

The analytical file does not contain device-model identifiers for the original electricity meter or versioned metadata for the external weather-data provider. Accordingly, the reproducibility claim in this work is limited to the supplied time-aligned analytical dataset and the explicitly reported computational protocol; no meter-model-specific or weather-provider-specific calibration is inferred.

3.2.2 Missing-value treatment and quality control

Timestamps were converted to a uniform hourly index and ordered chronologically. Twelve missing numeric values identified during preparation of the annual dataset were corrected by linear interpolation between adjacent valid observations. After this procedure, the final analytical table contained no missing cells.

Quality control combined physical plausibility checks with robust statistical screening. Negative active or reactive power values were treated as invalid. The interquartile-range rule was used only to flag statistically unusual observations for inspection and not as an automatic deletion rule, because genuine peak-demand periods may legitimately appear as statistical extremes.

Flagged observations were retained unless they violated physical plausibility or were independently identified as measurement errors. This conservative treatment prevents legitimate peaks from being removed before the anomaly-detection experiment.

3.2.3 Calendar and operational feature construction

Calendar predictors were derived directly from each timestamp. Weekend and holiday status were encoded as binary variables. Equipment Operating Mode was converted to a binary working/non-working indicator. Season was represented using indicator variables. To preserve the circular structure of hour-of-day, day-of-week, and month variables, cyclic sine/cosine encoding was applied.

The feature vector at each hourly time step therefore contains active and reactive power, outdoor temperature, cyclic calendar variables, weekend and holiday indicators, seasonal indicators, and equipment operating status.

3.2.4 Feature scaling and leakage prevention

Continuous model inputs were transformed using Min–Max scaling. The minimum and maximum values were estimated exclusively from the measured training subset and then applied unchanged to the measured validation and test subsets. Target predictions were transformed back to kilowatts before calculation of forecasting metrics.

No transformation parameter was estimated from validation or test observations. The provenance fields Data Origin, Synthetic Flag, and Split were excluded before scaling and model fitting.

3.2.5 Chronological splitting and sequence generation

Random shuffling was not used because the data form a time series. The 4,380 measured observations were partitioned chronologically into 3,066 training observations (70%), 657 validation observations (15%), and 657 independent test observations (15%). The training interval extends from 25 July 2025 at 00:00 to 29 November 2025 at 17:00; the validation interval extends from 29 November 2025 at 18:00 to 27 December 2025 at 02:00; and the measured test interval extends from 27 December 2025 at 03:00 to 23 January 2026 at 11:00.

A look-back window of L = 24 hourly steps was used for one-step-ahead forecasting. Sequences were constructed independently inside each subset, and no sequence was permitted to cross a train–validation or validation–test boundary.

With a 24-h look-back, this procedure produces 3,042 training sequences, 633 validation sequences, and 633 independent test sequences. The 4,380 synthetic-extension observations form a separate auxiliary subset and are not included in the primary training, validation, or independent test sequence counts.

3.3 Load-forecasting model

3.3.1 LSTM formulation

Electricity demand was modeled as a nonlinear temporal function of the preceding 24-h multivariate sequence. The LSTM was selected because its gated recurrent structure can retain relevant information across both short and longer temporal dependencies.

Here, σ denotes the logistic sigmoid function, ⊙ denotes element-wise multiplication, c_t is the cell state, and h_t is the hidden state. The one-step-ahead prediction is obtained from the final recurrent representation.

3.3.2 Network architecture and training

The final forecasting model consisted of two stacked LSTM layers with 64 and 32 hidden units, respectively. A dropout rate of 0.20 was applied after each recurrent layer. To improve training stability and exploit the strong short-term persistence of building electricity demand, the network was formulated as a residual forecasting model. Specifically, the recurrent network estimated a residual correction relative to the most recent observed active-power value, and the final one-step-ahead prediction was obtained by adding this correction to the latest scaled demand observation. The recurrent output was passed through a fully connected layer with 16 ReLU-activated neurons followed by a linear residual-output neuron.

The model was trained using the AdamW optimizer with a learning rate of 5 × 10−4 and a weight-decay coefficient of 1 × 10−5. The batch size was 128 and the maximum number of training epochs was 50. Mean squared error was used as the optimization objective. Gradient norms were clipped to 1.0 to improve numerical stability. A ReduceLROnPlateau scheduler reduced the learning rate by a factor of 0.5 after five consecutive epochs without improvement in validation loss. Early stopping was applied with a patience of eight epochs, and the model weights corresponding to the minimum validation loss were restored before test evaluation.

Model selection was performed using the validation subset only. Candidate look-back windows, LSTM layer widths, dropout rates, learning rates, batch sizes, and network depths were evaluated before the final 24-h, 64/32-unit configuration was retained. The measured test subset was not used for model or hyperparameter selection.

3.4 Anomaly-detection model

3.4.1 Autoencoder architecture and reconstruction loss

A fully connected autoencoder was used to learn the multivariate structure of normal measured observations. For an F-dimensional input vector x_i, the encoder g_φ maps the observation to a 16-dimensional latent representation z_i, and the decoder r_θ reconstructs the original vector.

For the corrected anomaly-detection experiment, the autoencoder input dimension was F = 2. Each input vector consisted of Total Active Power and Total Reactive Power. Both variables were Min–Max scaled using parameters estimated exclusively from the measured training subset. Weather, calendar, and equipment-operating variables were retained for the forecasting model but were not included in the autoencoder input vector.

The network topology is F → 64 → 32 → 16 → 32 → 64 → F. Hidden layers use ReLU activation. Because continuous inputs are Min–Max scaled, the output layer uses sigmoid activation. The model is trained on normal measured training observations only, using mean squared reconstruction error.

The autoencoder uses Adam with a learning rate of 0.001, batch size 32, and a maximum of 100 epochs. Early stopping monitors validation reconstruction loss with patience 10, and the lowest-loss weights are restored. The random seed is fixed at 42.

3.4.2 Controlled anomaly injection

Verified real-world anomaly labels were not available for the complete evaluation period. Therefore, controlled synthetic anomalies were injected exclusively into the measured validation and measured test subsets. The measured training subset remained free of injected anomalies so that the autoencoder learned normal operating behavior.

The anomaly-evaluation set contains 1,314 measured hourly observations: 657 validation observations and 657 test observations. A total of 66 one-hour observations were modified, corresponding to 5.02% of the anomaly-evaluation set. The validation subset contains 36 injected anomalies and the test subset contains 30.

Four anomaly types were used. Twenty abrupt-drop events were generated as 0.35 times the clean active-power value; 16 spike events were generated as 1.65 times the clean value; 15 level-shift events were generated as 1.30 times the clean value; and 15 zero-consumption events were generated by setting active power to zero. The injection procedure used random seed 42. The remaining 1,248 evaluation observations retained their clean measured values and were labeled normal.

3.4.3 Threshold selection and decision rule

The anomaly threshold was calibrated using the measured validation subset only. Candidate thresholds were defined by the 90th, 95th, 97.5th, and 99th percentiles of validation reconstruction error. Because controlled validation labels are available, the final threshold was the candidate value that maximized validation F1-score. The selected threshold was then frozen before evaluation on the measured test subset.

Among the evaluated candidates, the 97.5th-percentile threshold produced the highest validation F1-score and was therefore selected. The resulting fixed reconstruction-error threshold was τ = 0.0006246842. This value was subsequently applied without modification to all 657 observations of the independent measured test subset.

Here, denotes an anomaly and τ is the validation-selected reconstruction-error threshold. No test-set observation is used to determine τ.

3.4.4 Baseline anomaly-detection models

To provide a controlled reference for the autoencoder-based anomaly detector, two standard unsupervised anomaly-detection baselines were evaluated: Isolation Forest and One-Class Support Vector Machine (OCSVM). Both baseline models used the same two-dimensional input representation as the autoencoder, consisting of Min–Max-scaled Total Active Power and Total Reactive Power. Scaling parameters were estimated exclusively from the measured training subset.

Both baseline models were fitted using the same normal measured training observations used for autoencoder training. The same controlled anomaly locations and labels were retained in the measured validation and independent test subsets, ensuring that all anomaly-detection methods were evaluated under an identical experimental protocol.

Isolation Forest was implemented using scikit-learn. Candidate configurations were evaluated using the validation subset only. The number of estimators was selected from {100, 300, 500}, while max_samples was selected from {auto, 0.5, 1.0}. The feature fraction was fixed at 1.0, and random seed 42 was used. Anomaly scores were derived from the negative decision function so that larger values corresponded to more anomalous observations.

The One-Class SVM baseline used an RBF kernel. Candidate values of ν ∈ {0.01, 0.03, 0.05, 0.10} and γ ∈ {scale, 0.1, 1.0, 10.0} were evaluated exclusively on the validation subset. The anomaly score was defined as the negative decision-function value.

For both baseline methods, the final anomaly threshold was selected using the same validation-only principle applied to the autoencoder. Candidate score thresholds corresponding to the 90th, 95th, 97.5th, and 99th percentiles of validation anomaly scores were evaluated, and the threshold maximizing validation F1-score was retained. The selected model configuration and threshold were then frozen before evaluation on the independent 657-observation measured test subset. No test-set observation or label was used for model selection or threshold calibration.

Performance was evaluated using Accuracy, Precision, Recall, F1-score, and the binary confusion matrix. The primary purpose of the baseline comparison was not to establish universal superiority of one anomaly-detection algorithm, but to contextualize the performance of the autoencoder under the same controlled anomaly-injection protocol.

3.4.5 Integration ablation protocol

To quantify the downstream effect of anomaly handling on short-term load forecasting, an integration ablation experiment was performed using the same independent measured test subset and the same controlled anomaly locations employed in the anomaly-detection experiment.

Three input conditions were evaluated. In the clean-input condition, the forecasting model received the original measured observations. In the corrupted-input condition, the controlled anomalous Total Active Power values were inserted into the forecasting input windows without anomaly filtering. In the detector-guided correction condition, only observations identified as anomalous by the autoencoder were corrected before being passed to the forecasting model.

To preserve causality, detected anomalous active-power values were replaced using the most recent valid corrected observation; no future measurements were used during correction. In all three conditions, the forecasting target remained the original clean measured next-hour Total Active Power value.

The same trained residual LSTM configuration, chronological data partition, 24-h look-back window, and independent measured test interval were used across the three conditions. The purpose of this ablation was not to evaluate a new forecasting model, but to quantify whether upstream anomaly detection can reduce the degradation in forecasting accuracy caused by corrupted input measurements.

3.5 Historical MPC proof-of-concept formulation

3.5.1 Control objective and interpretation

The MPC module is formulated as a simulation-level decision-support component that converts short-term load forecasts into recommendations for flexible or controllable demand. The controlled resource may represent shiftable equipment schedules, HVAC demand, auxiliary loads, storage-assisted demand, or other demand-response participants. The MPC output is not interpreted as direct autonomous control of all electricity consumption in the monitored system.

At each hourly control step, the controller evaluates a 24-h prediction horizon. The objective is to track a desired load profile while penalizing excessive control action. In the source control formulation, the objective iswhere P̂(t + k) is the predicted demand, Pref(t + k) is the reference demand, u(t + k) is the recommended load-adjustment signal, and α and β determine the relative emphasis on reference tracking and control smoothness.

The available project record preserves the MPC objective structure, a 24-h control visualization, the receding-horizon workflow, and the interpretation of the control action, but it does not preserve the numerical α and β coefficients, actuator-specific bounds, or the optimization-solver configuration used in the earlier KEGOC-oriented simulation from which the legacy MPC performance figures were derived. These undocumented numerical settings are therefore not reconstructed or invented in the present reproducibility protocol. MPC results are interpreted as proof-of-concept simulation outcomes rather than as a device-level controller benchmark for the administrative-building dataset.

Accordingly, the MPC component is retained in the present manuscript for architectural and methodological illustration only. It is not included in the controlled benchmarking performed for the forecasting and anomaly-detection components, and the historical numerical MPC outcomes are not interpreted as results obtained from the administrative-building dataset.

3.5.2 Operational constraints and receding-horizon procedure

The constrained MPC formulation limits the predicted controlled load and the recommended adjustment signal to admissible ranges:

For load-shifting actions that only redistribute demand in time, an energy-conservation condition is applied over the prediction horizon:

When the decision-support action represents genuine curtailment, reduced operating time, or a set-point change, the energy-conservation condition is not imposed; in that case a reduction in total energy use may be physically meaningful. This distinction is required when interpreting peak-demand reduction separately from energy-consumption reduction.

The receding-horizon loop is executed hourly. At time t, the latest validated measurements are received; a 24-h forecast is generated; the constrained optimization problem is solved; only the first recommended action is retained; the next measurement is received; and the horizon is shifted forward by 1 h. If an anomaly flag is active for the newest input, the corresponding control recommendation is withheld or referred for operator verification.

3.6 Experimental setup and computational protocol

The corrected computational experiments reported in the revised manuscript were executed in a Python 3.13.5 environment. The corrected LSTM forecasting model used for the primary 633-sequence independent test evaluation was implemented in PyTorch 2.10.0 + cpu. NumPy 2.3.5 was used for numerical processing, and scikit-learn 1.8.0 was used for preprocessing and scaling operations.

To evaluate robustness to stochastic model initialization, the final LSTM configuration was trained independently five times using random seeds 42, 43, 44, 45, and 46. The chronological training, validation, and test partitions, preprocessing parameters, input features, model architecture, and stopping criteria were kept identical across all runs. Performance was evaluated on the same 633-sequence independent measured test subset, and the forecasting metrics are reported as mean ± standard deviation across the five independent runs.

The corrected forecasting comparison included Random Forest and ARIMAX baselines evaluated using the same chronological measured-data partition, one-step-ahead forecasting horizon, and independent 633-sequence test subset as the residual LSTM. Hyperparameter and model-order selection were performed using the validation subset only. The historical MPC results, in contrast, originate from an earlier project simulation for which the complete numerical controller configuration was not preserved and are therefore retained only as illustrative proof-of-concept results.

3.7 Evaluation metrics

3.7.1 Forecasting metrics

Forecasting accuracy was evaluated on the independent measured test subset using Mean Absolute Error (MAE), Root Mean Squared Error (RMSE), Mean Absolute Percentage Error (MAPE), and the coefficient of determination R2.

A numerical constant of ε = 10−8 kW was added to the denominator to avoid division by zero. Lower MAE, RMSE, and MAPE indicate better forecasting performance, whereas R2 values closer to one indicate stronger agreement with the measured demand trajectory.

3.7.2 Anomaly-detection metrics

Anomaly-detection performance was evaluated on the measured test subset containing controlled ground-truth labels. Accuracy, precision, recall, and F1-score were calculated from true positives (TP), true negatives (TN), false positives (FP), and false negatives (FN).

Because anomalies constitute a minority class, precision, recall, and F1-score are interpreted together with accuracy rather than relying on accuracy alone.

3.7.3 Energy-management metrics

Simulation-level energy-management performance is summarized using peak-demand reduction, electricity-cost reduction, and load factor. A reduction in total daily energy is reported only when the modeled control action includes genuine curtailment, reduced operating time, or an equipment set-point change; pure load shifting alone does not justify an energy-saving claim.

This evaluation convention separates peak shaving and tariff-driven cost redistribution from genuine energy conservation and prevents load shifting from being misinterpreted as a reduction in total energy use.

4 Results

4.1 Dataset characteristics and experimental partitioning

The complete dataset used in this study comprised 8,760 consecutive hourly observations covering the period from 25 July 2025 at 00:00 to 24 July 2026 at 23:00. The dataset consisted of two explicitly distinguished components: 4,380 measured observations obtained from the monitored administrative building and 4,380 observations forming a synthetic temporal extension.

The measured component covered the period from 25 July 2025 at 00:00 to 23 January 2026 at 11:00 and was used for the primary model-development and evaluation procedures. The synthetic extension covered the period from 23 January 2026 at 12:00 to 24 July 2026 at 23:00. Because these observations were synthetically extended rather than independently measured, they were excluded from the primary model-development and test evaluation and were retained only as a separately identified auxiliary component of the dataset.

The 4,380 measured observations were divided chronologically into training, validation, and test subsets. The training subset contained 3,066 observations, the validation subset contained 657 observations, and the independent measured test subset contained 657 observations. Random shuffling was not applied.

The training period extended from 25 July 2025 at 00:00 to 29 November 2025 at 17:00. The validation period covered 29 November 2025 at 18:00 to 27 December 2025 at 02:00, and the independent test period covered 27 December 2025 at 03:00 to 23 January 2026 at 11:00.

A 24-h look-back window was applied independently within each subset. Consequently, 3,042 training sequences, 633 validation sequences, and 633 independent test sequences were generated. No sequence was allowed to cross the boundary between the training, validation, and test subsets. Thus, information from future observations was not introduced into model training.

Continuous variables were normalized using parameters estimated exclusively from the measured training subset. The same transformation parameters were subsequently applied to the validation and test subsets. The provenance variables Data Origin, Synthetic Flag, and Split were excluded from the model input.

These results confirm that the final experimental structure preserved chronological independence between model development and evaluation and maintained a clear separation between measured and synthetically extended observations.

The evaluated hyperparameter search space and selected configuration are summarized in Table 1.

Table 1

HyperparameterSelected value
Look-back window24 h
LSTM units64 and 32
Number of LSTM layers2
Dropout rate0.20
OptimizerAdamW
Initial learning rate5 × 10−4
Weight decay1 × 10−5
Batch size128
Maximum epochs50
Early-stopping patience8
LR schedulerReduceLROnPlateau
LR reduction factor0.5
Scheduler patience5
Gradient clipping1.0
Repeated-run seeds42, 43, 44, 45, 46

Hyperparameter search space and selected configuration.

4.2 Controlled load-forecasting comparison

To provide a controlled comparison across forecasting approaches, the Random Forest, ARIMAX, and residual LSTM models were evaluated using the same chronologically partitioned measured dataset, the same one-step-ahead forecasting horizon, and the same independent 633-sequence test subset.

The Random Forest model achieved an MAE of 0.177 kW, an RMSE of 0.248 kW, a MAPE of 2.310%, and an R2 of 0.986. The selected ARIMAX(3,0,0) model achieved an MAE of 0.270 kW, an RMSE of 0.372 kW, a MAPE of 3.352%, and an R2 of 0.967.

The residual LSTM was evaluated across five independent random initializations. It achieved a mean MAE of 0.268 ± 0.042 kW, an RMSE of 0.336 ± 0.048 kW, a MAPE of 3.423 ± 0.555%, and an R2 of 0.973 ± 0.007.

Under the corrected controlled forecasting protocol, Random Forest, ARIMAX, and the residual LSTM were evaluated using the same chronological measured-data partition, forecasting horizon, and independent test subset. Random Forest achieved the lowest point-estimate forecasting error on the present dataset, while the residual LSTM demonstrated stable performance across five independent initializations. Future work should extend this comparison to additional forecasting architectures, larger multi-building datasets, and repeated statistical evaluation across independent sites.

The controlled comparison shows that Random Forest achieved the best point-estimate forecasting performance on the present dataset. The residual LSTM remained competitive and demonstrated stable performance across independent initializations, while ARIMAX provided comparable short-term forecasting accuracy using a statistical time-series formulation.

These findings indicate that the principal contribution of the present study should not be interpreted as superiority of the LSTM forecasting model over all alternative approaches. Instead, the forecasting module should be viewed as one component of the broader integrated architecture. Figure 3 presents the measured and LSTM-predicted electricity demand over the independent measured test interval at hourly and daily resolutions. Monthly and seasonal panels are not included because the independent measured test interval covers approximately 27 days and therefore does not support independent multi-season evaluation.

Figure 3

4.3 Controlled anomaly-detection evaluation

The anomaly-detection experiment was performed using controlled synthetic anomaly injection applied exclusively to measured validation and test observations. This design was used because independently verified real-world anomaly labels were not available for the complete monitoring period.

The complete anomaly-evaluation dataset contained 1,314 measured observations, including 657 validation observations and 657 test observations. A total of 66 observations were modified to introduce controlled abnormal behavior, corresponding to approximately 5.02% of the evaluation dataset.

Thirty-six anomalies were introduced into the validation subset and were used for anomaly-threshold calibration. The independent measured test subset contained 30 injected anomalies and 627 unchanged normal observations.

The test-set anomalies consisted of four controlled categories: 6 abrupt-drop events, 8 spike events, 7 level-shift events, and 9 zero-consumption events. These controlled cases provided explicitly defined ground-truth labels for evaluating reconstruction-error-based detection.

The anomaly threshold was selected exclusively using the validation subset. Candidate thresholds corresponding to the 90th, 95th, 97.5th, and 99th percentiles of the validation reconstruction-error distribution were evaluated, and the threshold producing the highest validation F1-score was selected. The resulting threshold was subsequently fixed before the independent test subset was processed.

Figure 4 shows the reconstruction-error sequence for all 657 measured test observations together with the fixed validation-selected threshold and the locations of the 30 injected ground-truth anomaly events.

Figure 4

Using the validation-selected 97.5th-percentile threshold (τ = 0.0006246842), the autoencoder identified 12 anomalous observations in the 657-observation independent measured test subset. All 12 detected observations corresponded to injected ground-truth anomalies, resulting in TP = 12 and FP = 0. Eighteen of the 30 injected anomalies were not detected, resulting in FN = 18, while 627 normal observations were correctly classified, resulting in TN = 627.

The resulting test-set performance was Accuracy = 97.26%, Precision = 100.00%, Recall = 40.00%, and F1-score = 57.14%. The perfect precision indicates that the selected threshold produced no false-positive detections, whereas the comparatively lower recall shows that the detector operated conservatively and failed to identify 18 of the 30 controlled anomaly events. Therefore, the corrected evaluation demonstrates strong specificity but limited anomaly sensitivity under the selected threshold (see Table 2).

Table 2

ModelMAE (kW)RMSE (kW)MAPE (%)R2
Random forest0.1770.2482.3100.986
ARIMAX(3,0,0)0.2700.3723.3520.967
Residual LSTM0.268 ± 0.0420.336 ± 0.0483.423 ± 0.5550.973 ± 0.007

Controlled forecasting comparison on the independent measured test subset.

Figure 4 visualizes the reconstruction-error sequence, the fixed validation-derived threshold, the detected events, and the injected ground-truth anomalies. The controlled anomaly-injection configuration and quantitative test results are summarized in Table 3. The per-category results indicate which anomaly types were reliably separated by the reconstruction-error threshold and which types accounted for most false negatives. In particular, the complete failure to detect level-shift anomalies indicates that moderate multiplicative deviations can remain close to the learned two-dimensional active/reactive-power manifold and therefore may not generate sufficiently large reconstruction errors.

Table 3

A. Dataset composition
SubsetObservationsInjected anomaliesNormal observationsPurpose
Validation65736621Threshold calibration
Test65730627Independent evaluation
Total1,314661,248—
B. Injected anomaly types
Anomaly typeTransformationTotal number
Abrupt drop20
Spike16
Level shift15
Zero consumption15
Total—66
C. Independent test-set detection performance
MetricValue
Selected validation percentile97.5th
Reconstruction-error threshold τ0.0006246842
Ground-truth test anomalies30
Detected anomalies12
True positives (TP)12
False positives (FP)0
False negatives (FN)18
True negatives (TN)627
Accuracy97.26%
Precision100.00%
Recall40.00%
F1-score57.14%
D. Detection performance by anomaly type
Anomaly typeInjectedDetectedMissedRecall (%)
Abrupt drop65183.33
Spike81712.50
Level shift7070.00
Zero consumption96366.67
Total30121840.00
E. Binary confusion matrix on the independent test subset
Ground-truth classPredicted normalPredicted anomalyTotal
Normal627 (TN)0 (FP)627
Anomaly18 (FN)12 (TP)30
Total64512657
F. Controlled comparison with baseline anomaly-detection models
MethodAccuracyPrecisionRecallF1TPFPFNTN
Autoencoder97.26%100.00%40.00%57.14%12018627
Isolation forest93.15%25.81%26.67%26.23%82322604
One-class SVM97.87%100.00%53.33%69.57%16014627

Controlled anomaly-injection protocol, validation-based threshold selection, and quantitative anomaly-detection performance on the independent 657-observation measured test subset.

The per-anomaly-type analysis revealed substantial differences in detection sensitivity. Abrupt-drop events were detected most reliably, with 5 of 6 events identified (recall = 83.33%). Zero-consumption anomalies achieved a recall of 66.67%, with 6 of 9 events detected. In contrast, only 1 of 8 spike events was detected (recall = 12.50%), while none of the 7 level-shift events exceeded the reconstruction-error threshold (recall = 0.00%). These results indicate that the current two-variable autoencoder is considerably more sensitive to abrupt reductions and zero-consumption events than to positive spikes and moderate level shifts.

Because the autoencoder performs binary anomaly detection rather than multiclass anomaly-type classification, type-specific precision and F1-score are not formally defined for the present detector. The predicted output distinguishes only normal from anomalous observations and does not assign a predicted anomaly category. Therefore, anomaly-type-specific recall is reported to quantify the detector sensitivity to each controlled anomaly category, while precision and F1-score are reported for the overall binary anomaly-detection task.

The corresponding binary confusion matrix contained 627 true negatives, 12 true positives, 18 false negatives, and no false-positive classifications, confirming that the selected threshold provided high specificity but limited sensitivity to controlled anomalies.

4.3.1 Baseline comparison

To contextualize the autoencoder performance, Isolation Forest and One-Class SVM were evaluated under the same controlled anomaly-detection protocol. All three methods used the same Min–Max-scaled Total Active Power and Total Reactive Power inputs, the same measured training, validation, and independent 657-observation test subsets, and identical controlled anomaly labels. Hyperparameters and anomaly-score thresholds were selected exclusively using the validation subset, after which the selected configurations were frozen for independent test evaluation.

Isolation Forest achieved an accuracy of 93.15%, precision of 25.81%, recall of 26.67%, and F1-score of 26.23%, with TP = 8, FP = 23, FN = 22, and TN = 604. One-Class SVM achieved an accuracy of 97.87%, precision of 100.00%, recall of 53.33%, and F1-score of 69.57%, with TP = 16, FP = 0, FN = 14, and TN = 627. By comparison, the autoencoder achieved an accuracy of 97.26%, precision of 100.00%, recall of 40.00%, and F1-score of 57.14%.

Under the present controlled protocol, One-Class SVM therefore achieved the highest F1-score and recall while maintaining zero false-positive detections. Isolation Forest showed substantially lower precision and F1-score because of a larger number of false-positive detections. However, all three methods showed limited sensitivity to spike and level-shift anomalies, indicating that the present two-variable active/reactive-power representation remains a limiting factor.

4.4 Integration ablation: effect of anomaly handling on forecasting

To quantify the practical benefit of connecting the anomaly-detection and forecasting modules, the residual LSTM was evaluated under three input conditions: clean measured inputs, anomaly-corrupted inputs without filtering, and anomaly-corrupted inputs followed by detector-guided causal correction.

Controlled anomalies substantially degraded forecasting performance when they were allowed to propagate directly into the forecasting input sequence. Detector-guided correction recovered a substantial proportion of the lost forecasting accuracy, demonstrating that the anomaly-assessment layer can protect the downstream forecasting module from corrupted measurements.

However, the corrected condition did not fully recover the clean-input performance. This result is consistent with the anomaly-detection evaluation, because 18 of the 30 controlled test anomalies were not detected and therefore remained uncorrected. The ablation therefore demonstrates both the benefit and the current limitation of the integrated anomaly-detection–forecasting workflow.

The integration ablation demonstrated a substantial degradation in forecasting performance when controlled anomalies were allowed to propagate directly into the LSTM input sequence. Relative to the corrupted-input condition, detector-guided causal correction reduced MAE by 29.41%, RMSE by 42.01%, and MAPE by 25.16%, while increasing R2 from 0.574 ± 0.004 to 0.857 ± 0.008. However, the corrected condition did not fully recover the clean-input performance because 18 of the 30 controlled anomalies were not detected and therefore remained uncorrected. These results provide quantitative evidence that upstream anomaly handling can improve the robustness of downstream forecasting, while also demonstrating that the magnitude of the benefit is constrained by anomaly-detection sensitivity.

4.5 Historical illustrative MPC proof-of-concept results

The MPC component was evaluated as a simulation-level decision-support mechanism for predictive load management. Unlike the forecasting and anomaly-detection evaluations, which are linked to the measured administrative-building dataset, the MPC performance values originate from the earlier KEGOC-oriented proof-of-concept control simulation (see Table 4).

Table 4

ScenarioMAE (kW)RMSE (kW)MAPE (%)R2
Clean measured input0.221 ± 0.0330.288 ± 0.0422.767 ± 0.4100.980 ± 0.006
Controlled anomalies, no filtering0.470 ± 0.0321.345 ± 0.0075.827 ± 0.4100.574 ± 0.004
Detected anomalies + causal correction0.332 ± 0.0330.780 ± 0.0224.361 ± 0.4170.857 ± 0.008

Integration ablation evaluating the effect of anomaly handling on downstream forecasting.

The simulation examined whether predicted electricity demand could be transformed into load-management recommendations aimed at peak shaving, load redistribution, and operating-cost reduction. The reported results are summarized in Table 5.

Table 5

IndicatorBaselineMPC scenarioChange
Peak demand120 kW102 kW−15%
Average daily electricity consumption980 kWh910 kWh−7%
Estimated electricity cost100%88%−12%
Load factor0.680.81+19.1%

Historical MPC proof-of-concept simulation retained for architectural illustration.

In the historical proof-of-concept simulation, the reported peak demand decreased from 120 to 102 kW, corresponding to a 15% reduction. This result indicates that the predictive-control formulation was capable of reducing or redistributing controllable demand during high-load intervals in the proof-of-concept scenario.

Average daily electricity consumption decreased from 980 to 910 kWh, corresponding to a reported reduction of approximately 7%. The simulated electricity-cost indicator decreased from 100% of the baseline value to 88%, representing a 12% reduction.

The load factor increased from 0.68 to 0.81. The relative increase was:

The increase in load factor reflects a more uniform simulated demand profile and reduced concentration of electricity consumption during peak intervals.

Figure 5 illustrates the 24-h baseline and MPC-controlled demand profiles in the proof-of-concept simulation. The controlled trajectory reduces the two principal demand peaks and produces a smoother daily profile.

Figure 5

These results should be interpreted as simulation evidence of the potential of the MPC component rather than as direct measured energy savings from the administrative building. The MPC evaluation did not constitute physical closed-loop deployment at the monitored facility.

4.6 Component-level evaluation of the integrated framework

The experimental results demonstrate three complementary functions of the proposed architecture. First, the forecasting component provides short-term estimates of future electricity demand. Second, the anomaly-detection component evaluates whether newly received measurements are consistent with learned normal operating behavior. Third, the MPC component converts forecast information into predictive load-management recommendations.

Importantly, these three sets of results originate from different but complementary evaluation procedures. The forecasting evaluation is based on chronologically separated measured electricity-consumption data. The anomaly-detection evaluation uses controlled synthetic anomaly injection within measured validation and test subsets. The MPC evaluation represents a proof-of-concept simulation of predictive load management.

This distinction prevents simulation outcomes or synthetically generated labels from being interpreted as independently measured operational events.

The integrated computational sequence can therefore be summarized as follows: measured observations are first subjected to preprocessing and anomaly assessment; validated input data are then passed to the forecasting module; and the resulting future-load estimates can subsequently be supplied to the MPC decision-support layer.

The principal outcomes of the current evaluation are summarized in Table 6.

Table 6

StudyApplicationMain methodMain objectiveIntegration with control
Kong et al. (2019)Residential electricity demandLSTMShort-term load forecastingNo
Marino et al. (2016)Building-energy forecastingDeep neural networksLoad predictionNo
Jokar et al. (2016)Advanced metering infrastructureMachine learningElectricity-theft detectionNo
Zheng et al. (2018)Smart-meter dataDeep learningElectricity-theft detectionNo
Mohsenian-Rad et al. (2010)Smart-grid demand-side managementOptimization/game theoryLoad schedulingYes—component-level; not end-to-end experimentally validated
Proposed frameworkAdministrative-building smart meteringLSTM + autoencoder + MPCForecasting + anomaly assessment + predictive managementYes—component-level; not end-to-end experimentally validated

Contextual comparison with representative related studies.

The results therefore support the architectural feasibility of linking forecasting, anomaly assessment, and predictive optimization within a common decision-support workflow. At the same time, the evaluation design does not imply that all three components were physically deployed and simultaneously validated in a single real-time building-control experiment.

4.7 Contextual comparison with existing approaches

The proposed framework was also positioned relative to representative studies addressing electricity-load forecasting, electricity-theft or anomaly detection, and demand-side management.

Direct numerical ranking across these studies is not appropriate because the datasets, application domains, sampling intervals, forecasting horizons, preprocessing procedures, and evaluation criteria differ substantially. The comparison should therefore be interpreted primarily in terms of methodological scope.

Previous LSTM studies have demonstrated the effectiveness of recurrent models for short-term electricity-demand forecasting. Other studies have investigated deep-learning architectures for building-load prediction or machine-learning methods for identifying suspicious electricity-consumption patterns. Demand-response and optimization studies have separately demonstrated the potential of predictive and scheduling approaches for peak-demand management.

The distinguishing characteristic of the present framework is the integration of these functions within one computational architecture. The proposed workflow combines data acquisition and preprocessing, anomaly assessment, short-term load forecasting, and predictive-control decision support.

Therefore, the principal contribution should not be interpreted solely in terms of obtaining a lower forecasting error than previously published studies. The main contribution is the development of a unified software architecture in which validated measurements, anomaly-assessment outputs, forecasting results, and predictive-control functionality are logically connected within a common decision-support workflow. The present study validates these components through separate experiments rather than through a single end-to-end physical deployment.

Any numerical comparison with external studies should consequently be treated as contextual rather than as a controlled benchmark. A rigorous cross-study performance comparison would require the competing methods to be evaluated using the same dataset, identical chronological partitions, the same forecasting horizon, equivalent input features, and common performance metrics.

5 Discussion

The results of this study should be interpreted in the context of three complementary but methodologically distinct evaluation components: short-term load forecasting using chronologically separated measured data, autoencoder-based anomaly detection using controlled anomaly injection, and Model Predictive Control evaluated through a proof-of-concept simulation. This separation is important because it prevents synthetic observations, controlled anomaly labels, and simulation outputs from being interpreted as independent real-world operating measurements.

The principal contribution of the proposed framework is therefore not a single performance metric, but the integration of data validation, anomaly assessment, demand forecasting, and predictive energy-management functions within one computational workflow. Such integration addresses a limitation frequently encountered in smart-grid research, where forecasting, anomaly detection, and demand-side optimization are investigated as separate tasks.

5.1 Dataset provenance and experimental design

A major methodological aspect of the present study is the explicit distinction between measured and synthetically extended data. The complete annual dataset contains 8,760 hourly observations, but only 4,380 observations correspond to measurements obtained from the monitored administrative building. The remaining 4,380 observations form a synthetic temporal extension and were not treated as additional independent measurements.

This distinction strengthens the interpretation of the experimental results because the primary train–validation–test procedure was restricted to the measured component. In particular, 3,066 measured observations were used for training, 657 for validation, and 657 for independent testing. After application of the 24-h look-back window, the corresponding sequence counts were 3,042, 633, and 633.

Chronological partitioning is particularly important for electricity-demand forecasting because random splitting may introduce future information into the training process. By preventing sequence windows from crossing subset boundaries, the experimental procedure provides a more realistic approximation of prospective forecasting, in which a model predicts observations that were not available during model development.

The synthetic extension was maintained as a separately identified auxiliary dataset and was excluded from all primary training, validation, and independent test metrics. However, it does not provide the same evidential value as measurements collected during additional months of physical operation. Consequently, the main conclusions of the study should be based on the independently measured component.

5.2 Interpretation of the load-forecasting results

A plausible explanation is that LSTM networks explicitly process ordered sequences and can retain information from preceding time steps through their recurrent memory structure. Electricity consumption in administrative buildings is influenced by working schedules, calendar effects, temperature, and equipment-operating conditions. Such interactions may generate nonlinear temporal patterns that are difficult to represent using a purely statistical linear model.

Random Forest can capture nonlinear relationships between predictors but does not inherently represent temporal order. Its forecasting performance therefore depends on explicitly constructed lag variables. In contrast, the LSTM model processes the complete 24-h sequence directly.

These observations are consistent with previous studies demonstrating the suitability of LSTM networks for short-term electricity-load forecasting. Kong et al. (2019) reported that recurrent neural networks can capture complex residential electricity-demand patterns, while Wang et al. (2021) demonstrated the usefulness of incorporating weather-related variables into short-term load prediction. Deep neural architectures have also been successfully applied to building-energy forecasting under heterogeneous environmental and operational conditions (Marino et al., 2016).

Under the corrected final chronological protocol, the LSTM model was rerun using 3,042 training, 633 validation, and 633 independent measured test sequences. Under the final repeated-run protocol, the residual LSTM achieved a mean MAPE of 3.423 ± 0.555%, an RMSE of 0.336 ± 0.048 kW, and an R2 of 0.973 ± 0.007 across five independent initializations.

5.3 Interpretation of the controlled anomaly-detection experiment

The anomaly-detection component differs fundamentally from the forecasting experiment because verified real-world anomaly labels were not available for the complete monitoring period. Controlled synthetic anomalies were therefore introduced into measured validation and test observations to create reproducible ground-truth labels.

The evaluation dataset contains 1,314 measured observations, including 657 validation and 657 test observations. Sixty-six observations were modified, corresponding to approximately 5.02% of the complete anomaly-evaluation set. Of these, 36 anomalies were introduced into the validation subset and 30 into the independent test subset.

Four types of controlled abnormal behavior were considered: abrupt drops, spikes, level shifts, and zero-consumption events. This design makes it possible to investigate whether a reconstruction-based detector can recognize predefined deviations from normal operating patterns while preserving a clean training subset.

The principal advantage of this approach is reproducibility. Each abnormal event has an explicitly known ground-truth label and transformation rule, allowing the threshold-selection and classification procedure to be evaluated systematically.

At the same time, controlled anomaly injection represents only an approximation of operational abnormalities. Real smart-meter anomalies can involve persistent meter drift, intermittent communication errors, equipment degradation, abnormal occupancy, unauthorized consumption, sensor calibration problems, or combinations of several mechanisms. Such patterns may differ substantially from isolated multiplicative or zero-consumption perturbations.

Under the corrected evaluation protocol, the 97.5th-percentile validation-derived threshold produced 12 true-positive detections, no false-positive detections, 18 false negatives, and 627 true negatives on the independent test subset. These values correspond to an accuracy of 97.26%, precision of 100.00%, recall of 40.00%, and an F1-score of 57.14%.

The resulting performance reveals an important trade-off. The absence of false positives indicates that the detector was highly conservative and that observations classified as anomalous were strongly associated with the controlled ground-truth events. However, a recall of 40.00% means that 18 of the 30 injected anomalies remained below the selected reconstruction-error threshold. Therefore, high overall accuracy should not be interpreted as uniformly strong anomaly-detection performance, particularly because normal observations substantially outnumber anomalous observations. Precision, recall, and F1-score provide a more informative characterization of detector behavior in this imbalanced setting.

These findings suggest that future work should investigate adaptive thresholds, anomaly-type-specific thresholds, temporal reconstruction models, and alternative architectures capable of improving sensitivity while maintaining the low false-positive rate observed in the present experiment.

Autoencoders remain well suited to this application because they can learn the structure of normal observations without requiring a large collection of labeled abnormal examples. Similar motivations have been discussed in previous electricity-theft and anomaly-detection studies, where verified abnormal events are often sparse or difficult to acquire (Jokar et al., 2016; Zheng et al., 2018).

Future validation should replace or complement controlled anomalies with independently verified meter alarms, maintenance records, confirmed equipment failures, and other operational events.

5.4 Interpretation of the MPC proof-of-concept simulation

The MPC component should be interpreted separately from the measured-building forecasting experiment. The reported control values originate from an earlier proof-of-concept simulation and do not represent physically measured before-and-after consumption at the administrative building.

Within this simulation scenario, peak demand decreased from 120 to 102 kW, representing a 15% reduction. The load factor increased from 0.68 to 0.81, corresponding to a relative improvement of approximately 19.1%. Estimated electricity cost decreased by 12%.

These results illustrate the potential value of combining short-term forecasting with receding-horizon control. Instead of responding only after a high-demand condition has occurred, MPC can use forecasts of future consumption to identify periods in which flexible demand should be shifted, reduced, or rescheduled.

Such predictive behavior is consistent with the general principles of demand-side management and Model Predictive Control. Previous studies have shown that demand-response strategies can reduce peaks and improve utilization of electricity infrastructure (Mohsenian-Rad et al., 2010; Palensky and Dietrich, 2011).

The reported 7% reduction in average daily energy consumption requires a more cautious interpretation. Pure load shifting changes the temporal distribution of demand but should not substantially change total energy consumption. A genuine energy reduction can occur only if the control action includes curtailment, reduced equipment operating time, altered temperature or equipment set points, elimination of inefficient operation, or another mechanism that reduces total consumption.

For this reason, the 7% energy-reduction value should be described exclusively as an outcome of the earlier proof-of-concept simulation and not as experimentally verified energy savings in the monitored administrative building.

The same limitation applies to the reported cost reduction. Cost savings depend on the tariff structure used in the simulation. Because the numerical tariff parameters and complete solver configuration are not preserved in the available experimental record, the 12% value demonstrates the potential behavior of the control concept rather than a transferable economic estimate.

Future work should implement the MPC module using explicitly documented controllable loads, tariff schedules, actuator constraints, objective-function weights, and solver settings. Physical or hardware-in-the-loop validation would then make it possible to distinguish true energy savings from load shifting and tariff optimization.

5.5 Significance of the integrated framework

The main advantage of the proposed architecture is the connection of three computational functions that are commonly evaluated independently.

First, the anomaly-detection layer assesses whether incoming observations are consistent with learned normal operating behavior. Potentially unreliable measurements can therefore be flagged before they influence subsequent analytical stages.

Second, the forecasting module transforms validated historical and contextual information into estimates of future electricity demand. These forecasts provide the predictive information required for proactive energy management.

Third, the MPC layer converts future-load estimates into recommended load-management actions under operational constraints.

This sequence creates a traceable decision-support pipeline:

measurement → preprocessing → anomaly assessment → forecasting → predictive optimization → control recommendation.

Such organization is important because high forecasting accuracy alone does not guarantee effective energy management. Similarly, accurate anomaly detection has limited operational value if abnormal measurements are not incorporated into subsequent decision-making. The proposed framework provides a mechanism for connecting these analytical results.

Another benefit is system-level traceability. Even when the internal representations of neural-network models are difficult to interpret, the complete workflow can be examined through input measurements, preprocessing decisions, reconstruction-error scores, forecast trajectories, MPC objectives, operational constraints, and generated recommendations.

This property may facilitate integration with building-management systems, automated metering infrastructures, or supervisory control systems in which operators need to understand the sequence of events leading to a particular recommendation.

However, the present study demonstrates computational integration rather than a fully deployed cyber-physical control system. Real-time implementation remains necessary to evaluate latency, communication reliability, operator interaction, cybersecurity, and physical equipment responses.

5.6 Comparison with previous studies

Previous research has established the usefulness of recurrent neural networks for short-term electricity forecasting (Kong et al., 2019; Wang et al., 2021), deep neural networks for building-energy prediction (Marino et al., 2016), machine-learning approaches for electricity-theft detection (Jokar et al., 2016; Zheng et al., 2018), and optimization-based approaches for demand-side management (Mohsenian-Rad et al., 2010; Palensky and Dietrich, 2011).

The present study differs from these works primarily in scope. Rather than treating forecasting, anomaly detection, and predictive control as independent algorithms, it combines them within a common computational architecture.

Therefore, the contribution of the study should not be expressed solely as a claim that the proposed LSTM provides lower forecasting error than models reported in unrelated studies. Differences in datasets, consumer types, monitoring periods, forecasting horizons, features, and preprocessing procedures prevent such a direct comparison.

A rigorous numerical benchmark would require all competing methods to be executed on the same dataset using the same train–validation–test periods, input information, forecasting horizon, and evaluation metrics.

Accordingly, Table 7 should be treated as a contextual methodological comparison rather than as evidence of direct numerical superiority.

Table 7

ComponentEvaluation dataEvaluation designMain result/status
Dataset8,760 hourly observations4,380 measured + 4,380 synthetic extensionProvenance explicitly separated
LSTM forecastingMeasured component3,042 train/633 validation/633 independent test sequencesMAPE = 3.423 ± 0.555%; RMSE = 0.336 ± 0.048 kW; R2 = 0.973 ± 0.007
Anomaly detectionMeasured validation/test subsets66 controlled anomalies; 30 in independent testAccuracy = 97.26%; Precision = 100.00%; Recall = 40.00%; F1 = 57.14%
MPCHistorical proof-of-concept simulation24-h receding-horizon load-management scenario15% simulated peak reduction; load factor 0.68 → 0.81; 12% estimated cost reduction; not measured building-level outcomes

Summary of the revised experimental framework.

5.7 Practical implications

The proposed framework may be useful in administrative buildings, industrial facilities, residential complexes, microgrids, and other environments in which hourly or higher-frequency electricity measurements are available.

The forecasting component can provide operators with advance information about expected demand. The anomaly-detection component can indicate observations that should be inspected before they are used for automated decisions. The predictive-control component can subsequently use validated forecasts to recommend load shifting, peak shaving, or scheduling actions.

In an operational implementation, the MPC module could interact with heating, ventilation, and air-conditioning systems, energy-storage devices, electric-vehicle charging, auxiliary equipment, or other flexible loads. However, each application would require explicit constraints describing equipment capacity, minimum operating times, safety restrictions, occupant-comfort requirements, and permissible switching frequencies.

The multilayer architecture also supports distributed implementation. Time-critical preprocessing and anomaly checks may be executed at an edge gateway, while long-term storage, model retraining, and computationally intensive analysis may be performed in a centralized or cloud environment.

Nevertheless, these deployment possibilities remain architectural implications rather than experimentally validated properties of the current study.

5.8 Limitations and future research

Several limitations define the scope of the present findings.

First, the independently measured data were obtained from a single administrative building and cover approximately 6 months. The second half of the annual dataset is a synthetic temporal extension and cannot be considered equivalent to independent real-world measurements.

The present empirical results therefore demonstrate within-site temporal generalization rather than cross-building generalization. All independently measured training, validation, and test observations originate from the same administrative building. Consequently, the reported forecasting and controlled-anomaly results should not be assumed to transfer directly to buildings with different occupancy profiles, HVAC configurations, electrical-load compositions, climatic conditions, or operating schedules. External validation using independent buildings and publicly available benchmark datasets is required before broader generalization claims can be supported.

Second, the corrected primary forecasting evaluation is based on a comparatively short measured test interval. This test period is sufficient for one-step-ahead short-term forecasting evaluation but does not support independent seasonal validation. Additional measured data covering complete annual and multi-year periods are required to evaluate seasonal generalization.

Under the final repeated-run protocol, the residual LSTM achieved a mean MAPE of 3.423 ± 0.555%, an RMSE of 0.336 ± 0.048 kW, and an R2 of 0.973 ± 0.007 across five independent initializations.

Fourth, anomaly detection was evaluated using controlled synthetic anomaly injection rather than a dataset of independently verified operational failures. The experiment therefore evaluates detection of predefined abnormal patterns and should not be interpreted as proof of equivalent performance for electricity theft, meter failures, or equipment degradation.

Fifth, although the corrected anomaly detector produced no false-positive detections, its recall was limited to 40.00%, with 18 of the 30 controlled test anomalies remaining undetected. This indicates that the validation-selected threshold favored specificity over sensitivity. In an operational monitoring system, such missed anomalies may delay the identification of abnormal consumption or measurement faults; therefore, accuracy alone should not be interpreted as evidence of strong anomaly-detection performance. Future work should investigate adaptive or dynamic thresholding and richer anomaly representations incorporating contextual variables such as outdoor temperature, calendar characteristics, and equipment-operating status to improve recall without substantially increasing the false-positive rate.

Sixth, the MPC results originate from a proof-of-concept simulation. They do not constitute measured post-intervention electricity savings from the administrative building. Furthermore, the complete numerical MPC configuration, including objective-function weights, actuator-specific bounds, solver configuration, and tariff parameters, is not preserved in the available experimental record.

In the controlled comparison, Random Forest achieved the lowest forecasting error, while the residual LSTM and ARIMAX models produced comparable results. The repeated-run LSTM evaluation nevertheless demonstrated stable performance across multiple initializations, supporting its suitability as the forecasting component of the proposed architecture.

Finally, cybersecurity, communication latency, packet loss, privacy protection, computational delay, and real-time hardware interaction were not evaluated experimentally.

Future research should therefore collect longer real-world datasets from multiple buildings, repeat the forecasting experiment using multiple random initializations, obtain verified abnormal-event labels, compare additional forecasting and anomaly-detection architectures, document and reproduce the complete MPC configuration, and evaluate the integrated framework in hardware-in-the-loop and real-time pilot environments.

Future work should also repeat autoencoder training across multiple independent initialization seeds while keeping the controlled anomaly locations and labels fixed, thereby quantifying stochastic variability in precision, recall, and F1-score without altering the reproducibility of the ground-truth anomaly protocol.

Probabilistic forecasting, temporal convolutional networks, attention-based architectures, transformers, adaptive anomaly thresholds, variational autoencoders, robust MPC, and stochastic MPC represent particularly relevant directions for extending the present framework.

6 Conclusion

This study developed an integrated artificial intelligence-based framework for intelligent electricity monitoring and predictive energy management. The architecture combines chronological data preprocessing, LSTM-based short-term load forecasting, autoencoder-based anomaly assessment, and Model Predictive Control within a common decision-support workflow.

A 12-month hybrid hourly dataset containing 8,760 observations was considered. Importantly, the dataset comprises 4,380 measured observations and 4,380 synthetically extended observations. The measured component was used for the primary model-development and independent evaluation procedure, whereas the synthetic extension was maintained as a separately identified auxiliary component and was excluded from the primary evaluation metrics.

The measured observations were chronologically divided into 3,066 training, 657 validation, and 657 test observations. With a 24-h look-back window applied independently within each subset, the forecasting experiment contained 3,042 training, 633 validation, and 633 independent test sequences. This design prevented future observations from entering model training and established a clearly defined real-data evaluation protocol.

Under the corrected controlled forecasting protocol, Random Forest, ARIMAX, and the residual LSTM were evaluated using the same chronological measured-data partition, forecasting horizon, and independent test subset. Random Forest achieved the lowest point-estimate forecasting error on the present dataset, while the residual LSTM demonstrated stable performance across five independent initializations. Future work should extend this comparison to additional forecasting architectures, larger multi-building datasets, and repeated statistical evaluation across independent sites.

The anomaly-detection component was reformulated as a reproducible controlled experiment. Sixty-six anomalies were introduced into 1,314 measured validation and test observations, while the training subset remained free of injected anomalies. The validation subset was used exclusively for threshold calibration, and the independent test subset contained 30 controlled anomaly events. This protocol provides explicit ground truth but does not replace validation using independently verified real-world equipment faults, meter failures, or electricity-theft events.

Using the fixed validation-derived threshold, the autoencoder detected 12 of the 30 controlled anomalies in the independent test subset, yielding an accuracy of 97.26%, precision of 100.00%, recall of 40.00%, and an F1-score of 57.14%. The results indicate conservative anomaly detection with no false-positive classifications but limited sensitivity to all injected abnormal patterns.

The controlled baseline comparison further showed that One-Class SVM achieved higher recall (53.33%) and F1-score (69.57%) than the autoencoder (40.00% recall and 57.14% F1-score), demonstrating that the proposed architecture is not dependent on the autoencoder being the best-performing detector and that alternative anomaly-detection models may be substituted within the modular framework.

The MPC component demonstrated the feasibility of transforming predicted demand into proactive load-management recommendations in a proof-of-concept simulation. The earlier simulation reduced peak demand from 120 to 102 kW and increased the load factor from 0.68 to 0.81, while an estimated 12% cost reduction was reported. These values should be interpreted as simulation outcomes rather than as physically measured savings at the monitored administrative building.

The main contribution of the study is therefore the integrated computational architecture rather than any individual numerical result. The framework establishes a logical sequence in which data quality and anomaly information can be considered before forecasting, and forecasting outputs can subsequently support predictive optimization.

Future validation should include independent buildings and public benchmark datasets to determine whether the observed forecasting and anomaly-handling behavior generalizes beyond the monitored administrative facility.

Further research is required before large-scale operational deployment. In particular, the framework should be evaluated using longer multi-building datasets, verified real anomaly events, repeated model runs, fully documented MPC parameters, and real-time or hardware-in-the-loop experiments. Such validation would make it possible to quantify model uncertainty, operational robustness, actual energy savings, economic benefits, communication performance, and scalability under real smart-grid conditions.

Statements

Data availability statement

The datasets presented in this article are not readily available because the measured component contains operational electricity-consumption data obtained from the monitored administrative building and is subject to institutional and data-protection restrictions. The synthetic temporal extension and controlled anomaly-injection configuration are explicitly distinguished from the measured observations. Anonymized measured data, synthetic supporting materials, and experimental configurations may be made available upon reasonable request, subject to institutional approval and applicable data-protection requirements. Requests to access the datasets should be directed to Gulnur Massabayeva, .

Author contributions

KA: Conceptualization, Formal analysis, Investigation, Methodology, Project administration, Validation, Writing – review & editing, Supervision. GM: Conceptualization, Formal analysis, Investigation, Methodology, Writing – review & editing, Data curation, Software, Visualization, Writing – original draft. MM: Formal analysis, Investigation, Writing – review & editing, Validation. MB: Formal analysis, Investigation, Validation, Writing – review & editing, Conceptualization, Methodology, Project administration, Writing – original draft. DK: Data curation, Formal analysis, Investigation, Methodology, Software, Validation, Visualization, Writing – review & editing. TK: Data curation, Investigation, Software, Validation, Visualization, Writing – review & editing, Project administration, Writing – original draft. SB: Investigation, Validation, Writing – review & editing, Software. AB: Data curation, Investigation, Visualization, Writing – review & editing.

Funding

The author(s) declared that financial support was not received for this work and/or its publication.

Conflict of interest

The author(s) declared that this work was conducted in the absence of any commercial or financial relationships that could be construed as a potential conflict of interest.

Generative AI statement

The author(s) declared that Generative AI was not used in the creation of this manuscript.

Any alternative text (alt text) provided alongside figures in this article has been generated by Frontiers with the support of artificial intelligence and reasonable efforts have been made to ensure accuracy, including review by the authors wherever possible. If you identify any issues, please contact us.

Publisher’s note

All claims expressed in this article are solely those of the authors and do not necessarily represent those of their affiliated organizations, or those of the publisher, the editors and the reviewers. Any product that may be evaluated in this article, or claim that may be made by its manufacturer, is not guaranteed or endorsed by the publisher.

Abbreviations

AI, artificial intelligence; AMI, advanced metering infrastructure; ARIMA, autoregressive integrated moving average; F1, F1-score; GSM, global system for mobile communications; IoT, Internet of Things; LSTM, long short-term memory; LTE, long-term evolution; MAE, mean absolute error; MAPE, mean absolute percentage error; ML, machine learning; MPC, model predictive control; MQTT, message queuing telemetry transport; PLC, power line communication; R2, coefficient of determination; RF, random forest; RMSE, root mean squared error.

References

  • 1

    Al-FuqahaA.GuizaniM.MohammadiM.AledhariM.AyyashM. (2015). Internet of things: a survey on enabling technologies, protocols, and applications. IEEE Commun Surv Tutor17, 2347–2376. doi: 10.1109/COMST.2015.2444095

  • 2

    AlibekkyzyK.KomadaP.KarmenovaM.BatalovaM.RakyshevaM. (2025). Paradigms of modeling and improving the reliability of data transmission in VLC technologies. Nauk. Visnyk Natsionalnoho Hirnychoho Universytetu4, 177–184. doi: 10.33271/nvngu/2025-4/177

  • 3

    BoxG. E. P.JenkinsG. M.ReinselG. C.LjungG. M. (2015). Time Series Analysis: Forecasting and Control. 5th Edn Hoboken, NJ: John Wiley & Sons.

  • 4

    CaiY.LiaoD.LiuB. (2026). Explainable smart-building energy consumption forecasting and anomaly diagnosis framework based on multi-head transformer and dual-stream detection. Appl. Sci.16:3836. doi: 10.3390/app16083836

  • 5

    CamachoE. F.BordonsC. (2007). Model Predictive Control. London: Springer.

  • 6

    ChenT.GuestrinC. (2016) “XGBoost: a scalable tree boosting system,” in Proceedings of the 22nd ACM SIGKDD international conference on knowledge discovery and data miningSan Francisco, CAACM785–794

  • 7

    DengR.YangZ.ChowM.-Y.ChenJ. (2015). A survey on demand response in smart grids: mathematical models and approaches. IEEE Trans. Ind. Inform.11, 570–582. doi: 10.1109/TII.2015.2414719

  • 8

    FangX.MisraS.XueG.YangD. (2012). Smart grid—the new and improved power grid: a survey. IEEE Commun Surv Tutor14, 944–980. doi: 10.1109/SURV.2011.101911.00087

  • 9

    GungorV. C.SahinD.KocakT.ErgutS.BuccellaC.CecatiC.et al. (2011). Smart grid technologies: communication technologies and standards. IEEE Trans. Ind. Inform.7, 529–539. doi: 10.1109/TII.2011.2166794

  • 10

    JokarP.ArianpooN.LeungV. C. M. (2016). Electricity theft detection in AMI using customers’ consumption patterns. IEEE Trans. Smart Grid7, 216–226. doi: 10.1109/TSG.2015.2425222

  • 11

    KeribayevaT.KoshekovK.AlibekkyzyK.KoshekovA.IvanovaM. (2025). Modeling obstacle avoidance strategies in UAV groups. Nauk. Visnyk Natsionalnoho Hirnychoho Universytetu2, 206–213. doi: 10.33271/nvngu/2025-2/206

  • 12

    KongW.DongZ. Y.JiaY.HillD. J.XuY.ZhangY. (2019). Short-term residential load forecasting based on LSTM recurrent neural network. IEEE Trans. Smart Grid10, 841–851. doi: 10.1109/TSG.2017.2753802

  • 13

    MadiyarovM.TukushovaA.BazarovaM.MukhamediyevG. (2026). Designing the architecture of a cloud-based software as a service for air-quality monitoring and forecasting. Eng. Sci.40:2150. doi: 10.30919/es2150

  • 14

    MarinoD. L.AmarasingheK.ManicM. (2016) “Building energy load forecasting using deep neural networks,” in IECON 2016—42nd annual conference of the IEEE industrial electronics societyFlorenceIEEE7046–7051

  • 15

    Mohsenian-RadA.-H.WongV. W. S.JatskevichJ.SchoberR.Leon-GarciaA. (2010). Autonomous demand-side management based on game-theoretic energy consumption scheduling for the future smart grid. IEEE Trans. Smart Grid1, 320–331. doi: 10.1109/TSG.2010.2089069

  • 16

    PalenskyP.DietrichD. (2011). Demand side management: demand response, intelligent energy systems, and smart loads. IEEE Trans. Ind. Inform.7, 381–388. doi: 10.1109/TII.2011.2158841

  • 17

    ShvetsO.NaizabayevaA.SeebauerM.ToleugazinA. (2023). Monitoring and control of energy consumption systems, using neural networks. Acta Polytech. Hung.20, 125–144. doi: 10.12700/APH.20.2.2023.2.7

  • 18

    SianoP. (2014). Demand response and smart grids—a survey. Renew. Sust. Energ. Rev.30, 461–478. doi: 10.1016/j.rser.2013.10.022

  • 19

    TaoF.ZhangH.LiuA.NeeA. Y. C. (2019). Digital twin in industry: state-of-the-art. IEEE Trans. Ind. Inform.15, 2405–2415. doi: 10.1109/TII.2018.2873186

  • 20

    WangY.ZhangN.ChenX. (2021). A short-term residential load forecasting model based on LSTM recurrent neural network considering weather features. Energies14:2737. doi: 10.3390/en14102737

  • 21

    WuY.SunW.LiQ. (2025). Power load forecasting and anomaly detection using a two-stage attention mechanism and deep neural networks. Electr. Power Syst. Res.249:112056. doi: 10.1016/j.epsr.2025.112056

  • 22

    ZhengZ.YangY.NiuX.DaiH.-N.ZhouY. (2018). Wide and deep convolutional neural networks for electricity-theft detection to secure smart grids. IEEE Trans. Ind. Inform.14, 1606–1615. doi: 10.1109/TII.2017.2785963

Summary

Keywords

anomaly detection, autoencoder, intelligent energy management, load forecasting, LSTM, model predictive control, smart grid, smart metering

Citation

Alibekkyzy K, Massabayeva G, Majka M, Bazarova M, Kaliyev D, Keribayeva T, Belginova S and Bugubayeva A (2026) An integrated AI-based software architecture for load forecasting, controlled anomaly detection, and predictive energy management. Front. Comput. Sci. 8:1972880. doi: 10.3389/fcomp.2026.1972880

Received

19 August 2026

Revised

22 September 2026

Accepted

25 September 2026

Published

15 October 2026

Volume

8 - 2026

Edited by

Guiming Luo, Tsinghua University, China

Reviewed by

Namdeo Badhe, Thakur College of Engineering and Technology, India

P. Ashok, Symbiosis International Deemed University, India

Omar Munoz, Autonomous University of Baja California, Mexico

Updates

Copyright

*Correspondence: Gulnur Massabayeva, ; Madina Bazarova, ; Daniyar Kaliyev, ; Talshyn Keribayeva,

Disclaimer

All claims expressed in this article are solely those of the authors and do not necessarily represent those of their affiliated organizations, or those of the publisher, the editors and the reviewers. Any product that may be evaluated in this article or claim that may be made by its manufacturer is not guaranteed or endorsed by the publisher.

Outline

Figures

Cite article

Copy to clipboard


Export citation file


Share article

Article metrics