{'fraction_non_alphanumeric': 0.028635034266008993, 'fraction_numerical': 0.008642891440045397, 'mean_word_length': 5.541761850371216, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Anomaly detection of energy consumption in buildings: A review, current trends and new perspectives

Enormous amounts of data are being produced everyday by submeters and smart sensors installed in different kinds of buildings. If leveraged properly, that data could assist end-users, energy producers and utility companies in detecting anomalous power consumption and understanding the causes of each anomaly. Therefore, anomaly detection could stop a minor problem to become widespread, costly and time-consuming issue. Moreover, this will help in better decision-making to reduce wasted energy and promote sustainable and energy efficiency behavior. In this regard, this paper is proposed to indepthly review existing frameworks of anomaly detection in power consumption and provide a critical analysis of existing solutions. Specifically, a comprehensive survey is introduced, in which a novel taxonomy is introduced to classify existing algorithms based on different factors adopted in their implementation, such as the machine learning algorithm, feature extraction approach, detection level, computing platform, application scenario and privacy preservation. To the best of the authors' knowledge, this is the first review article that discusses the anomaly detection in building energy consumption. Moving forward, important findings along with domain-specific problems, difficulties and challenges that remain unresolved are thoroughly discussed, including the absence of: (i) precise definitions of anomalous power consumptions, (ii) annotated datasets, (iii) unified metrics to assess the performance of existing solutions, and (iv) platforms for reproducibility. Following, insights about current research trends that anomaly detection technology needs to target for widespreading its application and facilitate its implementation are described before deriving a set of challenging future directions attracting significant research and development attention.

Climate change is an essential preoccupation for the world's population. Almost 80% of the overall world energy is produced by fossil fuels. In addition to find green energy sources, it is of utmost importance to diminish the total energy consumption percentage [1]. A significant approach into achieving this objective is through informing end-users of their power usage patterns. Accordingly, consumers can improve their behaviors and change their consumption habits with the aim of reducing wasted energy and contributing in the promotion of sustainable and green energy ecosystems [2,3]. In this line, governments around the world have realized the importance of energy efficiency and the major role that can play end-users to curtail the entire expenditure on energy [4].
On the other side, the building sector represents a major energy consumer across the world. Specifically, buildings are responsible of more than 40% of the overall energy generated globally, which is converted to more than 30% of the entire worldwide CO 2 emission [5,6]. As such, the reduction of power consumption in the building environments could absolutely support the urgently-needed diminutions in the world-wide power consumption and the related environmental interests. Nevertheless, reducing power consumption in buildings is not straightforward and is a challenging task since each building needs energy for serving their various purposes [7,8]. Even though there is an increasing interest towards developing zero-energy buildings, related ideas are only in their early stage and are just tested in a limited regions of developed countries, probably much more time is still required to see them in practice across the world. In this context, the potential option available currently is to promote energy awareness and optimize the operation of appliances used inside buildings, giving that the latter are rigorously built to consume the amount of energy needed for their expected aims, i.e. preventing energy waste [9,10]. According to recent studies, people could spend up to 80-90 % of their time in indoor environments (and could be more in some unexpected circumstances, such as the current situation due to the COVID-19 pandemic), which can impact enormously their energy consumption levels, especially if they show important negligence and carelessness [11,12].
Efficient feedback could help in reducing energy consumption in buildings and lessening CO 2 emissions. Accordingly, offering updated information and personalized recommendations to end-users and building managers is the initial stage towards setting innovative approaches to optimize energy usage [13,14]. In addition, for effective power usage, anomalous consumption behaviors must be captured [15]. Therefore, via implementing energy monitoring systems and benchmarking strategies, abnormal behaviors and footprints should be changed/removed. Consequently, smart anomaly detection techniques in energy consumption should be formulated for identifying new forms of abnormal consumption behaviors [16]. In buildings, an anomalous behavior of an electrical device or of the end-user could occur either because of a faulty operation of a device, end-user negligence (e.g. cold loss in a room by keeping a window open while the air conditioner is on or refrigerant loss in a fridge via maintaining the fridge door open), a theft attack, a non-technical loss, etc. [17,18]. An occurrence of anomalous behavior could lead to higher power consumption, longer operation-time than its normal behavior/operation-time and/or could result in a permanent malfunction of the device [19].
It has been demonstrated in various research works that it should be possible to utilize artificial intelligence for detecting anomalous energy consumption behaviors either generated by end-users, appliances' failure, or other potential causes [8,20]. The artificial intelligence community has hardly worked during the past decade on how to make detection of abnormal power consumption accurate and speedy, however, it is also of significant importance to detect when an appliance is not working appropriately and what are the reasons. This makes anomaly detection in energy consumption very different form other application scenarios (e.g. intrusion detection, healthcare anomaly detection, etc.) [21]. This is because detecting anomalous consumption should be followed by triggering a set of tailored recommendations to help end-users adjust their energy consumption habits; change faulty appliances; identify cyber attackers on energy infrastructures and carry on legal procedures; and take other measures related to end-users' negligence (e.g. close refrigerator door, close door and windows while an air conditioner is working, etc.) [22]. Such measures could be very useful in different ways since they result in high energy cost savings, and could further prevent different kind of disasters (e.g. a house fire).
Efficient energy saving systems based on anomaly detection schemes need to address various issues before reaching a wider adoption. Among the challenges is how to design scalable and low cost solutions while preserving expected features of decentralization and security. Other current issues are mainly related to privacy preservation, consumer anonymity, and the real-time implementation of anomaly detection based systems. A significant effort has been put in recent years to innovate anomaly detection strategies, a large amount of projects and frameworks are ongoing, which have been described in scientific journal articles, patents, reports and industrial white papers and produced principally by the academic community and industrial partners. However, we assert a systemic and comprehensive review conducted based on different sources is still required to investigate the challenges, issues and future perspectives of the applicability of machine learning for anomaly detection in energy consumption. In this context, this framework strives to fill that knowledge gap via proposing, to the best of the authors' knowledge, the first, extensive and timely survey of anomaly detection of energy consumption in buildings. Explicitly, with the aim of laying the foundation for this effort, the following contributions have been proposed: • First, we present an overview of existing anomaly detection schemes in building energy consumption, in which a genuine taxonomy is adopted to classify them into various categories based on the nature of machine learning model used to identify the anomalies, feature extraction, detection level, computing platform , application scenario and privacy preservation. In addition, we discuss various system architectures and associated modules determining the technical properties of anomaly detection systems. A considerable part of current knowledge on anomaly detection in energy consumption arises not just from conventional academic sources (i.e. journal articles and conference proceedings), but also from industrial outputs, granted patents, and whited papers. We focus in the first part of this framework on distilling valuable information from the aforementioned sources in order to allow the readers comprehending the technical challenges of energy consumption anomaly detection. More specifically, the advantages and limitations of every category is discussed thoroughly along with its competence in different use scenarios.
• Next, we perform a critical analysis and describe the important findings by conducting an in-depth discussion of the presented state-of-the-art. We explore current difficulties and limitations issues associated with the development and implementation of the anomaly detection systems, in addition to their market barriers.
• Third, we describe current trends and identify new challenges concerning the enrichment of anomaly detection schemes with new applications and functionalities that could impact positively the energy consumption in buildings, among them considering additional sources of data (e.g. occupancy patterns, ambient conditions, etc.), combining other technologies (i.g. non-intrusive load monitoring), collecting annotated datasets and using unified assessment metrics.
• Finally, we derive a set of future research directions that require greater emphasis with regard to four aspects, in order to: (i) overcome the actual drawbacks of anomaly detection algorithms, (ii) improve the exploitation of anomaly detection solutions for better energy saving ecosystems, (iii) improve the deployment of innovative anomaly detection systems in real-world scenarios, and (iv) preserving the privacy of end-users.
The remainder of this paper is organized as follows. An overview of state-of-the-art anomaly detection techniques in building energy consumption is presented in Section 2, where an exhaustive taxonomy is proposed with reference to various perspectives. Furthermore, their limitations and drawbacks are highlighted. Moving forward, critical analysis and discussion are presented in Section 3 as a result of the conducted overview, in which difficulties, limitations and market barriers are described. Following, Section 4 is divided into two parts, in which Section 4.1 is reserved to describing open research challenges regarding novel applications and functionalities of anomaly detection methods. While, Section 4.2 provides a set of insight perspectives and explicit emerging ideas for improving future anomaly detection systems. Finally, Section 5 derives relevant concluding remarks.
2 Overview of anomaly detection methods

Overview
This section describes existing anomaly detection methods based on the nature of implemented algorithms used to detect anomalies. Fig. 1 illustrates the proposed taxonomy of anomaly detection techniques in building energy consumption.

Unsupervised detection (U)
It aims at detecting formerly unknown rare consumption observations or patterns without using any a priori knowledge of these observations. Generally, this kind of detection assumes that the amount of anomaly patterns to the overall consumption data is small, i.e. less than 20%. Because the abnormalities represent the outliers that are unknown to the consumer at training stage, detecting anomalous consumption is reduced to the modeling of normal consumption behavior in the large majority of cases, in addition to the definition of specific measurements in this space with the aim of classifying consumption observations as abnormal or normal. Unsupervised techniques are mainly built on clustering, one-class learning and dimensionality reduction algorithms.
U1. Clustering: it is a machine learning scheme used to split power consumption data into various clusters and hence helps in classifying them into normal or abnormal in unlabelled datasets (even with many dimensions). This anomaly detection strategy has attracted a lot of interest in different research topics for its simplicity, such as intrusion detection in networks [23], Internet of things (IoT) [24], sensor networks [25], suspicious behavior detection in video surveillance [26], anomalous transaction detection in banking systems [27] and suspicious account detection in online social networks [28]. In addition clustering has the capability for learning and detecting anomalies from the power consumption time-series without explicit descriptions [29].
Aiming at distinguishing between actual anomalies and genuine changes due to seasonal variations, the authors in [30] propose a two-step clustering algorithm. In the first step, an anomaly score pertaining to each user is periodically evaluated by just considering his energy consumption and its variations in the past, whilst this score is adjusted in the second step by taking into account the energy consumption data in the neighborhood. In [31], the concept of "collective anomaly" is introduced, instead of the events that refer to an anomaly, to depict itemsets of events, which, depending on their patterns of appearance, might be anomalous. To achieve this, the frequent itemset mining and categorical clustering with clustering silhouette thresholding approaches were applied on sart meters data streams. In [32] an integrated scalable framework which combines clustering and classification techniques with parallel computing capabilities is adopted, by superimposing a k-means model for separating anomalous and normal events in highly coherent clusters. Moving forward, authors in paper [33] opt for time-series to investigate the anomaly detection in temporal domain, subsequently to categorizing the anomalies into amplitude and shape related-ones. A unified framework is introduced to detect both type of anomalies, by employing fuzzy C-means clustering algorithm to unveil the available normal structures within subsequences, along with a reconstruction criterion implemented to measure the dissimilarity of each subsequence to the different cluster centers. In [34], power data are processed through the mutual k-nearest neighbor (MNN) and k-means clustering algorithms to reduce the number of measurement samples, the consumption patterns are then analyzed to detect abnormal behaviors and malicious customers. Finally, entropy-based methods for anomaly detection represent another clustering category, in which a little effort has been devoted to thoroughly comprehend the detection force of using entropy-based analysis, such as [35,36].
U2. One-class Classification: also named one-class learning (OCL) relies on considering initial power consumption patterns to be parts of two groups, positive (normal) and negative (abnormal), then it attempts to design classification algorithms while the negative group can be either absent, poorly sample or unclear [37]. Accordingly, OCL is a challenging classification problem that is harder to be solved than conventional classification problems, which try to discriminate between data from two or more categories using training consumption data that pertain to all the groups [38].
Different schemes have been proposed in the literature to detect anomalous consumption footprints based on OCL.
In [39], one-class support vector machine (OCSVM) is introduced that aims to identify the smallest hypersphere encompassing all the power observations. In [40], a kernel based one-class neural network (OCNN) is proposed to detect abnormal power consumption. It merges the capability of deep neural networks (DNN) to derive progressive rich representations of power signals with OCL aiming at building a tight envelope surrounding normal power consumption patterns. In [41,42], two different approaches of one-class convolutional neural network (OCCNN) are proposed. They share the same idea of using a zero centered Gaussian noise in the latent space as the pseudo-negative class and training the model based on the cross-entropy loss to learn an accurate representation along with the decision boundary for the considered class. One-class random forest (OCRF) is also proposed to identify abnormal consumption when labeled data are absent [43,44], it is based on using classifier ensemble randomization fundamentals [45]. U3. Dimensionality reduction: in different machine learning applications, dimensionality reduction could be used as a classification approach with a low computational cost because it has the particularity of removing irrelevant power patterns and redundancy [46]. Various techniques are explored to classify power data as normal or abnormal, such as principal component analysis (PCA), linear discriminant analysis (LDA) [47], quadratic discriminant analysis (QDA) [48] and multiple discriminant analysis (MDA) [49].
In [50], PCA that is based on Karhunen-Loeve transform is used to detect anomalous power consumption. It relies on estimating principal components of every consumption category and then creates a classifier via projecting power patterns on the subsets distributed by those principal components related to the two main categories (i.e. normal and abnormal). In [51], LDA is used to classify power consumption patterns by discriminating between separated sub-categories and design a model to automatically labeling power consumption patterns with reference to their corresponding categories. This has been accomplished via the use of discriminant weights to separate the hyperplanes generated by the LDA statistical learning. In [52,53], QDA that is a variant of LDA is deployed to enable a non-linear separation of power consumption patterns pertaining to both normal and abnormal ensembles. Finally, MDA is mainly used to build discriminant axes (functions) from linear combinations of the initial power consumption data. Every axis is designed to maximize the difference between normal and abnormal categories while considering them uncorrelated [53,54].

Supervised detection (S)
Supervised anomaly detection in energy consumption necessitates to train the machine learning classifiers (binary or multi-class) using annotated datasets, where both normal and abnormal power consumption are labeled. Although supervised anomaly detection can achieve high identification results as demonstrated in academic frameworks, its adoption in real-world is still limited compared to unsupervised methods, due to the absence of power consumption annotated datasets. Fig. 2 illustrates the main steps to conduct a supervised anomaly detection approach. S1. Deep learning: deep abnormality detection (DAD) refers to learning normal and abnormal consumption patterns using deep neural networks (DNN) models. DAD has been used in various research topics, such as detecting fraudulent health-care transactions [40], identifying abnormalities in video streaming [55] and detecting credit card frauds [56]. However, the performance of a DAD based solutions could be sub-optimal in some cases owing to the imbalance property of power consumption datasets (power consumption patterns are not uniformly distributed over the normal and abnormal categories).
In [57,58], autoencoder and long short-term memory (LSTM) neural networks are merged to identify abnormalities in unbalanced and temporally correlated power consumption datasets. Similarly, in [59], the authors detect anomalies in time-series power footprints using variational recurrent autoencoder. Moving forward, Yuan et Jia [60] use stacked sparse autoencoder for extracting high-level representations from large-scale power consumption datasets gleaned using and IoT-based metering network. Next, they utilize softmax in the classification stage to capture the consumption anomalies before sending notifications and alerts to end-users using web applications.
On the other side, convolutional neural network (CNN) has demonstrated its effectiveness in different research applications, and it has superior performance in comparison with artificial neural network (ANN) algorithms for detecting abnormalities in time-series data [61]. In [62], the author opt for combining CNN and random forest to track energy consumption anomalies due to energy theft attacks and thereby helping energy providers to remedy the issues related to irregular energy usage and inefficient electricity inspection. Looking for the same purpose, Zheng et al. [63] propose a CNN-based solution, which helps mainly in identifying the non-periodicity of energy theft and periodicity of normal energy consumptions using 2D representations of power consumption signals. Using the same idea, a CNN is developed in [64] via representing time-series time/frequency energy consumption signals in 2D space and then learning anomaly features using convolution. Moving forward, in [65], multi-scale convolutional recurrent encoder-decoder (MSCRED) is deployed to analyze multivariate time-series observations and detect abnormalities. In [66], a restricted Boltzmann machine (RBM) along with a deep belief network (DBN) are merged to construct a DNN-based abnormality detection framework. Explicitly, a dimensionality reduction task is performed at the two first RBM layers before being fed into a fine tuning layer including a classifier to separate anomalies from normal data.
Furthermore, looking for innovative deep learning solutions to deal with the unbalanced property of anomaly detection datasets, generative adversarial networks (GAN) is employed. In addition, it has a good capability for modeling complex and high-dimensional data of different types, including images [67], time-series [68,69] and cyber security [70]. Unfortunately, its utilization to detect anomalous power consumption in buildings is still very limited [71],.
Because recurrent neural network (RNN) is very competent in analyzing time-series data and enables to exhibiting temporal dynamic behaviors [72]. It has been used to predict the anomalies occurring during energy usage and distinguish them from deviations emerging from seasonality, weather and holiday dependencies [73,58]. For instance, in [74], an RNN based anomaly detection system is designed, which can remove seasonality and trend from power consumption patterns, resulting in a better capture of the real abnormalities. In [75], the authors concentrates on elaborating an abnormality detection scheme having the ability to face the concept drift, due to family structure changes (e.g. a household turned to a second family residence). To that end, an LSTM based RNN model is developed to profiling and forecasting end-users' consumption behaviors using their recent/past consumption data. In [76], abnormal days illustrates suspicious consumption rates are identified using a hybrid learning model based on RNN and K-means. Similarly in [77], a hybrid model using RNN and quantile regression is introduced to predict and detect anomalous power consumption.
On the other hand, in order to provide the reader with more details on the use of deep learning for anomaly detection in energy consumption, Fig. 3 illustrates a flowchart of a supervised anomaly detection scheme proposed in the (EM) 3 project, which is performed using a DNN model [18]. In this framework, power consumption data of various appliances and occupancy patterns are gleaned using submeters and smart sensors. Next, collected data are labeled using a micro-moments paradigm, in which consumption footprints are divided into five consumption categories. Following, a DNN model is designed and train using the labeled dataset before testing it on new recorded, unlabeled data in the test stage.
S2. Artificial neural networks: using ANN for anomaly detection in energy consumption is mainly supported by its capability to learn and generalize from past consumption data to identify normal and abnormal behavior [78]. In addition, ANN could help in solving the anomaly detection issue when recorded data are noisy due to various reasons, e.g. noise generated during data transmission or from electrical appliances connected to the smart grid [79]. In [80], the identification of power consumption anomaly is handled by resorting to a multi-stage ANN-based solution. This latter incorporates a discrete wavelet transform to obtain the required features, a variance fractal dimension (VFD) operation applied on those features, an ANN scheme which exploits the VFD output to perform the training, and finally a threshold-based detection of the anomalous power consumption pattern. The work in [81] proposes a residential framework comprising a dual hybrid one-step-ahead load predictor and a rule-engine-based energy consumption abnormality detector. In order to attain a high anomaly detection precision in linear and nonlinear regression, the predictor merges the benefits of ANN and autoregressive integrated moving average (ARIMA) model.
Moving forward, the consumption anomalies are tracked through the use of multi-layer perceptron (MLP) and classification techniques in [82]. Similarly in [83], with the aim of predicting malicious behaviour in unbalanced data, an MLP-based solution is efficiently tested on two different datasets to carry out a flow-based control which preserves the end-users' privacy. In the same direction, the continuous and fine-grained monitoring of energy consumption in industrial buildings is discussed in [84] in order to preserve their reliable operation. Explicitly, an MLP-based anomaly detection scheme is targeted via detecting sensor data abnormalities in a pharma packaging system. Moreover, intrusion detection that can be applied in energy theft tracking, is investigated in [85] by combining artificial immune network (AIN) and cosine radial basis function neural network (RBFNN), wherein firstly multiple-granularities version of the former is supported to reveal the candidate hidden neurons, and subsequently, the latter is trained based on gradient descent learning process. In addition, different power consumption anomaly detection frameworks are introduced based on extreme learning machines (ELM) [86,87]. Specifically, ELM is built upon a single-layer feed-forward neural network (SLFN) for classifying the normal and abnormal classes [88].
S3. Regression: refers to identifying the relationship between two power variable classes or more in order to produce an ensemble of model parameters to predict the generation of abnormal power observations. In this context, the production of anomalous power consumption patterns can be predicted based on other collected abnormal footprints. Various regression models have been introduced in the literature to identify abnormalities in building energy consumption, including linear regression, support vector regression (SVR), auto-regressive models, regression trees and regression fitting [89]. The authors in [90] propose to adopt linear regression-based approaches to determine the anomalous periods for individual premises, and clear them from the premise data, such that to provide precise assessments of energy consumption patterns. In the same direction, a model to find abnormal energy consumption patterns is designed in [91] by analyzing the smart meters temporal data streams. Specifically, to perform the prediction and map the non-linearity of data, support vector regression with radial basis function is retained and evaluates the disparity between the actual and the expected energy consumption.
Because of the large quantity of stored smart meter data, anomaly detection with such information brought the big data issue into focus, particularly with the scarcity of adequate and efficient real time anomaly detection systems capable of handling this huge amount of data. In order to remedy this and facilitate energy-related decision makings, the studies in [92,93] depict a scalable architecture merging an autoregressive prediction-based detection method, with a new lambda scheme to iteratively upgrade the model along with real time anomaly detection. The Work in [94] target the reduction of anomalous consumption by presenting a new scheme which enabled the identification of anomalous power consumption within large sets of data. It follows a two-stage processing, namely prediction and then anomaly detection, where, by the aid of a hybrid neural network ARIMA model of daily consumption, daily real-time consumption is first predicted in the former step, whereas a two-sigma rule was adopted to localize the anomalies via the evaluation of the mismatch between real and predicted consumption. The framework in [61] address the anomaly recognition in streaming large scale data, which is a typical occurence scanario in nowadays numerous deployed sensors. In the scope of that work, both statistical (i.e. ARIMA) and CNN based approaches were integrated in a residual way, such that the fusion was shown to compensate the weaknesses of each of them and consolidate their strengths. In [84], a data-driven approach was pursued since no cyclicity pattern was noted on the observed data. From comparing three different regressors (i.e. regression tree, random forest, and MLP) in the prediction phase, the authors highlighted the advantages of the regression trees and random forests residing in the training time efficiency and model replicability ease.
S4. Probabilistic models: are among the most important machine learning tools, they have been instituted as an effective idiom for describing the real-world problems of anomaly detection in energy consumption using randomly generated variables, such as building models represented by probabilistic relationships [95,96]. The anomaly profiles of time-series patterns are identified using Bayesian maximum likelihood models for clean data [97] and noisy data [96], while Bayesian network models are implemented to detect abnormalities categorical and mixed based power consumption data in [98,99]. In [100,101], statistical algorithms are deployed to identify the anomalies via the identification of extremes based on the standard deviation, while in [100], the authors use both statistical models and clustering schemes to detect power consumption anomalies. In [102,103], naive Bayes algorithms are proposed to detect the abnormalities generated by electricity theft attacks in electricity consumption. Similarly in [104], Janakiram et al. deploy a belief Bayesian network to capture the conditional dependencies between data and then identify the anomalies. In [105], a statistical prediction approach based on a generalized additive model is introduced to timely detect abnormal energy consumption behaviors.
S5. Traditional classification: stands for models that rely on detecting to which power consumption category (subpopulation) a new power consumption sample pertains, with reference to a training ensemble of consumption footprints that have labels of both normal and anomalous consumptions. K-nearest neighbors (KNN), support vector machine (SVM), decision tree and logistic regression are the well-known conventional classification algorithms, they have been widely deployed in the state-of-the art of the energy-based applications or other research topics.
In [100,50], KNN based heuristics are proposed to detect abnormal power consumption, while in [82], the authors investigate the performance of KNN against other machine learning classifiers to identify abnormal power observations. In [106,107], SVM is deployed to detect abnormalities due to energy theft attacks. In the same direction, in [108], a genetic SVM model is proposed to detect abnormal consumption data and suspicious customers, in which a genetic algorithm is combined with SVM. While in [109], Zhang et al. fuse SVM and particle swarm optimization for detecting abnormal power consumption in advanced metering infrastructures. On the other side, in [110], a decision tree based solution is introduced to learn energy consumption anomalies triggered by fraud energy usage. Similarly in [111], an improved decision tree model is developed to detect anomalous consumption data using densities of the anomaly and normal classes. Moving forward, in [84], a decision tree regressor is presented to detect abnormal power consumption using sensor data, while in [82], the anomalies are detected using logistic regression.

Ensemble methods (E)
As it is demonstrated in various frameworks [18,112], none of the anomaly detection schemes could identify perfectly all abnormalities through low-dimensional subspaces because of the complexity of power consumption data and other factors influencing power usage over hourly, daily, weekly, monthly or yearly scales. Accordingly, the use of ensemble learning can solve some related issues, where the initial set of power observations is split in multiple subsets and various models are applied simultaneously on these subsets to derive the potential abnormalities. Following, anomaly identification scores are either summarized or the best one is selected to come out with final score.
E1. Boosting: it is a set of meta-algorithms used to principally reduce bias and variance of unsupervised learning, in which weak classifiers (learners) are converted into strong ones. Generally, they are structured in a sequential form. A weak classifier refers to the case where a slight correlation can be achieved with the true classification [113]. Different boosting schemes are proposed in literature to detect anomalies, among them bootstrap, gradient boosting machine (GBM) and gradient tree boosting (GTB).
In [114], Zhang et al. use a bootstrap strategy to conduct an unlabeled learning process for detecting anomalies in energy data in multi-feature data. In [115] , a GBM based anomaly detection is introduced to model power usage of commercial buildings. In the same manner, in [116], a grid search is deployed to capture the best parameter configuration of a GBM based anomaly detection. While in [117], the authors predict energy frauds though the identification of power consumption anomalies using a GBM based scheme. In [118], a GTB based anomaly detection is investigated along with other data mining techniques using power consumption pricing data.
E2. Bagging: also called bootstrap-aggregating, it is a set meta-algorithms developed for improving the accuracy and stability of several weak classifiers. Bagging differs from boosting by the fact that the weak learners are structured in a parallel form [119]. Moreover, distinct detection schemes can be applied on each sub-ensemble before aggregating their results as demonstrated in [120]. Random forests, bootstrap aggregation and their variations are the well-known bagging based ensemble learning methods used for anomaly detection. For example, in [121], Araya et al. propose a bootstrap aggregation based abnormality detection scheme, which helps in conducting an ensemble learning to identify energy consumption anomalies. In [122], an isolation forest with split-selection criterion (SCiForest) algorithm is introduced to check if the end-user's electricity consumption is anomalous or normal. In [62], non-technical losses (NTLs) occurring in the energy networks are detected using a random forest scheme. This is mainly conducted through sensing anomalous power consumption and learning consumption differences for different periods (i.e. hours and days).
In [123], a random forest classifier is deployed to detect anomalies while respecting the performance measure related to the accuracy and false alarm rates. In [124], a multiview stacking ensemble (MSE) technique is proposed to learn energy consumption anomalies collected using different IoT sensors in industrial environments. In [112], an anomaly detection scheme based on feature bagging is introduced. It relies on training several classifiers on different feature sub-ensembles extracted from a main high-dimensional feature set and therefore combining the classifiers' results into a unique decision. In [125], after deriving various feature sub-ensembles randomly from the initial feature, anomalies are identified and the performance is estimated in each sub-ensemble before fusing them to come out with the final output.

Feature extraction (F)
This part mainly discusses how feature extraction scheme can help to boost the performance of anomaly detection methods via: (i) representing the power consumption observations in novel spaces ( e.g. high-dimensional spaces); (ii) utilizing appropriate measures and functions (e.g. distance, density) to discriminate between normal and abnormal consumptions, and (iii) representing the consumption flowchart using new representation structures (e.g. graph-based representation) [126].
F1. Distance-based: refers to detecting abnormal consumption patterns by judging each pattern regarding its distance to its neighboring samples. Explicitly, normal consumption observations generally possess a dense neighborhood while anomalous consumption footprints are far away form their neighboring points (i.e. show a sparse structure). Various frameworks have been proposed to resolve the issue of distance-based anomaly detection in energy consumption, where unsupervised learning methods are usually adopted without having any distributive presumptions on recorded consumption data. In this regard, in [127], a distance-based anomaly detection is proposed via analyzing the theoretical properties of the nearest neighbors of each power observation. Explicitly, anomalous patterns are then detected with reference to a global quantity named distance-to-measure. Similarly in [128], power anomalies in smart grid are detected using a multi-feature fusion that is based on Euclidean distance and a fuzzy classification approach. In [129], the authors use a cosine similarity approach to estimate similarity distance between power consumption observations and detect suspicious patterns. Following, they sort the resulted cosine distance data for identifying abnormal consumption behavior based on a threshold.
Moreover, in [130], various methods are proposed to resolve the distance-based outlier detection in data streams (DODDS) issue and their performance is compared when detecting anomalies without having any distributional assumptions on power consumption observations. In a similar way, in [131], Huo et al. develop an distance-based abnormality detection method, in which a time-space trade-off strategy has been deployed for reducing the computational cost. While in [132], a resolution-based outlier factor (ROF) method is proposed to detect anomalies in large-scale datasets. It mainly focuses on analyzing the distances of both local and global features to effectively detect anomalous data. In [133], the energy consumption anomaly detection process is performed using an isolated forest (iForest) model. The latter has been proposed by Liu et al. as a competitive method to ROF and local outlier factor (LOF) algorithms [134,45].
F2. Time-series analysis: because power consumption data are considered as time-series footprints, it is logical that many studies have focused on formulating the anomaly detection issue such as to find anomalous observations based on standard signal analysis [124]. Specifically, this kind of anomaly detection relies on detecting unexpected spikes, level shifts, drops and irregular signal forms. For example, in [135], seasonal trend decomposition using locally estimated scatterplot smoothing (LOESS) is proposed to detect anomalous consumption points, in which a seasonal-trend decomposition scheme based on LOESS is introduced. It helps in splitting the power consumption time series samples into three components defined as seasonal, trend and residue [136].
On the other side, it is worth nothing that most of the anomaly detection schemes pertaining to this class are based on a short-term time-series (STTS) analysis. In this line, a log analysis of power consumption time-series patterns is conducted in [137] to detect anomalies in early warning systems. Similarly, [138], a feature extraction based abnormality detection scheme is proposed using canonical correlation. It can help in detecting the anomalies in different kinds of buildings, such as households, work spaces and industrial zones. In [139], abnormalities occurring in smart meters data are identified using time-series analysis, in which Cook's distance is deployed over a thresholding process to decide whether an observation is normal or abnormal. In the same vein, in [140], a hierarchical feature extraction method is proposed in order to capture energy consumption anomalies in time-series consumption data due to electricity stealing. While in [141], to identify the abnormal consumption behavior, the authors analyze different STTS features that could offer valuable details about deviations from a typical behavior.
On the flip side, other techniques use rule-based algorithms to analyze time-series data and detect anomalous power consumption [142,143]. For example, in [144], Yen et al. introduce a rule-based approach to analyze the phase voltages and then decide which are the anomalous patterns using an ensemble of rules. In the same direction, in [145], a rule-based algorithm is combined with a linear programming approach to detect anomalous electricity consumption and hence identify the locations of potential energy theft attacks and/or faulty meters. In [146,147], the detection of anomalous power consumption is performed using a rule-based algorithm, which is elaborated based on machine learning methods and the knowledge of energy saving experts. Following, an ensemble of energy saving parameters is then introduced to track abnormalities. While in [148], a rule-based algorithm is combined with an improved nearest neighbor clustering approach to identify potential abnormal power consumption behaviors. In [18], a micro-moment based algorithm is proposed to detect two kinds of power consumption anomalies, which are due to (i) excessive power consumption, and (ii) consumption while the end-users are outside. The latter is responsible of wasting a large amount of energy for a set of appliances, such as the air conditioner, heating system, fan, light lamp and desktop/laptop.
F3. Density-based: refers to anomaly detection methods that investigate the density of each power consumption pattern and those of its neighborhood. Moving forward, a power observation is considered as anomalous if it has a lower density compared to its neighbors [149]. Various techniques have been proposed in this regard; among them LOF that attempts to derive a peripheral observation by using density of its surrounding space [150]; cluster-based local outlier factor (CBLOF) that relies on detecting the anomalies using the size of its power consumption clusters, and the density between each power observation and its closest cluster [151]; local density cluster-based outlier factor (LDCOF) that represents an improved version of CBLOF, in which it applies a local density concept when allocating anomaly scores [152]. In this context, in [153], a density-based spatial clustering of applications with noise (DBSCAN) approach is introduced to detect anomalous power consumption in a wind farm environment.
F4. Graph-based: before applying graph-based methods to detect power consumption abnormalities, consumption data should be converted into a graph-based structure. Because there is not any standard manner to model this kind of data, researchers use various schemes to design such a representation. For instance, the authors in [154,155], consider the house, power generator, electric network, rooms, and appliances as nodes; and edges stand for the existing connection between a specific room and the operation of an appliance. Following, abnormalities resulting in a structural change of the graph topology are detected, while a graph-based abnormality is defined as an unforeseen deviation to a normative pattern.
Different graph-based abnormality detection (GBAD) algorithms have been proposed [156], where abnormal observations of structural data are identified in the information representing entities, actions and relationships. In [157], the authors propose a graph-based method to discover contextual anomalies in sequential data. Explicitly, the nodes of the graph are clustered into different categories, where each class includes only similar nodes. Following, anomalies are detected via checking if adjacent observations pertain to the same class or not. Similarly, in [158], a parallel graph-based outlier detection (PGBOD) technique is introduced for identifying power abnormalities, in which data are processed in parallel before extracting abnormal patterns.

Hybrid learning (H)
Annotating normal power consumption is much easier than labeling anomalous patterns, consequently, hybrid or semi-supervised anomaly detection has been adopted in several frameworks [159]. It leverages available annotated normal footprints (having labels) and pertaining to the positive class to identify abnormalities from the negative class. This is the case of deep autoencoder (DAE) architecture when it is only applied to learn normal consumption patterns (with no anomalies). Accordingly, using enough training consumption observations from the normal category, the autoencoder could generate low reconstruction errors for normal observations, over abnormal patterns [160].
In [161], a semi-supervised support vector machine (semi-SVM) based anomaly detection solution is proposed, where a small number of annotated power consumption patterns are required to train the learning model. This system can also generate alarms if suspicious consumption patterns are detected, which are different to usual energy consumption habits of the end-users. While in [162], DAE and ensemble k-nearest neighbor graphs (KNNG) are combined to develop a semi-supervised anomaly detection system, in which only normal events with their labels are used to train the learning model.

Others techniques (O)
In addition to what has been presented in the aforementioned subsections, there are other kinds of anomaly detection that are built on completely different strategies, including visualization and compressive sensing.
O1. Visualization: offers effective tools to comprehend consumption behaviors of end-users through mapping consumption footprints to visual spaces. In this line, visual experts make use of perceptual skills for helping endusers perceive and decipher their consumption patterns within data. Moreover, visualization of load usage footprints could help efficiently in detecting anomalous consumption behaviors, faulty appliances and suspicious consumption fingerprints that may be due to energy theft attacks. Accordingly, this allows end-users and energy managers to fix related issues and reduce wasted energy.
For example, in [163], the authors propose an anomaly detection framework based on providing various time series visualization schemes, which helps in analyzing and understanding the energy consumption behavior. Moreover, it enables also the visualization of resulting anomaly scores to direct the end-user/analyst to important anomalous periods. In the same way, an interactive visualization approach that helps in capturing power consumption anomalies is proposed in [164]. It focuses on analyzing and visualizing spatiotemporal consumption footprints gleaned using various streaming data sources. This method has been developed with respect to two prerequisites of real-world anomaly detection systems, which are the online monitoring and interactivity. Moving forward, an interactive dashboard is designed in [165] using an early warning application, which can automatically analyze energy consumption footprints and provide end-users with the timely abnormal consumption visualizations based on data recorded from smart meters and sensors in different buildings. While in [166], a graphical visualization tool for supporting the detection and diagnosis of power consumption abnormalities using a rule-based approach is proposed.
O2. Compressive sensing: represents a signal processing strategy for effectively analyzing and reconstructing timeseries data using their sparsity. It has been widely used in different research fields, such as facial recognition, holography and monitoring of bio-signals. In addition, compressive sensing puts all the appropriate qualities to detect anomalies in energy consumption [167]. For instance, in [168], the authors proves the relevance of applying compressive sensing in sparse anomaly detection, it relies on the fact that the number of anomalous patterns is generally smaller than the total number events. In the same direction, in [169], separable compression sensing is combined with PCA to identify anomalous power data. In [170], anomalous events in smart grid are detected using a sparse approximation paradigm.

Anomaly detection level
The anomaly detection level of power consumption data plays a major role in developing effective solutions because it describes either the level of resolution in which power anomalies have been detected and treated. Moreover, based on it, tailored recommendations could be generated to resolve the associated issues and promote energy efficiency.
L1. Aggregated level: it refers to detecting anomalous power consumption using data of the main supply in a specific building, i.e. without any information about individual consumptions of the different appliances connected to the electrical network. Although this kind of anomaly detection has been used in various works, it has the main drawback of not being able to provide the end-user with information about which appliance is responsible for a specific anomaly.
L2. Appliance level: it stands for the case where anomaly detection is performed using appliance power consumption data gathered using individual submeters. This kind of anomaly detection is widely adopted because it supports a fine-grained tracking of abnormalities occurring during the operation of each electrical device [22].

L3
. Spatio-temporal level: much attention has been devoted recently to the collection of continuous spatio-temporal power consumption patterns from different devices and sources. This affords new opportunities to timely understand consumption fingerprints in their spatio-temporal context [171,172]. Overall, detecting anomalous consumption behaviors using conventional data collection methods illustrates considerable challenges since the boundary between normal and anomalous observations is not obvious. Therefore, a straightforward solution to those challenges is to interpret consumption abnormalities in their multifaceted and spatiotemporal context. Specifically, detecting abnormal consumption related to specific hours in the day, or what are the severe days presenting anomalous consumption and how to identify them in the timestamps (weekdays, weekends, holidays, etc.) will be valuable to provide end-users with a personalized feedback to reduce their wasted energy [173,174].

Applications
The applications of anomaly detection of energy consumption in buildings are no longer limited to energy efficiency, but they are finding themselves in various novel application contexts. Explicitly, they could be used for detecting (i) abnormal consumption behaviors, (ii) faulty appliances, (iii) occupancy information, (iv) non-technical losses, and (v) at-home elderly monitoring. Fig. 4 summarizes the principal applications of anomaly detection in energy consumption.
A1. Detection of abnormal behavior of end-users: it is the main application for which anomaly detection has been proposed since the final objective is to reduce wasted energy and promote sustainable and energy efficiency behaviors [18,146]. In this context, detecting anomalous consumption behaviors of end-users allows a better and accurate assessment of power usage, which can be translated into providing them with a useful and personalized recommendations to optimize their energy consumption [175,176].
A2. Detection of faulty appliance: using various kinds of appliances at indoor environments have facilitated people's lives in a manner that everything becomes easier. However, these electrical appliances could be faulty in different ways or could suffer from inefficiencies, and hence leading to several issues, such as the events resulting in a massive energy waste and triggering electrical fires [177,178]. To that end, detecting faulty appliances and providing the end-users with customized recommendations to replace them is of significant importance for reducing the operation cost and increasing energy saving in buildings [22,145].
A3. Occupancy detection: detecting whether a building or one of its parts is occupied by the end-users is essential to allow a set of building automation tasks. Although actual tools of detecting the indoor occupancy typically need to install specialized sensors, including passive-infrared sensors (PIR), reed switches actuated by magnets, or cameras, their installation is very costly and further labor charges could be added to repair them when necessary [179,180]. Therefore, one solution to overcome the high-cost issue is to explore the aptitude of electrical sub-meters, which are installed in most of the houses around the globe to detect occupancy patterns [181,182]. For example, the authors in [183] investigate both appliance specific and aggregated load usage footprints to detect the occupancy of residents [184].
A4. Non-technical loss detection: it mainly refers to (i) detecting unintentional sub-meters' dysfunctions and electricity theft attacks attempting to bypass sub-meters; (ii) braking and/or stopping sub-meters; (iii) identifying faulty sub-meters' records; and (iv) capturing appliances having illegal connections [106,185]. Non-technical loss in energy consumption has negatively affected most of the economies over the globe [34]. For instance, more than 10% of produced energy could be lost every year in Europe due to non-technical loss and billions of dollars are lost every year because of theft energy attacks [145,186]. To that end, detecting non-technical-loss and electricity theft has been introduced as an information technology related challenge, which requires novel methods based on artificial intelligence, data mining and forecasting [102,107]. Moreover, separating between behavioral consumption anomalies, frauds and unintentional consumption deviations is reported as a current research trend to provide an accurate feedback to end-users and energy providers [117,147].
A5. At-home elderly monitoring: modern societies face significant issues with the monitoring of their elderly people at home environments [187]. This problem could have considerable social and economic effects, however, one solution to overcome it is via (i) monitoring appliance consumption of elderly people in real-time; (ii) identifying abnormal consumption behaviors that could be occurring due to some critical situations (e.g. falls); and (iii) predicting faulty operations of some appliances, which can results dangerous situations (e.g. floods or gas leaks) [188,189].

Computing platform
As presented previously, most of the anomaly detection methods have been built upon the use of machine learning techniques. However, although the use of these approaches has dived the development of anomaly detection technology, it requires serious challenges of computing resources, data processing speed and scalability. In this regard, describing and discussing available solutions used to implement anomaly detection systems is essential to understand the current challenges.
• P1. Edge computing platform: refers to distributed computational models that allow to drop the computing resources and information storage capabilities close to the end-user application, where it can directly be used, e.g. in energy consumption applications this can be done on the smart sensor platforms or smart plugs devices, as it is the case in (EM) 3 . Specifically, a smart plug is developed that incorporates different smart sensors to collect consumption and contextual data along with a micro-controller to pre-process data, segregate the main consumption signal into device specific footprints, and detect abnormal behaviors. This helps in improving output, accelerating data processing and saving bandwidth [190]. • P2. Fog computing platform: stands for decentralized computational infrastructures, where power consumption data pre-processing, computing, storage and analysis are conducted in the layer located between the data collection devices and the cloud [191]. In this line, the computational ability of the anomaly detection solution is carried out close to both the data recording devices and the cloud, in which data are produced and handled [192]. • P3. Cloud computing platform: concerns the cases when the computing and storage resources are ensured using distant servers, in which the end-users deploying the anomaly detection solutions are required to connect them through an Internet link to be able to execute the anomaly detection algorithms [101]. Put differently, the platforms used to implement these algorithms become as the access points for running the anomaly detection applications and visualize the data held by the servers. The cloud architectures are described by their flexibility, which allows the providers to constantly adjust the storage capability and computing power to the end-users' requirements [193]. • P4. Hybrid computing platform: refers to the cases where the computing power is guaranteed by various layers, including the cloud, fog and edge as explained in [194]. In this context, based on the computing requirement of the anomaly detection solution and the existing computational resources, the algorithms could be executed either in the edge and/or fog when they need a low computation cost, otherwise they could be implemented in the cloud when high computing cost is required [195,196]. Table 1, presents a comparison of several aforementioned anomaly detection frameworks in building energy consumption. They are compared with reference to various parameters, such as the (i) application scenario, (ii) category, (iii) implemented technique, (iv) learning process, (v) computing platform used (or required) to implement the anomaly detection algorithm, and (vi) privacy preservation. This helps in easily understanding the properties of each framework and difference between existing solutions. 3 Critical analysis and discussion

Discussion
Anomaly detection in building energy consumption is of paramount importance to developing powerful energy management systems, identifying energy theft attacks, inefficiencies and negligences. However, in most of the cases it is difficult to separate consumption abnormalities from the normal usage deviations occurring owing to seasonal changes and variation of personal settings (e.g. holidays, family parties, unexpected changes of due new circumstances, etc.). Moreover, one of the limitations of available anomaly detection methods is related to the fact that diverse unidentified context data, including seasonal changes, could impact the power usage of end-users in a manner to be as abnormal when existing time-series based anomaly detection techniques are used. In addition, a set of important findings can summarized as follows: • Most of existing approaches of anomaly detection in energy consumption try only to flag out power samples that are remarkably higher or lower than usual consumption footprints, as it is the case in other applications, such as bank card fraud detection, network intrusion detection and electrocardiogram anomaly detection. Unfortunately, this is not the correct case to detect anomalous power consumption because the definition of anomaly in energy consumption can be quiet different, other kinds of anomalies are available and their detection requires other information sources, e.g. occupancy patterns, appliance operation data.
• According to recent some works [22,19], using aggregated-level consumption data is not the best way to detect anomalies of energy consumption because they are general and can not give precise information of the causes of each anomaly. Therefore, using appliance-level data generated either by submeters or using non-intrusive load monitoring (NILM) systems is more appropriate since this helps in detecting the anomalies of each appliance [21,199].
• In most cases, an entire power consumption behavior is considered as anomalous and not only some power observations, which make it difficult to detect the anomalous parts. Therefore, this requires to compare current consumption footprints with past and ideal consumption cycles and not only use outlier detection algorithms, which can detection the anomalies at the sample level.
• Although unsupervised anomaly detection is easy to implement since it does not require annotated datasets to learn the anomalies, it presents serious drawbacks because it can only detect one kind of anomalies, which is related to excessive consumption. In contrast, supervised methods are not very popular as unsupervised ones because they require to use labeled datasets to learn the abnormalities. However, using methods pertaining to this category allow to detect other types of anomalies since they could be defined a priopri by human experts using training data collected from different sources, e.g. consumption footprints, occupancy patterns, indoor conditions and appliance operation parameters.
• In terms of the computing resources, most of the deep learning based anomaly detection frameworks require high-performance computing capabilities to conduct the learning process. Therefore, most of them use cloud computing to integrate and manage large datasets. While for conventional machine learning based anomaly detection, edge and fog computing have been successfully used in various frameworks.
• Privacy preservation: developing anomaly detection systems to promote energy saving in buildings is of paramount importance at all levels of the society. This can be performed using local and temporal fine-grained records of power consumption fingerprints, occupancy patterns and ambient conditions to identify abnormal and unnecessary power consumption [200]. Unfortunately, using this kind of fine-grained records enables disclosing information on the presence of the end-users based on their energy usage footprints. In this context, we have noticed that the privacy preservation has been ignored in most of the anomaly detection frameworks, only very few of them have tried to address this issue [197,198].

Difficulties and limitations
There are several common and domain-specific difficulties and limitations of anomaly detection systems in energy consumption, which hinder developing efficient solutions, make their implementation costly and limit their widespread utilization. They can be outlined in the following points: • Absence of annotated datasets: among the serious handicaps to develop and validate abnormality detection schemes is the absence of annotated datasets, which provide labels for both normal and abnormal consumptions. Most of the supervised algorithms are validated on small quantity of data, which can not be considered as comprehensive datasets and are not accessible for the energy research community. Specifically, repositories that label the events of abnormal consumption and their types almost do not exist and its creation is difficult and costly [21]. Therefore, creating various datasets for different kinds of buildings that reflect real consumption behaviors will help effectively the energy research community in testing and improving the detection of consumption abnormalities in different application scenarios [201].
• Imbalanced dataset: refers to distribution of anomalies through data calsses, i.e. anomalous data might usually be the minority amongst the overall dataset. Indeed, the anomaly data are very rare in reality, forming together with the major normal data an extreme unbalanced set. The class imbalanced characteristic of most of the anomaly detection datasets results in a suboptimality of the algorithms' performance. Therefore, to deal with this issue, some pre-processing techniques are required, among them (i) using resampling procedures to oversample the minority classes or undersample the majority classes, and (ii) generating synthetic power consumption data [18]. Moreover, in other topics, the anomaly classes are generally represented as minor classes, but in energy consumption this is not always the case, especially if a high energy wasting behavior is observed. In this regards, applying unsupervised anomaly detection methods is less efficient.
• Definition of anomalies: traditional definition of an anomaly signifies that an anomalous observation is an outlier or deviant. However, this definition could not be enough to define anomalies in energy consumption because other forms of abnormalities could exist, e.g. keeping an appliance on (i.e. air conditioner, fan, television, etc.) while end-users are outside, keeping windows and doors open when an air conditioner/heating system is switching on, which leads to a high power consumption, etc. Therefore, to efficiently detect anomalies of energy consumption, it is required to analyze not only the power consumption data but also other information sources, including the occupancy patterns, ambient conditions, outside weather footprints and appliance operation parameters.
• Sparse labels: on one hand, the labels denoting whether an instance is normal or anomalous is in many applications time-consuming and prohibitively expensive to obtain. This is especially typical for time series data, where the sampling frequency could reach 1000 Hz or the time could range over decades, generating an enormous amount of data points. On the other hand, anomalous data is often not reproducible and fully concluded in reality. For example, a failure in the electronics of a sensor would create an anomalous signal but another kind of failure may very likely cause new form of anomalous signal. In some area, anomalous instances could be fatal and hence extremely rare.
• Concept drift: this phenomenon usually occurs in time series data, where the common independent and identically distributed (i.i.d) assumption for machine learning models is often violated due to the varying latent conditions [202]. Since the observations and relations in power consumption data evolve over time, they should be analyzed near real-time, otherwise the systems implemented to analyze such data rapidly become obsolete over time [203,204]. In machine learning and data mining this phenomenon is referred to as concept drift.
• Absence of platforms to reproduce empirical results: one of the main issues of the anomaly detection in energy consumption is the absence of platforms for reproducing the results of existing solutions. This may hinder the performance comparison of existing algorithms and make it difficult to understand the state-of-the-art.
• Most of the frameworks differentiate with normal or abnormal power observations in general through separating them into two principal classes (normal and abnormal) without further details. However, in real-world scenarios, there exist different kinds of anomalous consumptions, e.g. anomalies due to excessive consumption of an appliance are different from those due to keeping a door of the refrigerator open or those due to the absence of the end-user, as it is demonstrated in [51]. In this line, without providing the end-user with the nature of anomalies and their sources, it is very difficult to trigger a behavioral change and promote energy saving.

Market barriers
The frameworks reviewed in this article show that the anomaly detection topic is a promising strategy for a large number of services and applications in the energy field. On the other hand, it is worth noting that the building energy monitoring market in general, comprises a multi-billion USD global opportunity. This market appears to be growing at a robust rate, in which the anomaly detection takes a significant part [205]. The decision making of energy saving systems in buildings depend on data, however, with the wide use of sub-meters and smart sensors, the data produced is very huge which can frequently provoke the lose or misunderstanding of relevant information. Various active energy companies and utilities actually involved in providing anomaly detection solutions, markedly illustrate the increased importance of this technology to promote energy efficiency. However, different questions still require answers before the widespread deployment of the anomaly detection technology in the energy industry.
First and foremost, anomaly detection solutions should demonstrate that they could provide the scalability, speed and privacy preservation needed for the considered application scenarios. Research efforts on distributed consensus algorithms, which are crucial to achieving these objectives, are still ongoing, however a solution that combines all desired characteristics cannot yet be achieved without significant trade-offs [206]. Albeit anomaly detection systems could be installed using existing electric infrastructures, another crucial issue of these systems is that they have actually high implementation costs. Most of the solutions are built upon the latest machine learning methods, which require high-performance computing resources, e.g. using cloud platforms. Therefore, this slows down the commercialization of these solutions. Moreover, resistance to security attacks resulting from unintentionally inappropriate system development or theft attacks is not seriously addressed in most of energy consumption anomaly detection solutions.

Current trends and new perspectives
After overviewing anomaly detection frameworks, discussing their limitation and drawbacks and describing the important findings, it is of utmost importance to describe the current trends of this niche and derive the new perspectives that could be targeted. This helps the anomaly detection community in understanding the current challenges and future opportunities to improve the anomaly detection technology of energy consumption in buildings. Fig. 5 summarizes the current trends and new perspectives that are identified in this framework.

Current trends
Anomaly detection in energy consumption presents various challenges, which are mainly domain-specific. For instance, there is no clear definition of normal versus anomalous consumptions and there is inexplicit frontiers that separate normal and anomalous behaviors. Moreover, there is an absence of ground-truth data and unified metrics that could be deployed to evaluate the performance of anomaly detection algorithms. In addition, other data sources could result in triggering non conventional energy consumption anomalies, such as: presence/absence of end-users, opening of windows/doors when some specific appliances are on. To that end, this section discusses a set of current trends that should be considered to enhance the anomaly detection technology for energy saving applications.

Considering other data sources
In traditional anomaly detection schemes deployed for energy consumption, the anomalies are generally detected using only power consumption data gleaned from the main circuit or from individual devices, without paying any attention to other factors that can affect the consumption. However, in order to conduct an accurate anomaly detection, all the data that impact power consumption should be gleaned and stored along with energy consumption patterns. Following, anomaly detection algorithms should be build with reference to all these data, which can be summarized as follows: D1. Appliance parameters: each appliance has specific parameter settings that are responsible on its well functioning, such as the minimum standby consumption, maximum standby consumption and maximum operation time. These parameters are important to define normal and abnormal consumptions of appliances and further to detect whether an appliance is working perfectly or it is faulty.
D2. Occupancy patterns: the presence or absence of end-users could highly affect energy usage and results in some anomalous consumption behaviors that are not directly linked to excessive consumption of appliances. For example, turning on an air conditioner, television, fan or desktop when end-users are absent should be considered as an abnormal consumption behavior. To that end, recording occupancy data allows to detect unconventional anomalous consumption behaviors.
D3. Ambient conditions: energy consumption could be extremely impacted by indoor conditions, such as the temperature, humidity and luminosity since the operation of some appliances depends mainly to these factors (e.g. Device consumption without the presence of the end-user air conditioners, heating systems, fans, light lamps, etc.). Therefore, collecting this kind of data helps in capturing abnormal energy consumption.

Non-intrusive anomaly detection
Starting from the advantage of NILM as a good alternative to submetering for collecting itemized billing, its use for detecting appliance-specific anomalies is very appreciated. Specifically, using NILM will remove the need to install individual submeters for each appliance and hence helps in significantly reducing the cost of anomaly detection solutions [17,207]. The use of NILM to detect abnormal consumptions results in the development of a new kind of non-intrusive anomaly detection systems. In [19,208], the authors have attempted to investigate if device-specific consumption fingerprints detected using NILM could be utilized directly to identify anomalous consumption behaviors and to what extent this could impact the accuracy of the identification. Accordingly, even though the performance of NILM to identify abnormal consumption is not yet as accurate as using submetering feedback, its performance could be improved further to allow a robust identification of faulty behavior. Moving forward, more effort should be put in this direction to develop non-intrusive anomaly detection of sufficient fidelity without the need to install additional submeters [22,209].

Collection of annotated datasets
As mentioned previously, the absence of annotated datasets impedes the development of power anomaly detection solution. To that end, greater effort should be put to collect and annotate power consumption datasets at different building environments (households, workplaces, public buildings, and industrial buildings), and further to share them publicly. This can help researchers to speed up the process of testing and validating their algorithms. In this context, the authors in [18] launch two new datastes for anomaly detection. The first one, called Qatar university dataset (QUD) is collected in an energy lab and offers the consumption of four appliance categories along with the occupancy patterns for a period of three months. While the second, named power consumption simulated dataset (PCSiD), produces consumption fingerprints of six devices and occupancy data for a period of two years. Both datasets provide power consumption footprints with their associated labels, where the overall data is split into five consumption classes. Three of them represent normal consumption classes, they are called "good consumption", "turn on device" and "turn off device", while the two remaining classes refer to anomalous consumption groups, which are defined as "excessive consumption" and "consumption while outside". Table 2 resumes the assumption and labeling process of micro-moment classes, which is applied in QUD and PCSiD (both datasets could be accessed via http://em3.qu.edu.qa/) [18].

Unified metrics to measure the performance
In addition to what has been been presented and based on analyzing the state-of-the-art, it is worth mentioning that there is no unified metrics and schemes to evaluate the performance of the anomaly detection algorithms. By contrast, conducting a fair comparison between different anomaly detection approaches should be conducted using an ensemble of standard metrics, and should be performed under the same conditions, e.g. using the same dataset including appliance fingerprints collected at the same sampling rate [21].

New perspectives
Recently, governments, end-users, utility companies and energy providers pay a significant interest to the anomaly detection technology as a sustainable solution that could help in achieving the energy efficiency targets. In this section, we provide a general overview of new perspectives in anomaly detection in energy consumption.

Explainable deep learning models
Deep learning based based anomaly detection solutions receive an increasing attention in current frameworks. However, despite their good performance, the black-box property of deep learning models represents a disadvantage in practical implementation [210]. Particularly, in energy consumption anomaly detection schemes, explanations of abnormalities detected using deep learning are critical. To that end, developing deep learning based abnormality detection techniques providing explanations why a power consumption observation/event is abnormal helps end-users/experts in focusing their investigations on the very crucial abnormalities and can boost their trust in the adopted solutions [211,212].
For instance, one important orientation could be through developing a novel generation of explainable deep one-class learning models to effectively detect different kinds of energy consumption anomalies [213]. Specifically, this category of models helps in (i) learning a mapping to concentrate normal consumption observations in a feature space, (ii) pushing abnormal patterns to be mapped away, and (iii) providing appropriate explanations for the anomalies detected, or more exactly, a human-readable prescription presenting helpful information on the causes that have led to the anomaly. Moreover, this enables to generate tailored recommendations helping end-users in reducing their wasted energy and energy providers in detecting non-technical losses through the use of explainable recommender systems [214].

Deep learning on microcontroller unit
Deep learning is when of the promising solutions to implement powerful anomaly detection solutions, however, a couple of years ago, it had been pretended that deep learning could just be implemented on high-end computing platforms, while the training/inference is conducted at the edge and carried out by edge servers, gateways or data centers. It had been a legitimate presumption at that period since the tendency was through the distribution of computing resources among the clouds and the edge serves. However, this situation is changed completely currently owing to recent R&D achievements performed by academic and industrial partners [215]. Accordingly, the alternative considers the use of novel microcontrollers that include integrated machine learning accelerators. This could bring machine learning and specifically deep learning to the edge devices. The latter could not just execute machine learning algorithms, but they do that while consuming very low power and they need to connect to cloud just if extremely required. Overall, this kind of microcontroller with embedded machine learning accelerators provides promising opportunities to offering computation capability for energy submeters and sensors collecting ambient conditions (i.e. temperature, humidity and luminosity), which gather data to enable various IoT applications.
On the other side, the edge is widely regarded as the furthest point in any IoT network that could be an advanced gateway (or edge server). Furthermore, it terminates at the submeters/sensors near the end-user. Thus, placing more analytical power near the end-user has become rational, where microcontrollers could be very convenient. Explicitly, this allows the inference and eventually the training, to be performed on tiny and resource-constrained low-power devices, instead of the large computing platforms (e.g. desktops, workstations, etc.) or the cloud. It is worth noting that to implement deep learning models, their size needs to be reduced in order to adapt the moderate computing, storage, and bandwidth resources of such devices, while maintaining the essential functionality and accuracy. Fig. 6 illustrates an example of the anomaly detection solution embedded on a microcontroller based smart plug, which is proposed in the (EM) 3 project [216].

Deep reinforcement learning
Reinforcement learning is a promising topic of artificial intelligence that has received a significant attention recently. Its idea is related to comprehending the human decision-making procedure before developing algorithms for enabling agents to determine the proper anomaly behaviour using trial-and-error in parallel with the reception of feedback form of reward power consumption signals [217]. In this regard, deep reinforcement learning (DRL) is then proposed as a merge of deep learning and reinforcement learning to detect more complex consumption anomalies. Detecting such abnormalities involves handling high-dimensional consumption patterns and environmental conditions, uncertainties of the agent's observations and sparse reward power consumption signatures. DRL techniques have been proposed lately to resolve a broad variety of issues, including detecting abnormalities video surveillance, traffic management and anomaly detection [218,219], communication and networking [220] and energy consumption prediction [221].
Overall, DRL shows promising opportunities to resolve effectively the problem of energy consumption anomaly detection since the latter is considered as a decision-making task. Following, an agent is designed to learn from the consumption and environmental data via a continuous interaction with them and reception of rewards for detected anomalies, i.e. the process is similar to the natural human learning via their experiences.

Innovative anomaly visualization
As explained previously, the capability to interpreting anomalous and normal power consumption behaviors is of utmost importance since the essential intrinsic challenges in the abnormality detection issue are mainly related to (i) the absence of obvious boundaries between anomalous and normal consumption observations, and (ii) the complexity to obtain annotated power consumption datasets to train and verify developed solutions. To that end, the knowledge and experience of human experts are much appreciated to judge the consumption scenarios. A subjective, comprehensive and interactive visualization of power consumption patterns and resulted analytic is hence greatly helpful to support the interpretation and facilitate an optimal decision-making. In this context, great attention has been devoted recently to using innovative visualization tools and visual analysis methods to detect anomalous data in other research fields, such as the spreading of rumors on social media [222] and user behaviors [223,224].
In this regard, using visualization and interaction for detecting anomalous power consumption behaviors and supporting end-users' interpretability and interactivity represent a promising research direction, especially to understand sensemaking of anomalous consumption footprints and explain why an anomaly occurs. For instance, novel visualization plots are designed in the (EM) 3 framework to portray anomalous consumption patterns using a scatter plot, in which two kind of anomalies, i.e. "excessive consumption" and "consumption while outside" along with normal data are traced over the day time. Specifically, Fig. 7 illustrates normal and abnormal consumption data collected from DRED dataset [225]. Explicitly, it describes in a good manner the distribution of consumption anomalies over the time line.
Furthermore, another interesting visualization plot developed in (EM) 3 , which could provide end-users with consumption analytics and anomaly detection capabilities at an appliance-level is the stacked bar [226]. It enables to select devices and stack various models of the same device altogether (e.g. televisions from distinct brands). Visualizing multi-level power consumption could help end-users in effectively detecting anomalies and faulty devices, and hence could allow them to perform better decision-making towards reducing wasted energy [227]. Fig. 8 portrays the stacked bar visualization plot developed in the (EM) 3 project.

Platforms for reproducible research
Despite the advance achieved in developing anomaly detection methods for energy consumption, three aspects principally affect reproducibility, and thus a fair and experimental comparison of anomaly detection algorithms: i) it is difficult to evaluate the generality anomaly detection techniques as most of the frameworks are generally assessed on a unique dataset, ii) there is an absence of frameworks comparing existing solutions under the same conditions, because of  the lack of available open-source anomaly detection datasets, and iii) distinct assessment criteria are used in the state-of-the-art with regard to the considered scenario [228].
To overcome this issue, there is an urgent need to release an open source anomaly detection toolkit, which includes challenging energy consumption datasets and existing anomaly detection algorithms. This will allow a fair and easy comparison of anomaly detection algorithms in a reproducible manner. Furthermore, this will help to prepare the ground for future anomaly detection competitions [229].

Privacy-preserving machine learning
The wide use of machine learning methods for anomaly detection in energy consumption is actually limited by the lack of open-access anomaly detection datasets to train and validate algorithms, due to strict legal and ethical requirements to protect end-user privacy. Aiming at preserving end-user privacy while promoting scientific research while using power consumption datasets, implementing novel approaches for federated, secure and privacy-preserving machine learning is an urgent need. In this context, removing private information (anonymization) and replacing of vulnerable inputs with artificially produced ones while permitting a reattribution based on a look up table (pseudonymization) are among the solutions that could be targeted [230]. Furthermore, using federated machine learning, which helps in training algorithms over various decentralized edge-devices/servers holding local power consumption patterns without sharing them seems very promising for anomaly detection in energy consumption [231].

Explainable energy recommender systems at the COVID-19 pandemic
Power consumption in buildings has been completely changed in the COVID-19 pandemic due to the constraints on movement. This has widely triggered teleworking and e-learning, and hence has shifted activities and energy usage to domestic residents [232]. Therefore, the need for smart solutions to detect energy consumption anomalies with reference to the actual situation and other changes that could be occurred at any time is a current challenge. To that end, the use of recommender systems for supporting human decision making has recently received much interest [233,234]. However, with the aim of increasing the end-user trust and improving the acceptance of the generated recommendations, these systems should provide explanations.
In this context, developing mechanisms for explainable and persuasive energy consumption recommendations that could be tailored based on the end-user preferences, habits and current circumstances will promptly reduce wasted energy and promote energy saving. Specifically, the explanations could justify the reasons for recommending each energy efficiency act [235]. On other the hand, the persuasiveness of fact-based explanations could be improved using persuasive and incentive aspects, such as emphasizing ecological impacts and economical saving benefits. Fig. 9 illustrates a general flowchart of an explainable energy recommender system proposed in the (EM) 3 framework [236]. Moreover, it is worth noting that explainable recommender systems are much appropriate to unexpected energy consumption situations (e.g. the COVID-19 pandemic) since the recommendations could be generated in real-time in addition to providing the end-user with more details (using contextual data) on each recommended action to increase its acceptance.

Conclusion
In this framework, a systemic and technically-informed survey of anomaly detection methods in building energy consumption has been presented. A taxonomy that classifies these approaches with reference to different aspects has been proposed, such as the machine learning model, feature extraction scheme, application scenario, detection level and computing platform. To conclude, anomaly detection strategies could evidently benefit energy saving systems, energy providers, end-users and governments via reducing wasted energy and energy costs. Explicitly, they provide insight information on abnormal consumption behaviors, anomalous appliances, non-technical loss and electricity theft cyberattacks, but most significantly, anomaly detection systems offer smart and powerful solutions for boosting end-users and energy stakeholders to promote energy saving, play a major role in the energy monitoring market and monetize their assets.
We have showed that most anomaly detection solutions in energy consumption are still in their early development phase, where most of them have been investigated in academic research. To promote their widespread utilization, a set of difficulties and limitations should be overcome, among them the lack of annotated datastes, absence of the reproducibility platforms and the lack of standard metrics to assess the performance of each solution. Therefore, much research effort should be made to confront to confront the aforementioned issues.
In addition, further investigations are still ongoing on the principal improvement directions, which could permit to develop power anomaly detection systems in terms of the scalability, decentralisation, low power consumption, easy implementation and privacy preservation. Finally, we assume that more research actions, projects and cooperation with industrial partners should be performed to help anomaly detection technology in reaching its entire potential, proving its commercial feasibility and lastly facilitating its adoption in all the buildings.