# A Thermal Discomfort Index for Demand Response Control in Residential Water Heaters
## 4 The Proposed Approach for Defining a Discomfort Index
### Water Utilization Forecasting Model
#### 4.2.3 Formulation  
The forecasting model for water utilization is based on an extremely randomized trees (ExtraTrees) regression model. ExtraTrees is an ensemble learning method for solving classification and regression problems that operates as a Random Forest (RF) technique. ExtraTrees defines a set of decision trees that is trained with training data, and the resulting output class (for classification problems) or prediction (for regression problems) is defined as the mode (for classification) or mean/average prediction (for regression) of the considered decision trees [31]. Using a large number of trees allows properly dealing with overfitting problems that arise when using few trees. ExtraTrees has two main differences with the standard procedure defined by RF: (i) each tree is trained using all the training data (and not using just a bootstrap sample, as the standard RF method), and (ii) a further step of randomization is included in the top-down splitting in the tree learner by selecting a random cut point for each considered feature in the problem (according to a uniform empirical distribution to select between the values for each feature in the training set). The split that computes the best result is then used to split the considered node of the tree [32]. ExtraTrees have proven to be an accurate predictor for electricity-related problems (e.g., for demand forecasting in industrial and residential facilities [7]).  
Input features considered for the proposed ExtraTrees regression method include:  
* _Use_ (\(\vec{u}\), 120 Boolean values): indicating whether a water utilization occurs in the past 120 min.
* _Month_ (\(m\), integer): indicating the month of the horizon to forecast.
* _Day_ (\(d\), integer): indicating the day of the horizon to forecast.
* _Hour_ (\(h\), integer): indicating the hour of the horizon to forecast.
* _Dayofweek_ (\(dw\), integer): indicating the day of the horizon to forecast.
* _Workingday_ (\(wd\), Boolean): indicating if the horizon to forecast is a working day or not.  
Fine-tuning of the proposed ExtraTrees regression method was performed using grid search techniques for hyperparameter settings. Hyperparameters are external parameters, inherent to the learning model, whose values cannot be set or estimated from training data. Hyperparameter values affect the quality of the resulting model, and appropriate values must be set before launching the learning process. Grid search techniques define a search space as a grid of different combinations of candidate hyperparameter values and proceed to evaluate every combination in the grid. In this article, the GridSearchCV method from scikit-learn was used. GridSearchCV (the \(CV\) stands for _cross validation_) was applied with varying parameters: _number of estimators_ and _max tree depth_, considering 10-folds cross-validation and the predetermined evaluation metrics over the model. After the model is trained, a vector with 120 Boolean values (\(\vec{F}\)), representing the water utilization forecast for the next two hours, is obtained according to the Equation: \(Pred(\vec{u},m,d,h,dw,wd)=\vec{F}\)  
Figure 4: On blocks and water utilization patterns in the electric water heater consumption.