scieee AI-readable full text Open interactive document viewer

Time series forecasting applied to an energy management system ‐ A comparison between Deep Learning Models and other Machine Learning Models

Arienti, João Henrique Leal

Abstract

A large amount of energy used by the world comes from buildings’ energy consumption. HVAC (Heat, Ventilation, and Air Conditioning) systems are the biggest offenders when it comes to buildings’ energy consumption. It is important to provide environmental comfort in buildings but indoor wellbeing is directly related to an increase in energy consumption. This dilemma creates a huge opportunity for a solution that balances occupant comfort and energy consumption. Within this context, the Ambiosensing project was launched to develop a complete energy management system that differentiates itself from other existing commercial solutions by being an inexpensive and intelligent system. The Ambiosensing project focused on the topic of Time Series Forecasting to achieve the goal of creating predictive models to help the energy management system to anticipate indoor environmental scenarios. A good approach for Time Series Forecasting problems is to apply Machine Learning, more specifically Deep Learning. This work project intends to investigate and develop Deep Learning and other Machine Learning models that can deal with multivariate Time Series Forecasting, to assess how well can a Deep Learning approach perform on a Time Series Forecasting problem, especially, LSTM (Long Short-Term Memory) Recurrent Neural Networks (RNN) and to establish a comparison between Deep Learning and other Machine Learning models like Linear Regression, Decision Trees, Random Forest, Gradient Boosting Machines and others within this context.

Full text

i Time Series Forecasting Applied to an Energy Management System João Henrique Leal Arienti A Comparison Between Deep Learning Models and Other Machine Learning Models Project Work presented as the partial requirement for obtaining a Master’s degree in Data Science and Advanced Analytics ii NOVA Information Management School Instituto Superior de Estatística e Gestão de Informação Universidade Nova de Lisboa TIME SERIES FORECASTING APPLIED TO AN ENERGY MANAGEMENT SYSTEM A Comparison Between Deep Learning Models and Other Machine Learning Models João Henrique Leal Arienti Project Work presented as the partial requirement for obtaining a Master’s degree in Data Science and Advanced Analytics Advisor: Mauro Castelli, Ph.D. August 2020 iii DEDICATION I would like to dedicate this thesis to my family. To my father and mother, both former university professors, for always encouraging me and supporting me in all my academic years. To my wife who made it possible for me to work, to study, and to take care of our wonderful daughters, one of them being born in the middle of the master program. To my sister who was doing a master thesis in the medical field at the same time as me and gave me important tips and also motivated me. For all of you, my most sincere gratitude. iv ACKNOWLEDGEMENTS I would like to deeply thank my thesis advisor, Dr. Mauro Castelli. Thank you for being available for advising me and for doing this incredibly fast. I always had a prompt answer which helped a lot in developing the thesis on the right path from the beginning. I would like to thank my friend and master’s colleague Biazi Bayer for helping me find an inspiring theme and project to support my thesis. And for always motivating me and being available to help. I would also like to thank my colleagues from the Ambiosensing project for their collaboration and teamwork. v ABSTRACT A large amount of energy used by the world comes from buildings’ energy consumption. HVAC (Heat, Ventilation, and Air Conditioning) systems are the biggest offenders when it comes to buildings’ energy consumption. It is important to provide environmental comfort in buildings but indoor wellbeing is directly related to an increase in energy consumption. This dilemma creates a huge opportunity for a solution that balances occupant comfort and energy consumption. Within this context, the Ambiosensing project was launched to develop a complete energy management system that differentiates itself from other existing commercial solutions by being an inexpensive and intelligent system. The Ambiosensing project focused on the topic of Time Series Forecasting to achieve the goal of creating predictive models to help the energy management system to anticipate indoor environmental scenarios. A good approach for Time Series Forecasting problems is to apply Machine Learning, more specifically Deep Learning. This work project intends to investigate and develop Deep Learning and other Machine Learning models that can deal with multivariate Time Series Forecasting, to assess how well can a Deep Learning approach perform on a Time Series Forecasting problem, especially, LSTM (Long Short-Term Memory) Recurrent Neural Networks (RNN) and to establish a comparison between Deep Learning and other Machine Learning models like Linear Regression, Decision Trees, Random Forest, Gradient Boosting Machines and others within this context. KEYWORDS Artificial Intelligence; Big Data; Data Science; Deep Learning; Energy Management System; Heat, Ventilation, and Air Conditioning; Internet of Things; Long Short-Term Memory; Machine Learning; Neural Network; Recurrent Neural Networks; Time Series Forecasting vi INDEX 1. Introduction ............................................................................................................. 1 1.1. Motivation ......................................................................................................... 1 1.2. Objectives .......................................................................................................... 1 2. Theoretical Background ............................................................................................ 3 2.1. What is Time Series Forecasting? ....................................................................... 3 2.2. Data Preparation ............................................................................................... 3 2.2.1. Standardization ........................................................................................... 4 2.2.2. Normalization ............................................................................................. 4 2.3. Model Evaluation ............................................................................................... 5 2.3.1. Train-Test Split ............................................................................................ 5 2.3.2. K-fold Cross-Validation ................................................................................ 6 2.3.3. Multiple Train-Test Splits (applied to Time Series) ...................................... 7 2.4. Performance Metrics ......................................................................................... 8 2.4.1. Mean Absolute Error (MAE) ........................................................................ 8 2.4.2. Mean Squared Error (MSE) ......................................................................... 9 2.4.3. Root Mean Squared Error (RMSE) ............................................................... 9 2.5. Machine Learning Models ................................................................................ 10 2.5.1. Linear Algorithms ...................................................................................... 10 2.5.2. Nonlinear Algorithms ................................................................................ 11 2.5.3. Ensemble Algorithms ................................................................................ 12 2.6. Deep Learning ................................................................................................. 12 2.6.1. Neural Networks ....................................................................................... 12 2.6.2. Recurrent Neural Networks ...................................................................... 14 3. Conceptual Model .................................................................................................. 17 3.1. Contextualization............................................................................................. 17 3.2. Internet of Things ............................................................................................ 17 3.3. Big Data ........................................................................................................... 18 3.4. Data Science .................................................................................................... 18 3.5. Market Analysis and Big Players Initiatives....................................................... 19 3.6. Ambiosensing Conceptual Architecture ........................................................... 20 3.6.1. Base Platform ........................................................................................... 21 3.6.2. Supervision Services.................................................................................. 23 3.6.3. Advanced Services .................................................................................... 24 vii 3.6.4. Ambiosensing Applications ....................................................................... 26 3.7. Data Collection and Ambiosensing Overview ................................................... 27 4. Experimental Settings ............................................................................................. 31 4.1. Device and Sensors .......................................................................................... 31 4.2. Data Acquisition Mechanism ........................................................................... 32 4.3. Experimental Framework ................................................................................. 34 4.3.1. Data Loading ............................................................................................. 34 4.3.2. Data Checking and Data Cleansing ............................................................ 36 4.3.3. Missing Values Treatment ......................................................................... 36 4.3.4. Outliers Treatment ................................................................................... 41 4.3.5. Descriptive Statistics ................................................................................. 43 4.3.6. Data Visualization ..................................................................................... 43 4.3.7. Feature Engineering .................................................................................. 46 4.3.8. Feature Selection ...................................................................................... 49 4.3.9. Deep Learning Models .............................................................................. 64 4.3.10. Machine Learning Models ................................................................ 76 5. Results .................................................................................................................... 82 6. Conclusions ............................................................................................................ 84 7. Practical Applications and Recommendations for Future Work .............................. 86 8. Bibliography ........................................................................................................... 87 viii LIST OF FIGURES Figure 2-1 - Train and test splits in blue and orange respectively. ........................................... 5 Figure 2-2 – Split and fold scheme of a 5-fold cross-validation example. ................................ 6 Figure 2-3 - Multiple Train-Test Splits created by TimeSeriesSplit configured for 5 splits. ....... 7 Figure 2-4 - Example of 5 splits created by TimeSeriesSplit. ................................................... 8 Figure 2-5 – An example of a Perceptron.............................................................................. 13 Figure 2-6 - An example of a Neural Network with a simple topology................................... 14 Figure 2-7 - An example of a Recurrent Neural Network (RNN) with cyclical and sideways connections. ................................................................................................................. 15 Figure 2-8 - LSTM memory block schema. ............................................................................ 16 Figure 3-1 Ambiosensing Conceptual Architecture ............................................................... 21 Figure 3-2 - Base Platform Layer ........................................................................................... 21 Figure 3-3 - Supervision Services Layer ................................................................................. 23 Figure 3-4 - Advanced Services Layer.................................................................................... 25 Figure 3-5 - Ambiosensing Device ......................................................................................... 28 Figure 3-6 - Ambiosensing Central Unit ................................................................................ 29 Figure 3-7 - Ambiosensing Overview .................................................................................... 30 Figure 4-1 - Ambiosensing device proof of concept. ............................................................. 31 Figure 4-2 - Data Collector Program Diagram. ...................................................................... 33 Figure 4-3 - Original dataset. ................................................................................................ 35 Figure 4-4 - Dataset after initial data preparation................................................................. 35 Figure 4-5 - Data captured from the sensors. ....................................................................... 37 Figure 4-6 - Data generated for data imputation. ................................................................. 37 Figure 4-7 - Dataset with original columns and null columns. Five rows out of the 10.000 transformed. ................................................................................................................ 37 Figure 4-8 - Dataset with original columns and replicated columns unaltered. Five rows out of the 40.000 not transformed. .................................................................................... 38 Figure 4-9- Sample dataset of Celsius feature before data imputation. ................................ 39 Figure 4-10 - Sample dataset of Celsius feature after data imputation. ................................ 39 Figure 4-11- Whole dataset of Celsius feature before data imputation................................. 40 Figure 4-12 - Whole dataset of Celsius feature after data imputation. ................................. 41 Figure 4-13- Time-series features summary statistics. .......................................................... 43 Figure 4-14 - Feature Celsius line plot................................................................................... 44 Figure 4-15 - Feature Celsius histogram................................................................................ 44 Figure 4-16 - Feature Celsius box and whisker plot. .............................................................. 45 ix Figure 4-17 - Feature Celsius lag scatter plot. ....................................................................... 45 Figure 4-18 - Feature Celsius autocorrelation plot. ............................................................... 45 Figure 4-19 - Dataset with new date-time features. ............................................................. 46 Figure 4-20 - Dataset with new Date_Period feature. ........................................................... 46 Figure 4-21 - Dataset with new Holiday_Flag feature when it is a holiday. ........................... 47 Figure 4-22 - Dataset with new feature Holiday_Flag when it is not a holiday. ..................... 47 Figure 4-23 – Celsius lag features. ........................................................................................ 48 Figure 4-24 - Dataset with new climate features. ................................................................. 48 Figure 4-25- External temperature feature for the whole dataset period. ............................ 49 Figure 4-26 - Precipitation feature for the whole dataset period. ......................................... 49 Figure 4-27 - Variables from the beginning of the dataset. ................................................... 50 Figure 4-28 - Variables from the end of the dataset. ............................................................ 50 Figure 4-29- Dataset after data transformations for feature selection. Variables from the beginning of the dataset. .............................................................................................. 51 Figure 4-30- Dataset after data transformations for feature selection. Variables from the end of the dataset. .............................................................................................................. 51 Figure 4-31- Features x Feature Importance Scores. ............................................................. 53 Figure 4-32 - Features x Feature Importance Scores (without top two features). ................. 53 Figure 4-33- List of selected features by the RFE algorithm. ................................................. 54 Figure 4-34 - Features x Feature Ranks by RFE algorithm (lower is better). .......................... 54 Figure 4-35 - Histogram of selected features. ....................................................................... 55 Figure 4-36 - Correlation matrix. .......................................................................................... 56 Figure 4-37 - Final dataset for Deep Learning models. .......................................................... 57 Figure 4-38 - Celsius feature series. ...................................................................................... 57 Figure 4-39- Celsius features series after trend removal. ...................................................... 58 Figure 4-40 - Autocorrelation plot for the 200 first data points of the Celsius feature. ......... 59 Figure 4-41 - Celsius series with the oldest lag features. ...................................................... 59 Figure 4-42 - Celsius series with the most recent lag features. ............................................. 60 Figure 4-43 - Features x Feature Importance Scores. ............................................................ 62 Figure 4-44 - Features x Features Importance Scores (without top feature t-6). ................... 62 Figure 4-45 - List of selected features by the RFE algorithm. ................................................ 63 Figure 4-46 - Features x Feature Ranks by RFE algorithm (lower is better). .......................... 63 Figure 4-47 - Final dataset for Machine Learning models. .................................................... 63 Figure 4-48 - Final dataset for DL models. Celsius feature highlighted for the univariate model. .......................................................................................................................... 64 3 2. THEORETICAL BACKGROUND 2.1. WHAT IS TIME SERIES FORECASTING? Time Series Forecasting is the Machine Learning area responsible for prediction problems that involve a time component. It is important to distinguish Time Series Analysis from Time Series Forecasting since they have different goals. Time Series Analysis is related to describing, to understanding the dataset. Meanwhile, Time Series Forecasting is associated with predicting, with forecasting the future (Brownlee, 2018c, p. 9;10). Times Series Analysis can be defined as the systematic approach of answering the mathematical and statistical questions posed by the time correlation introduced by the sampling of adjacent points in time. It is the analysis of experimental data that have been observed at different points in time (Shumway & Stoffer, 2017, p. 1). Time Series Analysis usually involves the study of the form of the data and of the components of a time series (Brownlee, 2018c, p. 11). Time Series Forecasting can be defined as the process of taking historical data of a time series, sometimes with additional information, and fitting models to forecast future values. Unlike Time Series Analysis that can be done in retrospect and use “future” information, forecasting models don’t have “future” information available. Everything must be done based only on what has already happened. A predictive model is evaluated by its predictive accuracy. Meanwhile, a descriptive model is assessed by its capability of providing correct causal explanations (Shmueli & Lichtendahl, 2016, p. 19). 2.2. DATA PREPARATION In many cases, the dataset will require different types of data preparation. Whenever features present themselves in dissimilar scales, it is the case to consider standardization or normalization. Both techniques intend to make features comparable to one another. For example, input variables pressure and temperature could be very different in scale. Pressure could be measured in hPa (hectopascal), which at Mean Sea-Level (MSL) is 1013,25 hPa (or 1 atm) by the International Organization for Standardization (ISO) (“International Organization for Standardization,” 1975). Still, temperature could be measured in Celsius degrees, which is usually between -40 and 40 degrees in its extremes. So, one variable has values in the range of the tens and the other in the thousands. Some Machine Learning models will perform better if the dataset has consistent scales. That is the case of algorithms like Regression, and K-Nearest Neighbors. These algorithms take advantage of rescaled datasets for different reasons. Regression because it weights input variables and K-Nearest Neighbors because it uses distance measures (Brownlee, 2019, p. 48). 4 2.2.1. Standardization Standardization (or z-score normalization) is the technique that rescales the data by transforming the mean of the distribution to zero and its standard deviation to one like a standard normal distribution (or standard Gaussian distribution) (Burkov, 2019, p. 39). It is represented by the following formula: y = (x – mean) / standard deviation Where mean is calculated as: mean = sum(x) / count(x) And the standard deviation is calculated as: standard deviation = sqrt( sum( (x – mean)ˆ2 ) / count(x) ) It is possible to standardize a dataset by using the class StandardScaler from Python’s library scikitlearn (“sklearn.preprocessing.StandardScaler — scikit-learn 0.23.2 documentation,” n.d.). 2.2.2. Normalization Normalization (or min-max normalization) is the technique that rescales the data by converting the actual range of values to a standard range of values. Usually, it is done in the interval between 0 and 1 or -1 and 1 (Burkov, 2019, p. 39). It is represented by the following formula: y = (x – min) / (max - min) Where min and max stand for the minimum and the maximum values of x in the dataset. 5 It is possible to normalize a dataset by using the class MinMaxScaler from Python’s library scikit-learn (“sklearn.preprocessing.MinMaxScaler — scikit-learn 0.23.2 documentation,” n.d.). 2.3. MODEL EVALUATION Model evaluation is an estimate of how well the model will perform in practice. Usually, to perform a model evaluation, the dataset is split between training and test sets. Model evaluation cannot be done using the same data as in training. Otherwise, any estimate of performance would be optimistic. If training data is used on evaluation, the algorithm is likely to score perfectly. However, there is a very good chance that the predictions will be wrong (Brownlee, 2019, p. 57). Therefore, the model evaluation must be done based on the test set. That is why the testing set is held back and it is an unseen data to the model. The algorithm never had contact with the testing set before model evaluation (Brownlee, 2018c, p. 145). Sometimes, the dataset is split into three parts: training, validation, and test sets. In this case, training data is used by the model to learn, validation data is utilized to select the best model, and to select parameters from estimates of performance and test data is employed, exclusively, to assess performance at the end of the process (Igual & Seguí, 2017, p. 82). 2.3.1. Train-Test Split Train-test split is the simplest method for model evaluation. And, if the dataset is large enough, both train and test splits could incorporate different patterns representing well the problem and the resulting estimate of performance could be consistent. Another positive aspect of the train-test split is that it is a fast method. Train-test split consists of splitting the dataset into two parts: training and test sets. One for training the algorithm and the other to make predictions and compare them to the already known values. That way, it is possible to calculate a performance metric and to assess the accuracy of the model. Figure 2-1 - Train and test splits in blue and orange respectively. The negative aspect of the train-test split is that differences in training and test sets could end up in dissimilarities in the estimate of performance (Brownlee, 2019, p. 58). It is possible to create a train-test split of the dataset by using the function train_test_split from Python’s library scikit-learn (“sklearn.model_selection.train_test_split — scikit-learn 0.23.2 documentation,” n.d.). 6 2.3.2. K-fold Cross-Validation K-fold Cross-Validation is a more robust method of model evaluation than Train-Test Split. That is because instead of a single train-test split, in cross-validation, the model is trained and evaluated multiple times on different data (Brownlee, 2019, p. 59). In K-fold Cross-Validation, the dataset is split into K-parts of equal size. These parts are known as folds. Then, the model is trained K times. Each time, the model is evaluated based on only one fold and it is trained using the remaining folds. This process is repeated in such a way that, by the end, every fold has performed the hole of validation data once. In the end, the K-fold Cross-Validation method provides K different accuracy values, that can be summarized using mean and standard deviation (Müller & Guido, 2016, p. 252). Split 1 Split 2 Training Data Split 3 Split 4 Test Data Split 5 Fold 1 Fold 2 Fold 3 Fold 4 Fold 5 Figure 2-2 – Split and fold scheme of a 5-fold cross-validation example. One of the positive aspects of K-fold Cross-Validation is that differences in the training and test sets are not as harmful as in Train-Test Split. For example, suppose that Fold 1 from Split 1 has data with a very distinct pattern when compared to Folds 2 to 5 also from Split 1. This would affect Split 1 performance score. But, by the time the model is trained for the second time with Split 2, the differences in Fold 1 are incorporated in the training data and represent a minor part of the training data. That is something that repeats through all the remaining splits until the end. Therefore, the impact of differences in training and test sets is minimized, resulting in a much more stable performance score. The main negative aspect of K-fold Cross-Validation is the computational cost since the model is trained K-times instead of once (Müller & Guido, 2016, p. 254). It is possible to apply K-fold cross-validation by using the class KFold and the function cross_val_score from Python’s library scikit-learn (“sklearn.model_selection.KFold — scikit-learn 0.23.2 documentation,” n.d.) (“sklearn.model_selection.cross_val_score — scikit-learn 0.23.2 documentation,” n.d.). 7 2.3.3. Multiple Train-Test Splits (applied to Time Series) K-fold Cross-Validation is not really suited for model evaluation of time series because it is a method that ignores the temporal components inherent to the problem (Brownlee, 2018c, p. 145). Train-Test Split, on the other hand, has the downside of high variance when training and test sets have differences in data (Brownlee, 2019, p. 58). So, for a Time Series Forecasting problem, a more appropriate method of model evaluation would be Multiple Train-Test Splits. Multiple Train-Test Splits consists of repeating the process of splitting the dataset into training and test sets several times. In each iteration, the training set gets larger and the test set remains the same for the sake of comparability among the performance scores obtained (Brownlee, 2018c, pp. 148, 149). Figure 2-3 - Multiple Train-Test Splits created by TimeSeriesSplit configured for 5 splits. It is possible to create multiple splits of a times series by using the class TimeSeriesSplit from Python’s library scikit-learn. The training set size is calculated by the following formula (“sklearn.model_selection.TimeSeriesSplit — scikit-learn 0.23.2 documentation,” n.d.): training set size = (i * (samples / (splits + 1))) + samples mod (splits + 1) Where i is the split iteration, samples is the number of samples, and splits is the number of splits desired. The part samples mod (splits + 1) is the remainder of the division of the number of samples by the number of splits plus one. Meanwhile, the test set size is calculated as follows (“sklearn.model_selection.TimeSeriesSplit — scikit-learn 0.23.2 documentation,” n.d.): 8 test index = samples / (splits + 1) Where samples is the number of samples and splits is the number of splits wanted. Below, an example of Multiple Train-Test Splits set to create 5 splits out of a dataset with 988 observations: Figure 2-4 - Example of 5 splits created by TimeSeriesSplit. 2.4. PERFORMANCE METRICS A Time Series Forecasting problem is a regression problem. And a regression problem is focused on the prediction of real values. A direct way to evaluate time series forecasts is based on the difference between the predicted values and the expected values. Three common performance metrics for Time Series Forecasting problems are: Mean Absolute Error, Mean Squared Error, and Root Mean Squared Error. 2.4.1. Mean Absolute Error (MAE) The Mean Absolute Error (MAE) is a performance metric calculated as the average of the absolute differences between the predicted values and the expected values. This measure has as a positive aspect the fact that is simple and that it indicates the magnitude of the error. However, it has as its negative aspect the fact that it does not inform the direction of the error, because the differences are being forced as positive values (Brownlee, 2019, p. 67) (Skiena, 2017, p. 221). 9 The Mean Absolute Error is represented by the following formula: mae = mean( abs( expected values – predicted values ) ) The Mean Absolute Error can be calculated by the function mean_absolute_error from Python’s library scikit-learn (“sklearn.metrics.mean_absolute_error — scikit-learn 0.23.2 documentation,” n.d.). 2.4.2. Mean Squared Error (MSE) The Mean Squared Error (MSE) is a performance metric calculated as the average of the squared differences between predicted values and the expected values. As in MAE, the differences are being forced to become positive values but, this time, by squaring and not by making them absolute. Squaring has the potential side effect of outliers dominating the error statistics. The MSE metric has the benefit of large error values contributing more to worsening the performance score. Therefore, it is an informative measure, especially, for noisy instances (Brownlee, 2019, p. 68) (Skiena, 2017, p. 222). The Mean Squared Error is represented by the following formula: mse = mean( (expected values – predicted values)ˆ2 ) The Mean Squared Error can be calculated by the function mean_squared_error from Python’s library scikit-learn (“sklearn.metrics.mean_squared_error — scikit-learn 0.23.2 documentation,” n.d.). 2.4.3. Root Mean Squared Error (RMSE) The Root Mean Squared Error (RMSE) is a performance metric that is simply the square root of the Mean Squared Error. The positive aspect of the RMSE is that it is on the same scale as the original values and, therefore, its magnitude is much more interpretable (Skiena, 2017, p. 223). The Root Mean Squared Error is represented by the following formula: rmse = sqrt( mean( (expected values – predicted values)ˆ2 ) ) 10 The Root Mean Squared Error can be calculated by the function mean_squared_error from Python’s library scikit-learn. In recent versions of the scikit-learn library, in v0.23.1 for sure, function mean_squared_error has a parameter called squared that, when set to False, returns RMSE value. The default value is True, though. (“sklearn.metrics.mean_squared_error — scikit-learn 0.23.2 documentation,” n.d.). 2.5. MACHINE LEARNING MODELS 2.5.1. Linear Algorithms 2.5.1.1. Linear Regression The Linear Regression algorithm uses a linear function of the input variables to make predictions. Linear Regression is also known as Ordinary Least Squares. In Linear Regression, the predicted value is thought as the weighted sum of the input variables. Linear Regression can represent predictions as a line for a single feature, as a plane for two features or as a hyper-plane for more features (Müller & Guido, 2016, pp. 45–47). The objective in Linear Regression is to find the plane that minimizes the Sum of Squared Errors (SSE) between predictions and true values (Kuhn & Johnson, 2013, p. 105). Linear regression has as positive aspects the fact that is easy to compute and that the coefficients, the weights in the sum of the input variables, are directly interpretable. Linear Regression has a couple of restrictions, though. An input variable cannot be determined from a combination of one or more of the other input variables (collinearity). And the number of observations must be greater than the number of input variables. Otherwise, it is impossible to reach a unique linear combination of the features to represent the target (Kuhn & Johnson, 2013, p. 108). Since Linear Regression has no parameters, it has no way to control model complexity (Müller & Guido, 2016, p. 47). 2.5.1.2. LASSO Regression LASSO (Least Absolute Shrinkage and Selection Operator) Regression is another linear model for regression. The prediction is also thought of as the weighted sum of the input variables like in Linear Regression. However, the weights, which are the coefficients, are not only chosen to predict well on training data but also to respect a constraint. The idea of having a constraint to control model complexity and to avoid overfitting is known as regularization (Müller & Guido, 2016, p. 53). In LASSO regression the constraint restricts the magnitude of the coefficients to be close or equal to zero. This type of regularization, where the sum of the absolute values of the regression coefficients is penalized, is known as L1 regularization. When the L1 regularization forces coefficients to be zero, in practice, the LASSO regression algorithm is performing a feature selection. Hence, the Selection Operator in the name of the method. LASSO regression achieves both improving the model quality and conducting variable selection by applying L1 regularization (Dinov, 2018, p. 579). 11 2.5.2. Nonlinear Algorithms 2.5.2.1. K-Nearest Neighbors The K-Nearest Neighbors algorithm can be applied to a classification (K-Neighbors Classification) or a regression (K-Neighbors Regression) problem. It is a straightforward algorithm, easy to interpret, and the main logic is the same for both cases. The training phase consists only of storing the data points. Later, to predict, the algorithm just finds the k-closest data points in the training data, which are considered the nearest neighbors. In the simplest version of the K-Neighbors Regression, where K is defined as one, the prediction is just the target value of the nearest neighbor. When K is larger than one, the prediction is the mean of the K-nearest neighbors (Müller & Guido, 2016, pp. 35, 40, 41). K-Nearest Neighbors algorithm can be applied through the KNeighborsRegressor class of Python’s scikit-learn library. The distance metric used as default is the Minkowski distance, which is a generalization of the Euclidean distance and the Manhattan distance (Brownlee, 2019, p. 80). Since the power parameter for the Minkowski distance is set as 2 by default, the Euclidean distance is applied if not otherwise configured. When the power parameter is set as 1, Manhattan distance is employed (“sklearn.neighbors.KNeighborsRegressor — scikit-learn 0.23.2 documentation,” n.d.). The positive aspects of the K-Nearest Neighbors algorithm are that it is easy to understand and that it achieves reasonable performance scores without many adjustments. These characteristics make it a good baseline method. The downside of the K-Nearest Neighbors algorithm is that it is not fast when the training dataset is very large, even more, because it is an algorithm that requires pre-processing. Other than that, it is an algorithm that doesn’t deal well with a dataset where most values are zeros either (Müller & Guido, 2016, p. 44). 2.5.2.2. Classification and Regression Trees Decision Trees or Classification and Regression Trees (CART) is another algorithm that also can be used to classify or to predict. Classification or numeric prediction trees are built based on the same logic. Multiple if-else logical decisions are used to partition the data via a divide-and-conquer strategy based on features (Dinov, 2018, p. 373). The Decision Trees algorithm builds a tree through the recursive process of searching over all possible splits within the dataset the one that is most informative about the target variable. The recursive partitioning of the data results in a tree of decisions that has nodes and leaves. In Regression Trees, nodes contain tests like “is feature a larger than value b?”. Leaves are terminal nodes that contain answers. In Regression Tress, for instance, a regression value (Müller & Guido, 2016, pp. 71–73). The Decision Trees algorithm has the upside of being easy to implement and highly interpretable. Besides, decision trees can handle many different types of input variables without pre-processing. Decision trees can also handle missing values and, because of the logic to build the trees, can perform feature selection either. However, decision trees do have negative aspects. One of them is model instability because minor changes in the data can affect the tree structure, compromising interpretability. Another one is predictive performance. Decision trees will have larger prediction errors if the relationship between input variables and target variables cannot be represented as rectangular subspaces of the input variables (Kuhn & Johnson, 2013, p. 174). 12 2.5.3. Ensemble Algorithms 2.5.3.1. Random Forest Random Forest is an Ensemble method of the type Bagging. A Bagging or a Bootstrap Aggregation algorithm trains the model multiple times based on subsets of the dataset. By the end, the prediction is obtained by averaging all the results collected from the multiple trained models. Through this approach, Bagging tries to reduce the variance of the prediction (Brownlee, 2019, p. 92). The Random Forest algorithm is a generalization of the Bagging method applied to Decision Trees. In Random Forest, randomness is inserted in the process of building the decision tree. Instead of choosing the best split point from the entire dataset, only a random sample from the original data, with replacement, is considered. The main idea is to use random decision trees and, by doing so, provide less correlation among different ensemble components (Aggarwal, 2015, p. 380). 2.5.3.2. Gradient Boosting Machines Gradient Boosting Machines are an Ensemble method of the type Boosting. A Boosting algorithm creates a sequence of models. The main idea is that each subsequent model tries to correct the mistakes from the previous model (Brownlee, 2019, p. 94). The basic principle of Gradient Boosting Machines is based on two things: a loss function and a weak learner. A loss function is a measure that indicates how good a combination of the coefficients fits the data (Müller & Guido, 2016, p. 56). For instance, squared error for regression. A weak learner is a model that can only provide good predictions on part of the data (Müller & Guido, 2016, p. 89). For instance, a shallow tree. The main goal of the algorithm is to search for an additive model out of the weak learners that can minimize the loss function (Kuhn & Johnson, 2013, pp. 204–206). Gradient Boosting Machines are also referred to as Stochastic Gradient Boosting but, actually, Stochastic Gradient Boosting brings a minor tweak. It borrows the idea of random sampling the training data from Bagging to reduce prediction variance (Kuhn & Johnson, 2013, pp. 204–206). 2.6. DEEP LEARNING 2.6.1. Neural Networks Artificial Neural Networks or just Neural Networks are a family of Machine Learning algorithms that encompasses different methods like Multilayer Perceptrons (MLP), Convolutional Neural Networks (CNN), and Recurrent Neural Networks (RNN). Deep Learning and Neural Networks are considered to be the same field. Deep Learning is a kind of learning based on deep neural networks, networks that have several stacked layers to improve their predictive capability (Skansi, 2018, p. preface V). 19 analyzing, not just the algorithmic and statistical aspects. Data Science covers data integration, data engineering, data visualization, Data Mining, Business Intelligence, etc. (Granville, 2017). A successful data scientist is compelled to see a business problem from a data perspective. Although Data Science is a comprehensive field, most of the attention of the scientific community and organizations are focused on Machine Learning, particularly on predictive analytics. Machine Learning is a kind of Artificial Intelligence that uses algorithms to extract patterns out of the data. These algorithms can learn from data as they are being trained. In this process of learning, they can improve their performance based on experience. In the end, a refined model is achieved that can be used to predict outcomes from unseen data based on the previous learning (Kirk, 2014, p. 2) (Bell, 2015, p. 2). There are many use cases for Machine Learning in the energy and environment sectors, like using predictive analytics to pick the best location for wind farms (Hardesty, 2015) or to analyze pollution data and make predictions about air quality (IBM Research Editorial Staff, 2016). In reality, the convergence of Machine Learning and the Internet of Things leads to possibilities that both technologies alone could never achieve. For instance, Machine Learning allows IoT to provide AI- powered analytics platforms capable of continuous analytics, besides predictive and prescriptive analytics (Ruzicka, Lawrence, Chaudhri, Jacquet, & Smith, 2018). Since Data Science popularity is a recent fact, some concerns are surrounding the matter. The most common issue is that some companies haven’t yet realized the benefits of Data Science. There are a couple of reasons for that, like the lack of data quality, data scattered in silos, failure to define a problem to solve, and insufficient skilled professionals (Ruzicka et al., 2018). In fact, there is a shortage of talent because good professionals must be skilled in math, statistics, programming, database, and business knowledge. 3.5. MARKET ANALYSIS AND BIG PLAYERS INITIATIVES Although an advanced energy management system is based on computational intelligence from new technology, this is far from being the only reason why the market does not present many options. One other reason might be the difference in investments between Data Science projects oriented to HVAC systems and industrial systems. There are already applications in different industry sectors, such as turbine control, preventive maintenance, or other production processes. However, in the case of HVAC systems, besides relevant expectations, motivation, and scientific development on how to apply Machine Learning techniques (Smith & Lasch, 2016), there are not significant products available in the market. The reason why Data Science projects for industrial systems are preferred when it comes to investments relies on the fact that much of the research is concentrated in intensive applications of capital and energy, like manufacturing and energy production. When HVAC systems are compared with this kind of application, it does not present the same amount of consuming nor the same potential return on investment. On the other side, the general dissemination of HVAC systems is much greater, which means that the sum of consumption of all HVAC systems reaches representative 20 marks. This makes valid any improvement in this field and is starting to catch the attention of big players from IT (Information Technology) and engineering. Some companies are already aware of the benefits of applying computational intelligence to energy management systems through IoT, Big Data, and Data Science initiatives. One good example is Google that through an artificial intelligence research project called DeepMind uses an ensemble of deep Neural Networks to reduce the energy bill of its data centers (Evans & Gao, 2016). Another example comes from a partnership between IBM (Internet Business Machines) and international researchers to develop a solution to operate HVAC systems in three major commercial buildings located in Hong Kong through Machine Learning techniques (Vishwanath, 2018). 3.6. AMBIOSENSING CONCEPTUAL ARCHITECTURE Since the market is absent in terms of energy management systems for buildings that integrate computational intelligence at competitive cost ready to work with HVAC or other systems, the Ambiosesing system is being developed to fill this gap. Ambiosensing conceptual architecture is an initial reference to show the main components and functionalities of the system regardless of any technological specification. The proposed architecture is divided into layers to better designate responsibilities and identify dependencies. Each layer has a specific purpose and upper layers can use lower-layer services, but not the other way around. 21 Figure 3-1 Ambiosensing Conceptual Architecture 3.6.1. Base Platform Figure 3-2 - Base Platform Layer 3.6.1.1. IoT Connectivity The IoT Connectivity component allows devices to connect to the Ambiosensing system via Internet through IoT's most common communication protocols, like HTTP (Hypertext Transfer Protocol), 22 MQTT (Message Queuing Telemetry Transport) and CoAP (Constrained Application Protocol). These devices could be sensors, actuators, microcontrollers, or single-board computers like Raspberry Pis. 3.6.1.2. Storage and Data Management The Storage and Data Management module is not only responsible to support data storage, but also to enforce suitable access rights and proper privacy levels. It has to keep records of all telemetry data from environmental variables and all attribute data from energy profiles, customers, assets, devices, etc. 3.6.1.3. Data Access Management The Data Access Management component provides control over user and data services accesses. Through the configuration of access policies, it grants correct use rights to the database. 3.6.1.4. Environmental Data Acquisition Management The Environmental Data Acquisition Management module is responsible for configuring data collection for environment variables. Each environment variable reading can have a different requirement in terms of periodicity or measuring unit. 3.6.1.5. Environmental Variables Control The Environmental Variables Control component is responsible for maintaining the relationship between inputs (environment variables) and devices. A device can have different types of sensors attached to it and even more than one sensor at a time. So, a single device can be able to register different environment variables. 3.6.1.6. Energy Equipment Management The Energy Equipment Management unit is accountable for facilitating equipment configuration and administration. It provides an equipment catalog to register and organize all connected devices. It is important to notice that some devices, such as sensors and Raspberry Pi’s, can be put together and can have an abstracted representation as a single device for the Ambiosensing system. The capability to manage all these kinds of equipment relationships is the responsibility of the Energy Equipment Management component. 23 3.6.1.7. Software Services Management The Ambiosensing system provides a catalog of web services to make functionalities supported by lower-layer components available to upper layer modules. These web services also grant to Ambiosensing the ability to externalize functionalities to other systems. The Software Services Management module provides not only administration capabilities over these web services but also documentation like web services specification (request syntax and parameters, response messages, etc.). 3.6.2. Supervision Services Figure 3-3 - Supervision Services Layer 3.6.2.1. User Registration and Management The User Registration and Management component is responsible for user administration. It provides the Ambiosensing system with the capability to manage user profiles and preferences and also to group users accordingly with common aspects. 3.6.2.2. Basic Profiles Management The Basic Profiles Management module allows administration over operating profiles of spaces. These profiles are created by an administrator user and can be based on specifics such as type of use 24 (e.g. office, store, warehouse, etc.), number of occupants, schedules, and other important information that might help to adjust the controlled environmental variables. 3.6.2.3. Analysis and Decision Support The Analysis and Decision Support unit provides the needed mechanisms so the user can analyze the operation of a space and, in this way, can be able to make wise decisions that contribute to less energy consumption. All this is achieved through cross-referencing environmental variable measures and data of equipment in operation. The Analysis and Decision Support module also allows the user to keep track of the energy-saving provided by the system throughout its operation. 3.6.2.4. Historical Data Management The Historical Data Management component is responsible for the administration of telemetry data collected and stored in the system. This time-series data can be from environmental variables readings or events that occurred in the system. No matter what source, historical data tends to be a large amount of data with time and needs to be managed accordingly to a lifecycle. This means that, when historical data gets huge, the system can “retire” the data by one of the two following strategies: data aggregation (e.g. old data stored by the minute is aggregated by the hour) or changing data storage type (e.g. withdraw data from database and store it on files). 3.6.2.5. Basic Intelligent Supervision The Basic Intelligent Supervision unit is composed of three modules: Planning, Monitoring, and Failure Detection and Recovery. The Planning component allows the setting of an operational plan based on system parameterizations done by an administrator user. This plan must be put in place and have direct interaction with environmental variables, both in acquisition and intervention. The Monitoring module enables operational plan monitoring based on initially defined parameters, making it possible to detect deviations from the correct operation. The Failure Detection and Recovery component is responsible not only for detecting operations beyond a pre-defined acceptance threshold by also for providing recovery capabilities. Failure recoveries could be achieved by following a recovery plan initially set on the system along with the operational plan or by the intervention of a human operator with the appropriate user rights to do so. 3.6.3. Advanced Services 25 Figure 3-4 - Advanced Services Layer 3.6.3.1. Advanced Profiles Management The Advanced Profiles Management module provides suggestions of the best operating profile of spaces considering the current condition in which the Ambiosensing system is working. The Advanced Profiles Management differentiates itself from Basic Profiles Management from Supervision Services in the sense that its suggestions are generated automatically by the system taking into consideration several parameters that may interfere with controlled environmental variables. In Basic Profiles Management it is up to an administrator user to create the operating profile of spaces. The Advanced Profiles Management can be set to run automatically or by user confirmation. 3.6.3.2. Alarms and Recommendation System The Advanced and Recommendation System component is responsible for detecting situations that might raise an alarm based on data analysis from telemetry and event data. The Monitoring module from the Basic Intelligent Supervision unit works closely with the Alarms and Recommendation System component. Every improper operation is flagged and an alarm is sent to the most suitable user informing what happened and the recommended measures. 3.6.3.3. Simulation of Scenarios The Simulation of Scenarios module provides the Ambiosensing system with the capacity of doing simulations on possible utilization scenarios of a space. This way it is possible to anticipate and elaborate operating strategies that are most suitable for the desired conditions. The Simulation of 26 Scenarios allows to assay the use of existing and desired equipment along with diverse operation conditions. 3.6.3.4. Audit and Reporting The Audit and Reporting component allows administrator users to follow system operations and to track actions and configurations done by users in the system. Through the use of dashboards, it is possible to analyze the system's operational status. And, using reporting, it is possible to review the footprints that each user has left in the system, granting audit capabilities to Ambiosensing system. This auditing competence of the Ambiosensing system is configurable accordingly to the local legal regulations from where the system is being implanted. 3.6.3.5. Self-Adaptive Energy and Performance Management The Self-Adaptive Energy and Performance Management module allows the system to identify specific circumstances in which its operation in no longer the most suitable one and it is still possible to adapt its operational profile to optimize performance. It is only possible to identify these situations through the use of intelligent services monitoring continuously current telemetry data. The system also uses historical telemetry data to define a performance baseline and to evaluate whether an operational profile adaptation will have a real advantage or not. In cases where a change in the operational profile is beneficial, it may occur automatically or by the consent of a properly granted user. 3.6.3.6. Energy Performance Pattern Analysis The Energy Performance Pattern Analysis component is responsible for analyzing system operation and detect operation patterns directly correlated with energy performance. To be able to do so, the Ambiosensing system evaluates environmental variables, equipment setups, spaces attributes, and other important variables that may interfere in the balance of occupant well-being and energy consumption. Based on this assessment, the system identifies and classifies energy performance patterns and corresponding operational profiles. 3.6.4. Ambiosensing Applications The top layer in Ambiosensing Conceptual Architecture is Ambiosensing Applications. This component is composed of interaction applications designed for end-users that allow execution of Ambiosensing system use cases such as: § Set up environmental variables; § Set up sensors; § Set up actuators; § Set up building plants (spaces); 27 § Create energy profiles; § Manage energy profiles; § Monitor environmental variables; § Monitor sensors; § Monitor actuators; § Analyze energy behavior; § Visualize alarms; § Query historical data; § Simulate scenarios; § Predict scenarios; § Generate audit reports; § Generate energy consumption dashboards; § Register user preferences; § Manage users. 3.7. DATA COLLECTION AND AMBIOSENSING OVERVIEW One of the greatest challenges of the Ambiosensing project is data collection. Hopefully, recent technological developments in IoT and Big Data contributed to advances in multiple computational tasks needed to device communication and coordination and data processing and storage. Definitely, the emergence of IoT platforms and Big Data frameworks for dealing with massive amounts of data and computation are among these recent technological breakthroughs. The Ambiosesing system consists, basically, of two types of hardware: the Ambiosensing devices and the Ambiosensing central unit. Ambiosensing devices are scattered around the environment in which they are operating and can have up to two roles: sensor and actuator. Ambiosensing central unit is a component of the greatest importance. As the name implies, it is a fundamental module where all telemetry data is consolidated for storage, processing, and analysis. Ambiosensing devices have as their main goal the capturing of electric signals from sensors attached to it and the conversion of these signals to digital values accordingly to pre-defined measurement units. For instance, in case of temperature to Celsius degree, in case of relative humidity to percentage and in case of luminosity to lux (lux is the unit from the International System of Units to measure luminous flux per unit area) (“IEC 60050 - International Electrotechnical Vocabulary - Details for IEV number 845-01-52: ‘lux,’” n.d.). Ambiosensing devices have some data aggregation and storage capacity especially useful in case of network failure. However, its processing power is not suitable for the amount of data to be handled and, as such, it is expected that Ambiosensing devices send telemetry data to Ambiosensing central unit. Figure 3-5 shows a schema of an Ambiosensing device with three sensors attached to it: luminosity, humidity, and temperature sensors. An Ambiosensing device is composed also of a controller element, which is, usually, a Raspberry Pi single-board computer. 28 Figure 3-5 - Ambiosensing Device Ambiosensing central unit is not only responsible for collecting telemetry data from all devices that are present in a monitored space. Ambiosensing central unit is also in charge of dispatching commands to control equipment that affects the controlled environment, such as HVAC systems. Since Ambiosensing central unit must perform many IoT functions, such as collect and store telemetry data and provision, monitor and control IoT devices, it makes sense that part of the Ambiosensing central unit is composed of an IoT platform. However, as the Ambiosensing central unit has goals that exceed the IoT platform's capabilities, it cannot be completely based on an IoT platform. An IoT platform may cover all modules from the Base Platform layer of the Conceptual Architecture and even a couple of components from Supervision Services and Advanced Services layers, such as User Registration and Management and Audit and Reporting, respectively. Figure 3-6 presents Ambiosensing central unit and Base Platform services and some top layers services as part of an IoT Platform. 35 library Numpy (“NumPy Manual,” n.d.) was applied to do calculations on the dataset and Python’s library scikit-learn (“Scikit-learn Documentation,” n.d.) provided most of the Machine Learning algorithms. Originally, the raw data were presented as the following dataset: Figure 4-3 - Original dataset. The following data transformations were done in data loading as an initial data preparation: § Date converted from Linux timestamp to date; § Key and Value columns were pivoted to denormalize the dataset. After initial data transformations, the dataset was presented as follows: Figure 4-4 - Dataset after initial data preparation. Below, a brief explanation of each dataset variable: § C2H5OH – Ethanol gas measure in ppm; § C3H8 – Propane gas measure in ppm; § C4H10 – Iso-butane gas measure in ppm; § CH4 – Methane gas measure in ppm; § CO – Carbon Monoxide gas measure in ppm; § CO2 – Carbon Dioxide gas measure in ppm; § Celsius – Temperature in Celsius degree; § Fahrenheit – Temperature in Fahrenheit degree; § H2 – Hydrogen gas measure in ppm; § Humidity – Relative humidity in % (percentage); § NH3 – Ammonia gas measure in ppm; § NO2 – Nitrogen Dioxide gas measure in ppm; § Pressure – Atmospheric pressure in the equivalent units hPa (hectopascal) or mbar (millibar). 36 The dataset has data from July 23rd of 2019 to Jan 23rd of 2020, resulting in a total of 228.307 observations. 4.3.2. Data Checking and Data Cleansing The Data Checking and Data Cleansing step has the objective to inspect the dataset and remove data collected inaccurately. By simply checking the average and the count by day of some features, like for instance Celsius, that represents indoor ambient temperature, it was possible to find some possible gaps in data collection. In the first months of the Ambiosensing project, the collector program developed in Python that goes inside the devices with all the logic for collecting and sending data to the IoT platform Thingsboard lacked local storing capability and, because of that, it didn’t have a fault-tolerant mechanism implemented. Later in the project, it was corrected, but, by then, the dataset already had two gaps of data for some days that had to be treated in the Missing Values Treatment step of the Data Science framework. There were two gaps in the dataset. One of seven days from August 16th to August 23rd of 2019 and another one of seventeen days from December 29th of 2019 to January 15th of 2020. Another issue also contributed to inaccurate data collection. The Grove Multichannel Gas sensor from the Ambiosensing Device has a unique characteristic. It needs some time to warm up. Until then, readings are very erratic. Because of that initial readings of the dataset and readings right after the two data gaps were inspected carefully. July 23rd, the initial date of data collection, had very few observations since the device was turned on late at night. July 24th had a lot of discrepancies because the sensor was still warming up. Because of that, data from July 23rd and 24th were removed from the dataset. Since data capture was resumed from data gaps on August 23rd for the first one and on January 15th for the second one, those days were also removed from the dataset to avoid completely inaccurate data. 4.3.3. Missing Values Treatment The Missing Values Treatment step aims to handle missing values by filling them with data. Because of the unexpected two data collection interruptions explained in the Data Checking and Data Cleansing step, the dataset required a consistent data imputation. The Missing Values Treatment step was divided into three parts: dataset preparation, a study of the most appropriate data imputation method for each feature, and data imputation itself. First, the dataset needed to be prepared for data imputation. New records were created for the two missing time frames with null values by the minute, almost as it should be if data were captured correctly. Besides that, all other variables, like the date-time features further explained in the Feature Engineering step, were also created. In the end, the observations generated were just like the ones captured from sensors, with the same data types, in the right order, but with null values. 37 Figure 4-5 - Data captured from the sensors. Figure 4-6 - Data generated for data imputation. After dataset preparation, some data imputation methods for time series were tested. A section of the dataset without missing values was extracted and transformed to perform the tests. The idea behind this evaluation is to hide the known values, execute the data imputation methods on fake missing values, and then compare the results of the different methods with the original non-null values. In the end, the most effective method for data imputation in time series should be determined for each feature. Steps taken to test different data imputation methods: 1. The dataset was filtered. Only a sample of the dataset was selected to be tested. A sample of 50.000 rows was taken; 2. The dataset sample was split into three parts to create the missing values observations in the middle one (out of the 50.000 rows, the first and the last 20.000 were not transformed, only the 10.000 in between were transformed to null values in every feature); Figure 4-7 - Dataset with original columns and null columns. Five rows out of the 10.000 transformed. 38 Figure 4-8 - Dataset with original columns and replicated columns unaltered. Five rows out of the 40.000 not transformed. 3. The dataset sample was joined back together to create the whole test sample; By this point, for every feature, there were two columns: one with the original value and a replica “_test” column with missing value if previously transformed or with the original value if not. 4. For every feature, the original column was taken as reference and the replica “_test” column was set as the target; 5. Data filled using mean and median; 6. Data imputed using the rolling average; 7. Data imputed using the rolling median; 8. Data imputed using interpolation with different methods: linear, time, quadratic, cubic, slinear, akima, polynomial of order 5 and 7, spline of order 3, 4 and 5; 9. The results were scored using scikit-learn metric R2 score and a table was created with the top result by feature. Below, an example of a feature before and after data imputation (sample dataset): 39 Figure 4-9- Sample dataset of Celsius feature before data imputation. Figure 4-10 - Sample dataset of Celsius feature after data imputation. In the last part of the Missing Values Treatment step, data imputation was applied to the whole dataset following the table created with the method with the highest score by feature. 40 Table 1 - The best method for each feature by R2 score. Below, an example of a feature before and after data imputation (whole dataset): Figure 4-11- Whole dataset of Celsius feature before data imputation. 41 Figure 4-12 - Whole dataset of Celsius feature after data imputation. After the removal of initial readings and of the first readings right after the identified data gaps, the dataset was reduced. After the first part of data imputation, the dataset preparation to receive imputed values, the dataset was incremented. Originally with 228.307 rows, after these two steps, the dataset had 263.357 observations. Out of these 263.357 records, 37.440 had missing values. So, the missing values accounted for 14,22% of the dataset. The Missing Values Treatment step eliminated all null values from the dataset. 4.3.4. Outliers Treatment The Outliers Treatment step has the objective to detect and replace data points that differ significantly from other observations. The Outliers Treatment step was divided into three parts: outliers identification, outliers removal, and data imputation post outliers treatment. The main idea behind dealing with outliers is to pinpoint outliers through the application of a statistic method called IQR (Interquartile Range). After that, to delete outliers, they were simply replaced with null values. As the last step in the process of treating outliers, null values were replaced through data imputation following the same top recommended method for each feature as identified in the Missing Values Treatment step. Steps taken to detect and replace outliers: 1. Since the Data Science process was conducted using Python, the dataset was converted from a Pandas dataframe to three Numpy arrays. The first and last Numpy arrays contained variables without the possibility of having outliers; 2. A function to identify outliers and replace them with null values was developed; a. The IQR was calculated as the difference from percentile 75th and 25th; IQR = Q75 – Q25 42 b. The outlier cutoff was calculated as the multiplication of IQR by a factor K and the lower and upper boundaries were established like percentile 25th minus the cutoff and percentile 75th plus the cutoff, respectively; cutoff = IQR * k lower = Q25 – cutoff upper = Q75 + cutoff Obs.: Usually, the K factor is set as 1.5 for outliers and 3 for extreme outliers (Tukey, 1977, p. 44). In this case, a K factor of 3 was used. c. Values lesser than the lower cutoff or larger than the upper boundary were identified as outliers and replace by null values. 3. Variables likely to have outliers from the Numpy array in the middle were iterated and the function was applied; 4. After detecting and removing the outliers, the Numpy arrays were concatenated back together; 5. The resulting Numpy array was converted back to a Pandas dataframe. 6. As a final step, data and data types were double-checked to make sure that the final dataset was equivalent to the initial one, but without outliers. The last part of Outliers Treatment step is to impute data where once were the outliers and now missing values can be found. By applying, for each feature, the top-recommended method for data imputation, almost all missing values created by outliers removing have been replaced by a consistent value. An interesting fact must be highlighted. Because three features, C3H8, C4H10, and CH4 gases’ readings presented outliers in the initial of the dataset, the null values that replaced the outliers at the beginning of the dataset were not changed by the top-recommended method for data imputation. That occurred because the top method in all three cases was the slinear method, a kind of interpolation. And interpolation methods create a bridge between the two edges data points in the data gap. Without the first edge data point from the data gap, it is not feasible to use interpolation. For that reason and because outliers were not in place anymore, to fill the null values from the beginning of the dataset for features C3H8, C4H10, and CH4, the median of each series was applied as a data imputation method. 43 Table 2 - Features and the number of null values after data imputation first and second iterations. 4.3.5. Descriptive Statistics The Descriptive Statistics step has the objective to present a statistical summary of each time-series feature. Eight statistical properties are showed: count, mean, standard deviation, minimum value, 25th percentile, median, 75th percentile, maximum value. Figure 4-13- Time-series features summary statistics. 4.3.6. Data Visualization The Data Visualization step has as objective to better understand the dataset by analyzing graphically one feature at a time and to identify temporal structures like trends, cycles, and seasonality. 44 Five different types of plots were employed: line plot, histogram, box and whisker plot (by month), lag scatter plot, and autocorrelation plot. Line plots were used to analyze all the observations of each feature by time to detect trend and seasonality. Histograms were utilized to evaluate, without the temporal ordering, the distribution of observations for each input variable. On the other hand, box and whisker plots were applied to examine the distribution of values by time interval. In this case, by month. Lag scatter plots were used to explore the relationship between each observation and itself from a previous timestep. Finally, autocorrelation plots were employed to quantify the strength and type of relationship between observations and their lags (Brownlee, 2018c, p. 50). As an example, below all five plots from feature Celsius: Figure 4-14 - Feature Celsius line plot. Figure 4-15 - Feature Celsius histogram. 51 Figure 4-29- Dataset after data transformations for feature selection. Variables from the beginning of the dataset. Figure 4-30- Dataset after data transformations for feature selection. Variables from the end of the dataset. 4.3.8.1. Feature Selection of All Variables After getting the dataset ready, all variables were fed to the Random Forest model and the feature importance scores were obtained. Below, a table with all the features and their respective feature importance scores. 52 Table 3 - Features and feature importance scores. Next, two plots with feature importance scores, the first one with all the features and the second one with the top two features by importance taken out to a clear perspective of other variables. 53 Figure 4-31- Features x Feature Importance Scores. Figure 4-32 - Features x Feature Importance Scores (without top two features). After feature importance analyzes, feature selection was performed. An RFE (Recursive Feature Selection) algorithm from Python’s library scikit-learn was used. RFE algorithm demands a predictive model and again a Random Forest model was employed (Brownlee, 2019, p. 53). 54 Below, the list of selected features and a plot with their ranks. Figure 4-33- List of selected features by the RFE algorithm. Figure 4-34 - Features x Feature Ranks by RFE algorithm (lower is better). By the nature of some selected features, they seem to be highly correlated. So, before the final set of features, a correlation analysis was carried out. Since Pearson’s correlation coefficient assumes a normal distribution of the attributes (Brownlee, 2019, p. 35) and since the selected features didn’t present this characteristic, as can be seen in the histograms below, Kendall’s correlation coefficient was applied (Dalgaard, n.d., p. 124). 55 Figure 4-35 - Histogram of selected features. Below, the correlation matrix created using Kendall’s correlation coefficient. 56 Figure 4-36 - Correlation matrix. After analyzing the correlation matrix, some insights were extracted: 1. Date is highly correlated to Date_Period and it should be removed from the selected features; 2. C2H5OH is highly correlated to CO and CO has a bigger importance score. So, C2H5OH should also be removed from the selected features; 3. C4H10 is highly correlated to C3H8 and C3H8 has a bigger importance score. So, C4H10 should be removed too from the selected features; 4. Lastly, H2 is highly correlated to CO and CO has a bigger importance score. So, H2 should be removed as well from the selected features. After finishing the Feature Selection for All Variables part, the dataset was presented as follows: 57 Figure 4-37 - Final dataset for Deep Learning models. In the end, the final dataset had 1.098 observations, ten features, and the target variable. This dataset was later used with the Deep Learning models. 4.3.8.2. Complementary Feature Selection of Lag Features The complementary feature selection was focused only on the lag features for the Machine Learning models other than Deep Learning. As explained in more detail in the Feature Engineering step, these models have to harvest temporal context out of lag features. The complementary feature selection objective is to define which lag feature should be added to the previously selected features. Differently from the feature selection conducted previously for all variables, feature importance scores, and feature selection ranks were not calculated immediately. Since the complementary feature selection is about lag features, first, lag variables were evaluated with the help of an autocorrelation plot. Also, before exploring lag features through an autocorrelation plot, time-series components like trend or seasonality were removed if present (Brownlee, 2018c, p. 131). Below, a plot of the complete series of the target variable Celsius. Figure 4-38 - Celsius feature series. 58 As can be seen from the plot, the Celsius series presents a decreasing trend. Because of that, to remove the trend from the Celsius series the differencing method was applied (Brownlee, 2018c, p. 114). After removing the trend component, the Celsius series was presented as follows: Figure 4-39- Celsius features series after trend removal. Once the Celsius series didn’t present a trend anymore, it was possible to create the autocorrelation plot. Next, the autocorrelation plots of the two hundred first data points of the Celsius series. 59 Figure 4-40 - Autocorrelation plot for the 200 first data points of the Celsius feature. Since the dots below or above the blue area indicate statistical significance, the correlated data point that lasts the longest is data point 36. It represents a positive correlation. As each six data points represent one day, this means that the temperature from 6 days before still has some degree of correlation. After this important conclusion, the Celsius series was transformed into the dataset showed below with timesteps t-36, t-35,… , t-2, t-1, and t. This dataset was used to perform both feature importance scoring and feature selection ranking afterward. Figure 4-41 - Celsius series with the oldest lag features. 60 Figure 4-42 - Celsius series with the most recent lag features. After getting the dataset ready, the whole process to calculate feature importance scores and feature selection ranks was repeated just like it has been done in the feature selection of all variables. Below, a table with all the features and their respective feature importance scores. 67 Split 2 Training (332, 7) Validation (164, 7) Split 3 Training (496, 7) Validation (164, 7) Split 4 Training (660, 7) Validation (164, 7) Split 5 Training (824, 7) Validation (164, 7) Table 7 - Shapes of multivariate multiple parallel series LSTM datasets. The input sets were all in the shape (n, 7). The output sets were also in the same format. In this case, there are multiple input series and multiple output series. So, the output sets had not only the feature Celsius but all time series variables. 4.3.9.2. Model Evaluation Largely used on different types of problems, k-fold cross-validation is not really suited for time series forecasting. That is because it ignores the temporal component. For instance, by the time a fold from the middle of the dataset is taken as the validation dataset, the training dataset remains with a considerable data gap. So, to evaluate time series forecasting models consistently, a TimeSeriesSplit object from Python’s library scikit-learn was used to create multiple train-test splits. The TimeSeriesSplit object was applied to create five splits that differ in the number of observations used to train the model. Each following split has a larger training dataset to work with as can be seen in the following picture. The validation dataset remains with the same amount of data on every split: 68 Figure 4-51 - Five splits of the dataset for a univariate LSTM NN. As an example, below, the five splits from the univariate LSTM neural networks: Figure 4-52 - Plots of five splits of the dataset for a univariate LSTM NN. Each following split with a little more data for training than the previous. Before TimeSeriesSplit object be used to created multiple training and validation sets, a test set was split out of the dataset as a holdout. The idea is to utilize training and validation sets as a kind of time-series cross-validation and to have the test set as a totally impartial set of unseen data to do a final model evaluation. So, the dataset was first split into 90% to training/validation set and 10% to 69 test set and, later, among the 90% of the dataset designated to training and validation, five splits were created using TimeSeriesSplit. 4.3.9.3. Data Transformation The Data Transformation step objective is to apply some transformations to the dataset that can maximize the capacity of the model to extract knowledge from the dataset. Since the dataset has variables with very different scales, mainly, the Pressure feature, a normalization object called MinMaxScaler from Python’s library scikit-learn was used to rescale consistently the time series. Below, a line plot of all the input variables from the multivariate LSTM neural network. Feature Pressure, in the range of thousands, is clearly on a different scale than all other variables. Figure 4-53 - Line plot of all the input variables with feature Pressure on a different scale. When applying a normalization technique to a dataset, it has to be done carefully. Otherwise, the process could have data leakage. Data leakage occurs when data from outside the training data is used to train the model resulting in overfitting and an optimistic evaluation of the model (Brownlee, 2016). If the entire dataset is normalized at once and then splits for training and validation are created, scale factors, like min and max values of the series, will be from the whole dataset. Therefore, information from the validation set will be used in the training phase and vice-versa, resulting in data leakage. To avoid this situation, normalization was done within each split separately for training and validation sets. The same approach was done, later, with the test set. 4.3.9.4. Data Preparation The goal of the Data Preparation step is to get the dataset ready to be used for training an LSTM neural network. To do so, the data must be presented in a three-dimensional array with the following components: samples, time steps, and features (Brownlee, 2018a, p. 46). Samples are the observations, the rows in the dataset. Features are the input and output variables, the columns in the dataset. A time step is one point of observation in the sample. 70 Below, an example of the data prepared for a univariate LSTM neural network as a three-dimension array [samples, time steps, features]. In this case, the training set has 684 samples, 18 time steps, and only one feature, since it is a univariate problem. For 684 times, only one feature (one column) is presented with its 18 lag features. Figure 4-54 – Data prepared for a univariate LSTM NN. Highlighted the first of 684 samples with its 18 time steps and one feature. To put in perspective, below, another example, but for a multivariate LSTM neural network. This time, the training set has 685 samples, 18 time steps, and 7 features, since it is a multivariate problem. For 685 times, 7 features (columns) are presented with its 18 lag features. 71 Figure 4-55 - Data prepared for a multivariate LSTM NN. Highlighted the first of 685 samples with its 18 time steps and seven features. 4.3.9.5. Define, Compile, Fit, Evaluation and Predict After setting a time series cross-validation like evaluation process, transforming the dataset through normalization, and preparing the dataset to feed an LSTM neural network, the deep learning models were trained. But first, the number of steps was set to 18, following the indication from the Feature Selection step that lag features until the 18th time step still affect the target variable considerably. The process of training the Deep Learning models was divided into five steps: define the neural network architecture, compile the neural network, fit the training data, evaluate with the validation data, and predict. To define the neural networks different architectures were used. Below, a brief explanation of each one of them: § Baseline § 1 hidden layer with 12 neurons. § Wider NN (Neural Network) 72 § 1 hidden layer with 25 neurons. § Wider 2x NN § 1 hidden layer with 50 neurons. § Deeper NN § 2 hidden layers with 25 neurons. § Deeper 2x NN § 4 hidden layers; § First and last hidden layers with 25 neurons; § Second and third hidden layers with 35 neurons. § Deeper 4x NN § 8 hidden layers; § First and last hidden layers with 25 neurons; § All the in-between layers with 35 neurons. § Deeper 4x NN with Dropout Regularization § 8 hidden layers; § First and last hidden layers with 25 neurons; § All the in-between layers with 35 neurons; § 20% of dropout between every hidden layer. The steps of compiling the neural network, fitting the training data, evaluating with the validation data, and predicting were repeated in the same way for all different neural network topologies. Below, as an example from the univariate LSTM NN, the initial output of the model training: 73 Figure 4-56 - Initial output of a univariate LSTM NN training. Next, also as an example from the univariate LSTM NN training, charts of model loss from model training of the five splits (training and validation losses by epoch): 74 Figure 4-57 - Model Losses (Split #1 to #5). 4.3.9.6. Performance Metric After training and evaluation of the Deep Learning models, predictions were made using the training and the validation datasets. The objective of this is to calculate the performance metric of each dataset by comparing the respective predictions to the already known values of the target variables. The performance metric used for that was the Root Mean Squared Error. Before calculating the RMSE, a minor transformation step was required. Since the training and the validation datasets were normalized by the MinMax technique, the predictions needed to be transformed back to the scale of the original values. Thus, and as RMSE was being used as a performance metric, it would be more noticeable if the error was of 1 Celsius degree, more or even less. By using the inverse_transform function of the MinMaxScaler object from Python’s library scikitlearn, it was relatively easy to invert the predictions. The only exception was in the case of the multivariate multiple input series LSTMs. Because input and output dataset shapes were different in 75 this case, input dataset shapes were (n, 8) and output dataset shapes were (n, 1), the inverse_transform function demanded some data transformation before be applied. Below, as an example from the univariate LSTM NN, the training and the validation score calculated from the five splits: Figure 4-58 - Training and Validation Scores. 4.3.9.7. Prediction on Test Dataset As the last step, to be sure of the generalization capability of the model, predictions were made out of the test set (holdout). The entire process was repeated, but with some small changes. In this case, the training dataset was composed of what before was the training and the validation dataset. The new training dataset needed to have its data transformed and prepared just like before. The dataset was normalized and converted to the three-dimensional array of samples, time steps, and features that an LSTM expects. After that, the Deep Learning model was trained again, but, this time, with much more data. The test dataset was also transformed and prepared. The test dataset was used to make predictions based on the recently trained model. Predictions were inverted following the same logic as before and the RMSE was calculated to obtain a test score. The image below shows the results achieved, as an example with the univariate NN, with the dataset in blue, the predictions from the new training dataset in orange and the predictions from the test dataset in green: 76 Figure 4-59 - Complete dataset overlaid with predictions. Interesting to notice that there are no predictions for the first eighteen observations in the chart above. That is due to the eighteen time steps configured in the LSTMs. 4.3.10. Machine Learning Models Different models were used in an attempt to get the best Machine Learning model possible to compare with Deep Learning models. Linear Regression, Decision Trees, and ensemble models like Gradient Boosting were among them. The idea was to test if Deep Learning models, more specifically, LSTM neural networks, have a great advantage or not for time series forecasting problems. Because of that, all the same criteria used with Deep Learning models were applied to Machine Learning models to have a fair comparison. It is important to remind that Machine Learning models didn’t receive any special treatment to deal with a times series forecasting case, though. Below, a table with all Machine Learning models that have been employed: Model Acronyms Model Type Model Name LR Standard Linear Regression LASSO LASSO Linear Regression KNN K-Nearest Neighbors CART Classification and Regression Trees GBM Ensemble Gradient Boosting Machines (or Stochastic Gradient Boosting) 83 Below, the table presenting the final results: Figure 5-1 - Best results for Deep Learning and other Machine Learning models. As can be noticed by comparing RMSE performance metrics, Deep Learning models indeed have a better performance when it comes to time series forecasting problems. However, it is important to remark that other Deep Learning models like the univariate and the multivariate multiple parallel series variations besides achieving overall better performance than other Machine Learning models did not accomplish that by such large margin as was the case of multivariate multiple input series models. 84 6. CONCLUSIONS Several algorithms from different areas of Machine Learning were tested in an attempt to find the best possible model to solve the problem of time series forecasting for the Ambiosensing system. After many experiments, it became clear that the multivariate LSTM networks in a configuration of multiple variables as input and one variable as the target would be the best choice for the operational use case problem of the Ambiosensing system. By applying multivariate LSTM networks with a single hidden layer with 50 nodes the Ambiosensing system would predict with very high precision (RMSE of 0,028 Celsius degrees) the average temperature for the next four hours allowing the system to set its configurations adequately. Taking into consideration only Deep Learning models, it was shown that, by a large margin, multiple input series models outperformed univariate and multivariate parallel series models (RMSE of 0,028 versus RMSE of 0,375 and 0,486 respectively). The reason to make better predictions than the univariate variations is, probably, due to the extra features that the multiple input series models take into consideration. With more information available, the model can learn more and, hence, make better predictions. Still, multiple parallel series models have the same features available as multiple input series models, but the fact that these models intend to predict not only one but several time series make it underperform when compared to multiple input series models that have only one target to predict. It is important to remark, still concerning only Deep Learning models, that models that achieved the best performances were shallow networks with a single hidden layer. Deeper networks did not make as assertive predictions even when they were combined with regularization techniques to avoid overfitting like dropout. This is an indication that, probably, the problem of predicting indoor temperature for the Ambiosensing system is not as complex as initially thought. At least, as long as the right features are available with a consistent data quality to train the models. Concerning other Machine Learning models other than Deep Learning, even with a set of features that mixed lag features among the selected features, they did not perform as good as multivariate LSTM networks (RMSE of 0,569 versus RMSE of 0,028 respectively). The lag features did bring time context to the Machine Learning models, but these models did not treat them as the same variable in different time steps like the LSTM networks. The Machine Learning models treated the lag features as completely different input variables. This is an important advantage for LSTM networks when compared to other Machine Learning models that are not as suited as LSTM networks to deal with large sequences of data. Ensemble methods did improve the performance between Machine Learning models, but not enough to beat LSTM networks in any configuration. But, the difference between the best Ensemble method, the Gradient Boosting Machines (RMSE of 0,569), and the second-best LSTM networks configuration, the univariate LSTM network with a single hidden layer with 25 nodes (RMSE of 0,375), was not that big. If only the best result for each tested algorithm is considered, even the worst model still would be satisfactory to be applied in the use case of predicting indoor temperature for the Ambiosensing system. A 0,5 Celsius degree error would still be acceptable and would not affect drastically the ability of the Ambiosensing system to set its configurations autonomously. 85 An important final remark is that in an attempt to improve the performance of the Deep Learning models with LSTM networks, the dataset was transformed through differencing into a stationary time series. By analyzing the complete dataset line plot, it is possible to observe a decreasing trend in indoor temperature from July to January, corresponding with the weather changes from summer to winter in the northern hemisphere. However, removing the trend from the time series did not result as expected. The results were worse than the ones with the original dataset. A possible explanation is that the Neural Network learned the trend by the context provided in the input sequence eliminating the need to remove it from the time series. 86 7. PRACTICAL APPLICATIONS AND RECOMMENDATIONS FOR FUTURE WORK The use case chosen to test and compare different models was the operational scenario of predicting the indoor temperature from historical data to support the Ambiosensing system to automatically set the best possible base configuration to prevent high energy consumption from drastic changes. However, the results showed that Deep Learning models like LSTM networks can be used for much more complex problems using the same dataset and the context of the Ambiosensing system. Another possible application that can take advantage of the several input features related to gas concentrations and also from the unique feature of LSTM networks of handling well large sequences of data is to apply the model predictive capability to anomaly detection. A more specific variation of this use case could be a fire or explosion or danger alert module in the Ambiosensing system based on the dangerous concentration of certain gases like the flammable Methane or the toxic Carbon Monoxide. As future work, although LSTM networks did achieve great results, it is possible to invest in some techniques to improve it even more. One of them would be lifting the performance by adapting the learning rate. Decreasing the learning rate over time during training could increase the performance and also reduce the training time. In the experiments, the Adam (Adaptive Moment Estimation) optimization algorithm was used. The Adam optimization algorithm in its default Keras configuration provides learning rate adaptation automatically. However, it would be interesting to explore further the parameter learning rate for the Adam optimization algorithm and also other optimization algorithms like the classic Stochastic Gradient Descent or the RMSProp (Root Mean Square Propagation) with different learning rate configurations. Another possible future work also in the context of improving LSTM networks would be to experiment with different types of LSTM networks. For instance, bidirectional LSTMs or even combinations of LSTM and CNN networks. Bidirectional LSTM networks learn both from forward and backward passes. And LSTM and CNN networks can work together in a hybrid model joining the strengths of each algorithm. In a specific LSTM-CNN configuration, a CNN model could extract and learn features from the sequence of data and an LSTM model could work as a backend that would receive the data initially processed by the CNN model. Deep Learning is a vast field with lots of possible practical applications. Because of the way that Neural Networks learn, with enough computational resources available, they should outperform classical linear forecasting methods in general. Mostly, due to its capability of mapping complex relationships between inputs and outputs. This characteristic together with the support for input sequences in RNN with stable gradients in LSTM networks granted efficiency in learning temporal dependencies from the input to the output. All these aspects together make LSTM networks a good fit for times series forecasting. 87 8. BIBLIOGRAPHY Adafruit Sensirion SHT31-D (Temperature and Humidity Sensor). (n.d.). Retrieved August 6, 2020, from Adafruit Industries website: https://www.adafruit.com/product/2857 Aggarwal, C. (2015). Data Mining: The Textbook. Springer. Ambiosfera. (n.d.). Retrieved June 8, 2019, from Ambiosfera - Energia e Ambiente website: http://www.ambiosfera.pt/ Barooah, P., Subramany, R., & Siddarth, G. (2018). Patent No. US 10,047,968 B2. United States of America: United States Patent. Bell, J. (2015). Machine Learning: Hands-On for Developers and Technical Professionals. John Wiley & Sons, Inc. Bernardo, J. (2015). Estratégia para a Eficiência Energética nos Edifícios Públicos. In Workshop: RePublic_ZEB. Retrieved from http://www.lneg.pt/download/10887/DGEG_REPublic_ZEB 11dez2015.pdf Bonér, J., Chala, A., Ruzicka, W., Bennet, L., Kappal, S., & Smith, T. (2018). Big Data: Stream Processing, Statistics, and Scalability. DZone Devada Media, 40. Retrieved from https://dzone.com/guides/big-data-stream-processing-statistics-and-scalabil Brownlee, J. (2016). Data Leakage in Machine Learning. Retrieved August 7, 2020, from https://machinelearningmastery.com/data-leakage-machine-learning/ Brownlee, J. (2018a). Deep Learning for Time Series Forecasting Predict the Future with MLPs, CNNs and LSTMs in Python (v1.4). Brownlee, J. (2018b). Deep Learning with Python Develop Deep Learning Models on Theano and TensorFlow Using Keras (v1.15). Brownlee, J. (2018c). Time Series Forecasting with Python How to Prepare Data and Develop Models to Predict the Future (v1.6). Brownlee, J. (2019). Machine Learning Mastery with Python Understand Your Data, Create Accurate Models and Work Projects End-to-End (v1.14). Burkov, A. (2019). The Hundred-Page Machine Learning Book. Chala, A., Polak, A., Laird, C., Lamb, C., Stichbury, J., Babu, S., & Smith, T. (2019). Big Data: Volume, Variety, and Velocity. DZone Devada Media, 38. Retrieved from https://dzone.com/guides/bigdata-volume-variety-and-velocity Dalgaard, P. (n.d.). Introductory Statistics with R (Second Edition). Springer. Dinov, I. (2018). Data Science and Predictive Analytics Biomedical and Health Applications using R. Springer Nature. 88 Direcção Geral de Energia e Geologia. (2017). Balanços Energético Sintético 2016. Retrieved from http://www.dgeg.gov.pt/wwwbase/wwwinclude/ficheiro.aspx?access=1&id=15901 Evans, R., & Gao, J. (2016). DeepMind AI Reduces Google Data Centre Cooling Bill by 40%. Retrieved August 6, 2020, from https://deepmind.com/blog/deepmind-ai-reduces-google-data-centre- cooling-bill-40/ Google Cloud Public Datasets. (n.d.). Retrieved August 7, 2020, from Google Cloud website: https://cloud.google.com/public-datasets Granville, V. (2017). Difference between Machine Learning, Data Science, AI, Deep Learning, and Statistics. Retrieved August 6, 2020, from Data Science Central website: https://www.datasciencecentral.com/profiles/blogs/difference-between-machine-learning- data-science-ai-deep-learning Graves, A. (2012). Supervised Sequence Labelling with Recurrent Neural Networks. Springer. Groth, P. (2017). 5 reasons data is a key ingredient for AI applications. Retrieved August 6, 2020, from Elsevier website: https://www.elsevier.com/connect/5-reasons-data-is-a-key-ingredient-for-ai- applications Halevy, A., Norvig, P., & Pereira, F. (2009). The Unreasonable Effectiveness of Data. Retrieved from www.computer.org/intelligent Hardesty, L. (2015). Siting wind farms more quickly, cheaply. Retrieved August 6, 2020, from MIT News Office website: http://news.mit.edu/2015/siting-wind-farms-quickly-cheaply-0717 Holidays Library Documentation. (n.d.). Retrieved August 6, 2020, from https://pypi.org/project/holidays/ Humidity Sensor BME280. (n.d.). Retrieved August 6, 2020, from Bosch Sensortec website: https://www.bosch-sensortec.com/products/environmental-sensors/humidity-sensors- bme280/ IBM Research Editorial Staff. (2016). Forecasting the Future: Air Quality in South Africa with the IoT. Retrieved August 6, 2020, from IBM Research Blog website: https://www.ibm.com/blogs/research/2016/10/forecasting-air-quality-south-africa-iot/ IEC 60050 - International Electrotechnical Vocabulary - Details for IEV number 845-01-52: “lux.” (n.d.). Retrieved August 7, 2020, from International Electrotechnical Commission website: http://www.electropedia.org/iev/iev.nsf/display?openform&ievref=845-01-52 Igual, L., & Seguí, S. (2017). Introduction to Data Science A Python Approach to Concepts, Techniques and Applications. Retrieved from http://www.springer.com/series/7592 International Organization for Standardization. (1975). Retrieved August 6, 2020, from Standard Atmosphere (ISO Standard No 2533:1975) website: https://www.iso.org/standard/7472.html Kirk, M. (2014). Thoughtful Machine Learning: A Test-Driven Approach (First Edition). O’Reilly Media, Inc. 89 Kuhn, M., & Johnson, K. (2013). Applied Predictive Modeling (5th ed.). Springer Nature. Menne, M. J., Durre, I., Korzeniewski, B., McNeal, S., Thomas, K., Yin, X., … Houston, T. G. (2012). Global Historical Climatology Network - Daily (GHCN-Daily), Version 3.26. https://doi.org/http://doi.org/10.7289/V5D21VHZ Müller, A., & Guido, S. (2016). Introduction to Machine Learning with Python A Guide for Data Scientists (First Edition). O’Reilly Media Inc. NumPy Manual. (n.d.). Retrieved August 6, 2020, from https://numpy.org/doc/stable/ Oldewurtel, F., Parisio, A., Jones, C. N., Gyalistras, D., Gwerder, M., Stauch, V., … Morari, M. (2012). Use of model predictive control and weather forecasts for energy efficient building climate control. Energy and Buildings, 45, 15–27. https://doi.org/10.1016/j.enbuild.2011.09.022 Pandas Documentation. (n.d.). Retrieved August 6, 2020, from https://pandas.pydata.org/docs/ Pisello, A. L., Bobker, M., & Cotana, F. (2012). A Building Energy Efficiency Optimization Method by Evaluating the Effective Thermal Zones Occupancy. Energies, 5(12), 5257–5278. https://doi.org/10.3390/en5125257 Ruzicka, W., Lawrence, C., Chaudhri, A., Jacquet, F., & Smith, T. (2018). Artificial Intelligence: Automating Decision-Making. DZone Devada Media, 29. Scikit-learn Documentation. (n.d.). Retrieved August 6, 2020, from https://scikitlearn.org/stable/user_guide.html Shaikh, P. H., Nor, N. B. M. ., Nallagownden, P., Elamvazuthi, I., & Ibrahim, T. (2013). Robust Stochastic Control Model for Energy and Comfort Management of Buildings. Australian Journal of Basic and Applied Sciences, 7(10), 137–144. Shmueli, G., & Lichtendahl, K. (2016). Practical Time Series Forecasting with R: A Hands-on Guide (Second Edition). Axelrod Schnall Publishers. Shumway, R., & Stoffer, D. (2017). Time Series Analysis and Its Applications with R Examples (4th ed.). Retrieved from http://www.springer.com/series/417 Skansi, S. (2018). Introduction to Deep Learning From Logical Calculus to Artificial Intelligence. https://doi.org/10.1007/978-3-319-73004-2 Skiena, S. (2017). The Data Science Design Manual. Retrieved from http://www.springer.com/series/3191 sklearn.ensemble.RandomForestRegressor — scikit-learn 0.23.2 documentation. (n.d.). Retrieved August 7, 2020, from https://scikitlearn.org/stable/modules/generated/sklearn.ensemble.RandomForestRegressor.html sklearn.metrics.mean_absolute_error — scikit-learn 0.23.2 documentation. (n.d.). Retrieved August 6, 2020, from https://scikitlearn.org/stable/modules/generated/sklearn.metrics.mean_absolute_error.html 90 sklearn.metrics.mean_squared_error — scikit-learn 0.23.2 documentation. (n.d.). Retrieved August 6, 2020, from https://scikitlearn.org/stable/modules/generated/sklearn.metrics.mean_squared_error.html sklearn.model_selection.cross_val_score — scikit-learn 0.23.2 documentation. (n.d.). Retrieved August 6, 2020, from https://scikitlearn.org/stable/modules/generated/sklearn.model_selection.cross_val_score.html sklearn.model_selection.KFold — scikit-learn 0.23.2 documentation. (n.d.). Retrieved August 6, 2020, from https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.KFold.html sklearn.model_selection.TimeSeriesSplit — scikit-learn 0.23.2 documentation. (n.d.). Retrieved August 6, 2020, from https://scikitlearn.org/stable/modules/generated/sklearn.model_selection.TimeSeriesSplit.html sklearn.model_selection.train_test_split — scikit-learn 0.23.2 documentation. (n.d.). Retrieved August 6, 2020, from https://scikitlearn.org/stable/modules/generated/sklearn.model_selection.train_test_split.html sklearn.neighbors.KNeighborsRegressor — scikit-learn 0.23.2 documentation. (n.d.). Retrieved August 6, 2020, from https://scikitlearn.org/stable/modules/generated/sklearn.neighbors.KNeighborsRegressor.html sklearn.preprocessing.MinMaxScaler — scikit-learn 0.23.2 documentation. (n.d.). Retrieved August 6, 2020, from https://scikitlearn.org/stable/modules/generated/sklearn.preprocessing.MinMaxScaler.html sklearn.preprocessing.StandardScaler — scikit-learn 0.23.2 documentation. (n.d.). Retrieved August 6, 2020, from https://scikitlearn.org/stable/modules/generated/sklearn.preprocessing.StandardScaler.html Smith, S. I., & Lasch, C. (2016). Machine Learning Integration for Adaptive Building Envelopes. Posthuman Frontiers, 98–105. Retrieved from http://papers.cumincad.org/data/works/att/acadia16_98.pdf Spann, T., Deschamps-Sonsino, A., Lawrence, C., Churilo, C., & Azzola, F. (2019). The Internet of Things: Connecting Devices and Data. DZone Devada Media, 36. Retrieved from https://dzone.com/guides/internet-of-things-connecting-devices-and-data Spann, T., Lawrence, C., Azzola, F., Simmons, D., Styger, E., & Smith, T. (2018). Internet of Things: Harnessing Device Data. DZone Devada Media, V, 44. Retrieved from https://dzone.com/guides/iot-harnessing-device-data Tukey, J. (1977). Exploratory Data Analysis. Addison-Wesley. Vishwanath, A. (2018). IoT and Machine Learning to Reduce Energy Use in Cooling Systems. IBM Research-Australia, Internet of Things. Retrieved from https://www.ibm.com/blogs/research/2018/07/reduce-energy-cooling/ Zhang, A., Lipton, Z., Li, M., & Smola, A. (2020). Dive into Deep Learning (Release 0.7.1). Retrieved 91 from https://d2l.ai/index.html Page | i