{'fraction_non_alphanumeric': 0.035184328891504475, 'fraction_numerical': 0.012022363277144898, 'mean_word_length': 4.968389362769694, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Energy Disaggregation with Semi-supervised Sparse Coding

Residential smart meters have been widely installed in urban houses nationwide to provide efficient and responsive monitoring and billing for consumers. Studies have shown that providing customers with device-level usage information can lead consumers to economize significant amounts of energy, while modern smart meters can only provide informative whole-home data with low resolution. Thus, energy disaggregation research which aims to decompose the aggregated energy consumption data into its component appliances has attracted broad attention. In this paper, a discriminative disaggregation model based on sparse coding has been evaluated on large-scale household power usage dataset for energy conservation. We utilize a structured prediction model for providing discriminative sparse coding training, accordingly, maximizing the energy disaggregation performance. Designing such large scale disaggregation task is investigated analytically, and examined in the real-world smart meter dataset compared with benchmark models.


I. INTRODUCTION
Energy efficiency has raised increasing public concerns due to the persistent and predominant consumption of fossil fuels, which has remained largely unabated during recent decades (Mobilia, 2017). More recently, smart meters and other metering sensors interconnected across distributed networks are being increasingly adopted in urban households (Benzi et al., 2011), playing crucial roles in providing efficient, secure and reliable residential energy usage monitoring (Krishnamurti et al., 2012;Zheng et al., 2013). As of 2018, more than 86.8 million smart meters have been installed across the US, among which 88% are equipped in residential houses (Chui et al., 2018). Smart meters record energy at a low resolution (typically every hour or 15 minutes) and reported at least daily (Feuerriegel et al., 2018). Although residential smarter meters can report detailed information on whole-home electricity consumption in real-time, they do not perform appliance-level monitoring of power usage, which would provide more informative feedback for customers to conserve energy. According to Darby et al. (2006), with detailed appliance-level energy consumption notification, residents can modify their consumption habits, which can improve energy efficiency by 12%. What's more, disaggregated energy information plays a crucial role in diagnosing household electricity problems and forecasting demand (Froehlich et al., 2010). Therefore, energy disaggregation (also referred to as non-intrusive load monitoring or NILM), which aims to estimate the power demand of individual appliances based on a single whole-home aggregated energy signal, has attracted great interest in the applied machine learning area (Herrero et al., 2017).
NILM typically monitors a single source of usage data by employing signal processing to identify constituent components based upon a data repository (i.e., a dictionary) of current and voltage signatures. Aside from electricity usage analytics, current and prospective use-case applications also include condition-based maintenance and anomaly detection related to intrusions, faults and defects (e.g., short circuits, overloads), in order to prevent or mitigate the risk of outages and electrical fires. In the disaggregation and recognition of energy consumption patterns, sampled signals from an electricity consumption indicator are disaggregated in order to identify device and appliance level power usage patterns, often by employing machine learning or other signal processing methods. The notion of energy usage disaggregation underlying NILM is straightforward: monitor a single source of data on energy usage (e.g., a smart meter) and employ signal processing software to identify constituent components based upon unique energy-usage (e.g., current and voltage) signatures. The objective of such signal disaggregation is to identify energy consumption patterns at a much lower cost than would be incurred with submetering.
By way of example, one such approach employs two current transformers (CTs) as sensors that measure alternating current (AC) attached to the service mains of the electric panel for a property, in order to measure electricity consumption (or generation). These current sensors monitor usage patterns, in order to disaggregate the consumption signatures of individual appliances by sampling current and voltage at a rate of one million times per second. This highresolution data is used to train algorithms in order to detect minute variations in magnitude, phase, and frequency to differentiate between appliance performance. Split-core type CTs have a primary winding, a magnetic core, and a secondary winding and may be attached as sensors to either live or neutral wiring entering a building, without the need for high voltage electrical work. For whole building monitoring, the primary winding is the live or neutral wire (but not both) entering the building, passed through the opening in the CT with the secondary winding consisting of many turns of fine wire housed within the transformer case.

A. Existing Research
As surveyed by Butzbaugh et al. (2019), the literature is extensive regarding the suitability, reliability, robustness and accuracy of particular algorithms and sensors for NILM and disaggregation of energy usage patterns at device and appliance levels. It has been further noted throughout the literature that available sensing devices on the market tend to be highly variable in relative accuracy for identifying usage patterns. Studies assessing multiple disaggregation tools document that the accuracy of a given product in identifying the energy consumption associated with a particular end use (e.g., a refrigerator) can range between 0 to 90 percent. Energy disaggregation research introduced in (Hart, 1992) can be classified as supervised and unsupervised methods depending on whether a training dataset of power consumption from individual appliances is utilized. For supervised algorithms, optimization and pattern recognition techniques are commonly applied. Integer programming to determine the optimal combination of active appliance states is discussed in (Suzuki et al., 2008). The study (Baranski and Voss, 2004) presents a genetic algorithm combining with fuzzy clustering to detect usage patterns using only standard digital meters. To detect power signals of devices, a multi-label classification framework employing both time and wavelet domain features is introduced in (Tabatabaei et al., 2016). Altrabalsi et al. (2016) propose a k-means clustering SVM model to handle low-complex NILM problems with a short training period.
Besides, deep neural nets have driven remarkable improvements in the NILM area. In (Kelly and Knottenbelt, 2015), both convolutional (CNN) and recurrent neural networks (RNN) are employed to model sequence-to-sequence (seq2seq) learning. The study (Bonfigli et al., 2018) examines a denoising autoencoder which attempts to reconstruct the clean power demand of target appliances. On the other hand, unsupervised work utilizes the Factorial Hidden Markov Model (FHMM) considering additional features such as time of day and dependency between appliances is described in (Kim et al., 2011) to infer the state of each appliance. Following that, Kong et al. (2016) consider a hierarchical extension of the HMM model to handle the appliances with multiple functional modes.

B. Contributions
Most existing studies within both supervised and unsupervised frameworks have their limitations. Supervised learning requires highquality individual appliance data for model training, before the system deployment, in order to guarantee accurate disaggregation results. Although unsupervised approaches do not rely on the preceding appliance-level data, most are highly task-dependent (Kim et al., 2011) and their disaggregation results usually underperform the supervised models with extra training stages. Additionally, most studies are conducted in a laboratory environment containing household energy data within a relatively small number of houses, e.g., REDD (Kolter and Johnson, 2011) and BLUED (Filip, 2011). Therefore, the generalizability of such algorithms has not been fully investigated yet.
Motivated by a more practical strategy to conduct energy disaggregation, we adopt the semi-supervised approach based on sparse coding to disaggregate power usage using low-resolution, hourly data which is readily accessible via smart meters. Specifically, we apply the discriminative training algorithm based on sparse coding to learn hidden patterns (i.e., sparse representations) in each appliance's usage over a typical week, then combine with the learned hidden patterns to predict the appliance-level power usage of unseen houses using their whole-home aggregate signal alone. Furthermore, we consider a substantially larger household energy dataset containing approximately 1,000 houses within a two-year period and conduct experiments using selected quantitative metrics to evaluate the algorithm efficiency in realistic scenarios.

A. Data Model
Consider a lossless household power system consisting of M households and K number of appliances, e.g., refrigerators and heaters, with T hours power usage recording in each household. We denote the energy usage recorded for device k ∈ {1, . . . , K} in household m ∈ {1, . . . M } during T hours with x m k ∈ R T ×1 . Accordingly, we represent energy usage recording for a particular device as one class: where X k ∈ R T ×M . Based on this, we define the aggregated power consumption including all K devices as whereX ∈ R T ×M and the m th column ofX contains T hours aggregated energy consumption for all devices in a given house m.
At the training stage, we assume that the individual device energy readings X1, . . . , XK are accessible from plug-level or outlet-level monitors in a limited number of instrumented homes. While at the test stage, we assume that we can only access the aggregated signal X ′ reported by smart meters, and we aim to separate the aggregated signal into its component appliances, i.e., X ′ 1 , . . . , X ′ K .

B. Non-negative Sparse Coding Model
Sparse coding has been widely applied as an effective data representation method to source separation problems (Schmidt and Olsson, 2006;Schmidt et al., 2007). We adopt this approach to train separate models for each individual class X k , then apply these models to separate aggregated signals in the testing stage. Specifically, sparse coding attempts to approximate each class training sample X k as where B k = [b1, . . . , bn] ∈ R T ×n represents a dictionary matrix and its columns are n basis functions, and Ai = [a1, . . . , aM ] ∈ R n×M represents a activation matrix Ai = [a1, . . . , aM ] ∈ R n×M and each column represents the activation of basis functions (Wang and Gao, 2014). It is noticeable that sparse coding assumes that only a few basis functions in the dictionary are sufficient to represent the training data, thus the activation matrix A k should be sparse, i.e., most of the elements are zeros, leaving only a few nonzeros. Accordingly, an over-complete dictionary of the training data in which more basis functions than the dimensions of training data (i.e., n ≫ T, M ) is learned. To solve the sparsity, we need to impose an ℓ1 regularization penalty to the activations (Lee et al., 2007). What's more, since the input data (energy usage) is inherently non-negative, it imposes the further constraints that the dictionary and activation matrices are both non-negative. Accordingly, the nonnegative sparse coding (NNSC) for energy usage is to find nonnegative optimal sparse representation of training data such that the reconstitution error is minimized: where · F is the Frobenius norm, · 2 is the ℓ2 norm and λ ∈ R + is a regularization parameter to encourage sparsity of activation matrix A k . Moreover, b (j) k 2 ≤ 1 constraints are imposed to reduce the complexity of each basis function. It is noticeable that (4) is not jointly convex in A k and B k , but convex in each variable when holding the other fixed. Thus, to minimize the objective with respect to both, we can take turns updating B k and A k (Hoyer, 2002).
Based on the above procedure, sparse representations A k and B k for power usage X k of each class k ∈ {1, . . . , K} in the training dataset can be learned based on (4). Since B k is trained to reconstruct the kth class with small activation, we assume it is the optimal dictionary to reconstruct the kth portion of the aggregated signal. In the testing stage, we assume that the bases learned from the training stage remain the same for reconstructing signals, i.e., We aim to disaggregate a new aggregated power signalX ′ ∈ R T ×M without providing any information on its components. When the sparse coding framework is applied to the test aggregated signal and we assume that the sources are additive, we havē where we denote B1:K as shorthand for [B1, . . . , BK ]. Therefore, based on (6), the joint set of optimal new activation matricesÂ ′ 1:K can be computed as the following problem: Therefore, based on the basis B k learned from training stage and the activationÂ ′ k computed in (7), we can predict the kth component of tested aggregated signalX ′ aŝ Therefore, the disaggregation error is defined as which evaluates the accuracy for reconstructing individual classes via only the aggregated signal combining with obtained activations.

C. Discriminative Disaggregation Model
The sparse coding approach only concerns the sparse approximation of input data, and it strongly hinges on the assumption that the disaggregation dictionary is the same as that of reconstruction in (5). However, the additional discriminative information provided by bases over the training signals is limited when being used in complex disaggregation tasks . Accordingly, discriminative disaggregation sparse coding (DDSC) which is to learn a dictionary whose resultant activations possess improved discriminative power is proposed in (Kolter et al., 2010). Specifically, with the assumption that the disaggregation dictionary is not necessarily the same as that for reconstruction, and the intuition that optimal value ofÂ k should be the activations learned by sparse coding is given by ∀k ∈ {1, . . . , K}, DDSC aims to minimize disaggregation error in (9) while discriminatively optimizing the the dictionary bases in order to move activationŝ A ′ 1:K as close to A * 1:K as possible . Therefore, the disaggregated error in (9) can be converted into an augmented regularized disaggregation error defined as where B1:K denotes the reconstruction bases which are learned from sparse coding in (4), andB1:K denotes the discriminative bases which intend to reduce the difference betweenÂ1:K and A * 1:K where A * 1:K is the activations learned by sparse coding in (10). To update the discriminative basesB1:K and by denotingB = B 1, . . . ,BK and A * = A * T 1 , . . . , A * T K T (and similarly forÂ), we apply a structured perceptron algorithm (Collins, 2002) stated as where α denotes the perceptron updating step size. It is noticeable that for each iteration we need to remove negative elements and renormalize each column inB1:K to keep its form consistent with B1:K.

D. Prediction Model
Based on the discriminative bases obtained in (12), the discriminative activationsÃ ′ 1:K can be computed by reformulating (7) intõ Accordingly, the prediction of the kth component of new aggregated signalX ′ based on DDSC can be expressed as Therefore, we summarize the iterative DDSC algorithm as follows: the NNSC algorithm is employed first to initialize the target activations and reconstruction bases. Following that, the discriminative disaggregation (DD) training iterations in (11) and (12) (Kolter et al., 2010).

III. EXPERIMENTAL RESULTS
In this section, we evaluate the performance of the DDSC algorithm on real-world scenarios.

A. Dataset and Experimental Setup
We conduct experiments using the Pecan Street dataset, which contains 60-second interval energy readings from nearly 1,000 houses with up to 23 domestic appliance-level meters per household, collected over two years across three research sites (i.e., Austin, New York, California) (Russo and Hinson, 2019;Street, 2015). Since the widely deployed smart meters are constrained to report at a low sample rate (typically 1/3600 Hz), for generalization purposes, we convert both whole-home and device-level readings into intervalbased time series with a 1/3600 Hz sample rate (Liang et al., 2019). Meanwhile, we reduce the size of bases to guarantee the performance of DDSC by only considering five categories of electrical devices with distinct consumption patterns (i.e., furnace, dishwasher, refrigerator, air, and a miscellaneous category) (Dong et al., 2013). Due to limited computational power, we choose to select 80 houses that satisfy the requirements as our dataset, i.e., m = 80. Critically, we focus on disaggregating data from homes that are absent from the training data, where we assign 70% of the data for training and 30% of the data for testing. The hyper-parameters of the algorithm (e.g., number of bases n, regularization parameter λ and step size α) are all selected independently using grid search through a discrete set of empirical values. Again, due to the computational limits, we provide the weekly (T = 168) disaggregated predictions in different cases to evaluate the DDSC performance.

B. Implementation
Based on the dataset and settings described in Section III-A, we conduct all DDSC experiments using Python 3.7 packages (Oliphant, 2007) including machine learning solver Scikitlearn (Pedregosa et al., 2011) and signal processing solver Librosa (McFee et al., 2015). Specifically, we implement a coordinate decent approach (Friedman et al., 2007) to solve the optimization problems in (10) and (11) using Scikit-learn module SparseCoder and Librosa to decompose and retrieve the activation matrices. In the NNSC pretraining stage, to solve the optimization over B k in (4), we apply the multiplicative non-negative matrix factorization method proposed by Eggert and Korner (2004). For the rest part, we rely on the standard methods for solving the optimization problems.

C. Weekly Energy Disaggregation
In this subsection, we evaluate the weekly prediction of energy disaggregation using DDSC during different seasons. Fig. 1(a) and 1(b) illustrate the true energy consumption of one selected house in the test set for two different weeks in summer and winter respectively, along with the predicted consumption by DDSC. Fig. 1(c) and 1(d) show the relative consumption comparison of different devices over the whole week in both seasons.
We can see that for the selected house, weekly energy usage in the summer is higher than that in the winter mainly due to the relatively heavier usage of air conditioners. In contrast, the refrigerator has steady usage patterns regardless of seasons. In terms of the total predicted percentage, we can see that DDSC performs well for this particular house in both seasons. In terms of usage signals, for devices which hold certain steady usage pattern, e.g., refrigerator, DDSC can capture the weekly trend well. However, DDSC fails to predict the spikes in dishwasher usage. The underlying reason is that when the component signal is too sparse and relatively weak, it is hard for DDSC to identify the disaggregation dictionary when training bases B1:K with limited label data (Dong et al., 2013). Moreover, DDSC has difficulty in disaggregating air and furnace components during winter. This can possibly be explained that the consumption patterns of air and furnace are highly correlated with each other, which leads to poorer disaggregation performance.

D. Quantitative Evaluation
Next, we present metric results that evaluate the performance of DDSC on each of these components compared with the baseline NNSC model. When we focus on the error in energy usage at every time point, we apply the mean absolute error (MAE) defined as where x k (t) denotes the ground truth andx k (t) denotes the prediction of device k at time t. Meanwhile, when we are interested in recovering the total energy used by each appliance over a period, e.g., one week, we use normalized signal aggregated error (SAE) (Zhang et al., 2018) expressed as where r k andr k denote the ground truth and the predicted total power consumption of device k over time period T , i.e.,r k = T t=1x k (t) and r k = T t=1 x k (t). This measure can provide accurate evaluation for weekly power usage even if its per-timestep prediction is less accurate. However, we do not apply the widely used Normalized Disaggregation Error (NDE) (Zhong et al., 2014) as since it is less straightforward to provide meaningful feedback to householders compared with MAE. Also, MAE is more robust than NDE with outliers, i.e., extremely inaccurate predictions (Zhang et al., 2018). 2% overall compared with NNSC, which are also improved for each appliance. It clearly demonstrates that the discriminative training in DDSC is crucial to enhancing the performance of the energy disaggregation procedure and provides a significant improvement over the baseline NNSC model.

IV. CONCLUSION
Energy disaggregation, which separates whole-home power consumption into individual device-level consumption, can make a significant contribution to energy conservation. In this paper, we examine the importance of structure learning for disaggregation tasks and present a sparse coding model to discover discriminative sparse structures of individual devices. The extensive experiments focusing on high volumes of disaggregated (and in many cases somewhat relatively low-resolution) data available from smart meters and related sensors may be conducted to demonstrate whether or not and if so, under what conditions and to what degree the discriminative model might substantially improve the performance of sparse coding in disaggregation tasks. Estimated consumption patterns being specifically inspected may provide detailed forensic measurement regarding energy consumption and other related decision support analytics for maintenance and risk mitigation.

V. DISCUSSION AND FUTURE RESEARCH
The primary bottleneck in our approach is that the disaggregation performance is not reliable when training bases contain large amounts of appliances with similar consumption patterns and limited label metadata. Since the size of the dictionary matrix expands, the massive number of tunable parameters will lead to many local optima and high time consumption for iterative updates. Also, only a small amount of labeled data can be collected for training due to user privacy and security concerns. Therefore, a possible research direction is to combine sparse coding with deep learning to learn multiple layers of dictionaries to capture more nuanced hidden patterns of each device.
We also plan to analyze the sensitivity of energy disaggregation performance to smart meter sampling frequency. More large-scale datasets and published algorithms will be incorporated into comprehensive comparison. Furthermore, some hybrid approaches that vary the sampling rate in order to track high-frequency patterns will be evaluated. Lastly, the applicability of the discriminative sparse coding method to other source separation problems will be further investigated, in addition to seasonal patterns, intraday and across other timescales. (c) Percentage prediction in winter.
(d) Percentage prediction in summer. Fig. 1: Example weekly predicted energy profiles and total energy percentage in winter and summer periods.