# Selection of Features Based on Electric Power Quantities for Non-Intrusive Load Monitoring
## 3 Database Creation
### Signal Processing
\right] \tag{11}\]  
In order to define a reference value representative of the pre-event scenario for the \(k\)-th parameter, the mean value among the four pre-event values has been considered:  
\[ref_{k}=\frac{(\mathbb{P}_{k}(\sigma w_{1})+\ \mathbb{P}_{k}(\sigma w_{2})+\ \mathbb{P}_{k}( \sigma w_{3})+\ \mathbb{P}_{k}(\sigma w_{4}))}{4} \tag{12}\]  
The obtained reference values have been then considered to evaluate the variation of the \(k\)-th parameter due to the occurrence of the event, \(\Delta\mathbb{P}_{k}\), according to the following equation:  
\[\Delta\mathbb{P}_{k}^{post-4}=\mathbb{P}_{k}\big{(}\sigma w_{post}\big{)}-ref_ {k} \tag{13}\]  
where, given \(post=[5,6,7,8]\), the superscript \(post-4\) denotes the index of the post-event values of the parameter \(\mathbb{P}_{k}\). Consequently, the matrix containing the variations of all the \(\mathbb{P}_{k}\) parameters, named \(\Delta\mathbb{P}\in\Re^{4*4}\), has been obtained:  
\[\Delta\mathbb{P}=\left[ \begin{array}{ccc}\Delta P(\sigma w_{5})&\Delta P( \sigma w_{6})&\Delta P(\sigma w_{7})&\Delta P(\sigma w_{8})\\ \Delta P_{1}(\sigma w_{5})&\Delta P_{1}(\sigma w_{6})&\Delta P_{1}(\sigma w_{7 })&\Delta P_{1}(\sigma w_{8})\\ \Delta P_{H}(\sigma w_{5})&\Delta P_{H}(\sigma w_{6})&\Delta P_{H}(\sigma w_{7 })&\Delta P_{H}(\sigma w_{8})\\ \Delta Q_{1}(\sigma w_{5})&\Delta Q_{1}(\sigma w_{6})&\Delta Q_{1}(\sigma w_{7 })&\Delta Q_{1}(\sigma w_{8})\end{array} \right]=\left[ \begin{array}{ccc} \Delta P^{1}&\Delta P^{2}&\Delta P^{3}&\Delta P^{4}\\ \Delta P^{1}_{1}&\Delta P^{2}_{1}&\Delta P^{3}_{1}&\Delta P^{4}_{1}\\ \Delta P^{1}_{H}&\Delta P^{2}_{H}&\Delta P^{3}_{H}&\Delta P^{4}_{H}\\ \Delta Q^{1}_{1}&\Delta Q^{2}_{1}&\Delta Q^{3}_{1}&\Delta Q^{4}_{1}\end{array} \right] \tag{14}\]  
Then, these values have been used to with respect to the weight and bias variables is the cross entropy. For each pair of output class/target class \(oc/tc\) the cross-entropy is calculated as:  
\[ce = -tc\cdot log(oc) \tag{16}\]  
The cross entropy penalizes the classification errors in the different classes, mainly penalizing misclassifications that are confident. The aggregate cross-entropy performance is the mean of the individual values. Figure 2 shows the structure of the MLP neural network considered in this paper. The variables used as input are the selected features, whereas the output of the network consists of a binary vector in which the neuron corresponding to the ON or OFF event of an appliance is set equal to 1. Hence, the dimension of the output vector is twice the number of the considered appliances (44 in the case study). In order to obtain an unbiased evaluation of the neural model fit, the available dataset is generally split into three sets. The _Training set_ is used to fit the model and determine weights and biases; the _Validation set_ is used for parameter selection and it should provide an unbiased evaluation of the fit during the network training. During training, the error of each model is checked on the validation set and the model that achieves the lowest validation error is selected. This is the final choice of features and model. The _Test set_ is used once the training is completed to evaluate the performance of the final model.