scieee AI-readable full text Open interactive document viewer

Distributed cloud-edge analytics and machine learning for transportation emissions estimation

Gutiérrez Torre, Alberto

Abstract

(English) In recent years IoT and Smart Cities have become a popular paradigm of computing that is based on network-enabled devices connected providing different functionalities, from sensor measures to domotic actions. With this paradigm, it is possible to provide to the stakeholders near-realtime information of the field, e.g. the current pollution of the city. Along with the mentioned paradigms, Fog Computing enables computation near the sensors where the data is produced, i.e. Edge nodes. This paradigm provides low latency and fault tolerance given the possible independence of the sensor devices. Moreover, pushing this computation enables derived results in a near-realtime fashion. This ability to push the computation to where the data is produced can be beneficial in many situations, however it also requires to include in the Edge the data preparation processes that ensure the fitness for use of the data as the incoming data can be erroneous. Given this situation, Machine Learning can be useful to correct data and also to produce predictions of the future values. Even though there have been studies regarding on the uses of data at the Edge, to our knowledge there is no evaluation of the different modeling situations and the viability of the approach. Therefore, this thesis aims to evaluate the possibility of building a distributed system that ensures the fitness for use of the incoming data through Machine Learning enabled Data Preparation, estimates the emissions and predicts the future status of the city in a near-realtime fashion. We evaluate the viability through three contributions. The first contribution focuses on forecasting in a distributed scenario with road traffic dataset for evaluation. It provides a robust solution to build a central model. This approach is based on Federated Learning, which allows training models at the Edge nodes and then merging them centrally. This way the models in the Edge can be independent but also can be synchronized. The results show the trade-off between accuracy versions training time and a comparison between low-powered devices versus server-class machines. These analyses show that it is viable to use Machine Learning with this paradigm. The second contribution focuses on a particular use case of ship emission estimation. To estimate exhaust emissions data must be correct, which is not always the case. This contribution explores the different techniques available to correct ship registry data and proposes the usage of simple Machine Learning techniques to do imputation of missing or erroneous values. This contribution analyzes the different variables and their relationship to provide the practitioners with guidelines for correction and data treatment. The results show that with classical Machine Learning it is possible to improve the state-of-the-art results. Moreover, as these algorithms are simple enough, they can be used in an Edge device if required. The third contribution focuses on generating new variables from the ones available with a ship trace dataset obtained from the Automatic Identification System (AIS). We use a pipeline of two different methods, a Neural Networks and a clustering algorithm, to group movements into movement patterns or \emph{behaviors}. We test the predicting power of these behaviors to predict ship type, main engine power, and navigational status. The prediction of the main engine power is compared against the standard technique used in ship emission estimation when the ship registry is missing. Our approach was able to detect 45\% of the otherwise undetected emissions if the baseline method was to be used. As ship navigational status is prone to error, the behaviors found are proposed as an alternative variable based in robust data. These contributions build a framework that can distribute the learning processes and that resists network failures in low-powered devices.

Full text

Alberto Gutierrez-Torre Distributed Cloud-Edge Analytics and Machine Learning for Transportation Emissions Estimation Thesis for the Doctoral Degree in Computer Architecture Barcelona, July 2022 Universitat Politècnica de Catalunya - BarcelonaTECH Computer Architecture Department UPC Universitat Politècnica de Catalunya BarcelonaTECH Barcelona, Spain Thesis for the Doctoral Degree in Computer Architecture Computer Architecture Department Supervisors Josep Lluís Berral García & David Carrera Pérez Tutor Yolanda Becerra Fontal Cover depicts a view of San Vicente de la Barquera (Cantabria, Spain) from the port of La Barquera. A neural network transformed the original picture, specially the Picos de Europa mountain range, which was transformed into waves. Original image ©Jon Chica (Photographer). The resulting image has been obtained from applying a Neural Network style transfer using Hokusai’s The Great Wave off Kanagawa (Kanagawa-oki Nami Ura) as reference style. Base thesis template courtesy of Andreas Liudi Mulyo. This thesis was partially funded by a Severo Ochoa Center of Excellence grant SEV-2015-0493- 16-5 during 4 years, by European Research Council (ERC) under the European Union Horizon 2020 research and innovation programme (grant agreement No 639595), the Ministry of Economy, Industry and Competitiveness of Spain under contracts TIN2015-65316-P, 2014SGR1051, 2017-SGR1414 and PID2019-107255GB, the Generalitat de Catalunya under project RIS3CAT GA.001-P-001662 and the European Union’s Horizon 2020 research and innovation programme under grant agreement No. 952179 and No. 101004152. To all the PhD students who are struggling Keep on pushing Nobody ever figures out what life is all about, and it doesn’t matter. Explore the world. Nearly everything is really interesting if you go into it deeply enough. -RICHARD P.FEYNMAN Abstract In recent years Internet of Things ( IoT )and Smart Cities have become a popular paradigm of computing that is based on network-enabled devices connected providing different functionalities, from sensor measures to domotic actions. With this paradigm, it is possible to provide to the stakeholders nearrealtime information of the field, e.g. the current pollution of the city. Along with the mentioned paradigms, Fog Computing enables computation near the sensors where the data is produced, i.e. Edge nodes. This paradigm provides low latency and fault tolerance given the possible independence of the sensor devices. Moreover, pushing this computation enables derived results in a near-realtime fashion. This ability to push the computation to where the data is produced can be beneficial in many situations, however it also requires to include in the Edge the data preparation processes that ensure the fitness for use of the data as the incoming data can be erroneous. Given this situation, Machine Learning ( ML ) can be useful to correct data and also to produce predictions of the future values. Even though there have been studies regarding on the uses of data at the Edge, to our knowledge there is no evaluation of the different modeling situations and the viability of the approach. Therefore, this thesis aims to evaluate the possibility of building a distributed system that ensures the fitness for use of the incoming data through ML -enabled Data Preparation, estimates the emissions and predicts the future status of the city in a near-realtime fashion. We evaluate the viability through three contributions. The first contribution focuses on forecasting in a distributed scenario with road traffic dataset for evaluation. It provides a robust solution to build a central model. This approach is based on Federated Learning ( FL ), which allows training models at the Edge nodes and then merging them centrally. This way the models in the Edge can be independent but also can be synchronized. The results show the trade-off between accuracy versions training time and a comparison between low-powered devices versus server-class machines. These analyses show that it is viable to use Machine Learning ( ML ) with this paradigm. The second contribution focuses on a particular use case of ship emission estimation. To estimate exhaust emissions data must be correct, which is not always the case. This contribution explores the different techniques available to correct ship registry data and proposes the usage of simple Machine Learning ( ML ) techniques to do imputation of missing or erroneous values. This contribution analyzes the different variables and their relationship to provide the practitioners with guidelines for correction and data treatment. The results show that with classical Machine Learning ( ML ) it is possible to improve the state-of-the-art results. Moreover, as these algorithms are simple enough, they can be used in an Edge device if required. The third contribution focuses on generating new variables from the ones available with a ship trace dataset obtained from Automatic Identification System ( AIS ). We use a pipeline of two different methods, a Neural Network ( NN ) and a clustering algorithm, to group movements into movement patterns or behaviors. We test the predicting power of these behaviors to predict ship type, main engine power, and navigational status. The prediction of the main engine power is compared against the standard technique used in ship emission estimation when the ship registry is missing. Our approach was able to detect 45% of the otherwise undetected emissions if the baseline method was to be used. As ship navigational status is prone to error, the behaviors found are proposed as an alternative variable based in robust data. These contributions build a framework that can distribute the learning processes and that resists network failures in low-powered devices. We propose different alternatives for the learning process depending on the requirements. The last two contributions focus on correcting the data of a particular vii viii ▶ABSTRACT use case. Nevertheless, the techniques applied are general enough to be used in other domains of application. With these corrections, the data post-process done in the Edge nodes, i.e. emission estimation, provides more accurate results as the fitness for use of the data is improved. Acknowledgements This chapter shows the human side of research, aside from all the technical details that we will cover later. Because, in the end, science is carried by researchers that are humans (at the present moment... who knows in 30 years!) and that are not always performing optimally. We are not machines, even though we learn. The journey of playing The Game of Thesis has been long and hard. Nevertheless, this manuscript shows that it was possible to carry on with the enormous task which a Ph.D. represents. Looking back we notice that this effort is not a thing done alone, even though the main work was done by the author. Therefore, this chapter is dedicated to the people that may not be authors in my papers but made them possible. Like P-Model, Underworld, Black Sun Empire, Björk, Lo-Fi Girl, Boards of Canada, The Flower Kings and so many more musicians and music collectives that have been with me during all the thesis. Also, I want to thank you, reader, for laying your eyes on this document. It takes a lot of courage and patience to go through a document like this. I hope this document brings you an idea or two that you can use. First of all, of course, I want to say thank you to my advisors David Carrera and Josep Lluís Berral. David was the first contributor to this thesis as, thanks to him, I got a grant to do my research on this topic. He has always been there providing great insights on the conceptual side when we were focusing on the technical fun. From him, I have learned that it is better to do things that make sense than things that are technically novel and fun. Because we create things that will enable future advances. On the other side, Josep Lluís has believed in me for years since the Bachelor’s degree final project. He has endured my doubts, lack of performance at some points, and my procrastination. He has been an endless source of new ideas and general advice. If I am here today writing this thesis is because of the inspiration that I got from him. Thank you for being the best mentor and friend. Clai! Also, thanks to Yolanda for being my tutor at UPC in the last years and managing all the related bureaucracy. Many thanks to Marc Guevara and Albert Soret from the Earth Sciences department from BSC for helping me with a topic I would have never thought I would research: Ship emissions estimation. They have helped me to get through the details and assumptions of the field, especially in the first years of my PhD, where I did not know the huge amount of work that these systems have inside. Researching alone is a rare thing these days. This is why I have to also give my thanks to the fellow Ph.D. Students that I have met along the way. First of all, the BSC Data-Centric Computing team in which I have found mentors and partners in research: Felipe (Thank you for reviewing the thesis!), David B., Nicola, Marcelo, Aaron, Álvaro, Oscar, Tom, Jordà, Sergi, Paco, Anna, Claudia, Ferran, Gonzalo, Shuja, Kiyana, Juan Luís, Alejandro, Joan, Dani and Zoran. Thank you for being part of an amazing group. Moreover, I have found great people outside the group in the At Tudadis room: Jorge Carahuevo, Alberto M., Dani A., and Javier. Thank you for showing me in my early master years the hardships of the Ph.D. and motivating me to not pursue one. I am sorry that your advice was not followed. Special thanks to the Doctoral Coffee Symposium members, Alexandre and Martí, for those afternoons full of science and procrastination which showed me that investing some time in relaxing and discussing the research and other topics can improve drastically the actual academic output. Also, thanks to Alan for our philosophical talks on those afternoons when we spoke about science, work, and all sorts of things. Moreover, I want to say thanks to the workers of the Barcelona School of Informatics Bar for providing all those healthy meals and snacks during my 13 years of studies. The dobles con queso and ix xvi ▶LIST OF FIGURES CHAPTER 3 4.1 Schema of a Fog Architecture. The Edge-Cloud continuum, from Edge to Cloud. 36 4.2 Federated model compared to having a centralized model and then broadcasting it. 37 4.3 Schema of the Fog Infrastructure, from Edge to Cloud. 38 4.4 Schema of the Fog Infrastructure applied to transportation research. 39 4.5 Data pipeline including the management and the analytics parts. The data wrangling processes include data cleaning, aggregation, and interpolation. These processes can be performed by classical techniques or using ML models, specially in the data cleaning process as will be seen in further chapters. This figure is an implementation of a subset the Figure 2.9 modules. 40 4.6 Federated model compared to having a centralized model and then broadcasting it. Notice that it is mandatory to broadcast the model using the FL approach, however, data broadcasting is optional, i.e. it is not necessary for FL to work. 41 4.7 Example of merging weights in a single neuron model. All the weights are averaged taking into account the network structure. For example 𝑤1=(Í𝑀 𝑖=1𝑤1𝑖)/𝑀.42 4.8 Error vs. Hidden units vs. Time aggregation for the number of cars and speed estimation on CRBMs. 44 4.9 Comparison of the RMSE regarding the number of nodes (federated models) and the number of FL rounds with (top) the average error of all the tested model configurations and (bottom) the best model configuration. Notice that the different number of rounds have an associated number of epochs. 45 4.10 Comparisonofthe RMSE regardingthelearningrateandthenumberofnodes(federated models) with (top) the average error of all the tested model configurations and (bottom) the best model configuration. 46 4.11 Cars RMSE with respect to the learning rate and the FL rounds. Notice that when the learning rate is 0.01 the merged model is overfitted towards the blue local data from models 1 and 3. When the learning rate is smaller, the model obtained is more general and is able to cover all the data splits. Also notice that for the four models, the test data is the same, therefore the data used for training in the local model 2 is more different than the other two splits. 46 4.12 RMSE of the merged model for the number of cars and speed with 2 federated models comparing having a common initialization (N2_init) versus random initialization (N2_no_init). Configuration: Hidden units 6, batch size 32, epochs 1, federated rounds 100, and learning rate 0.0001. RMSE calculated with the test set. 47 4.13 RMSE of the merged model for the number of cars and speed with 3 federated models comparing having a common initialization (N3_init) versus random initialization (N3_no_init). Configuration: Hidden units 8, batch size 32, epochs 31, federated rounds 15, and learning rate 0.0001. RMSE calculated with the test set. 47 4.14 Time comparison for configurations in low-power devices vs. single CPU Xeon ref., for each amount of hidden units. 48 4.15 Average modeling time on different Edge devices. 49 LIST OF FIGURES ◀xvii CHAPTER 5 5.1 Descriptionofthe data pipelinefromrawdata totheemission computation. AIS cleaning process is a simplified version of Jeon et al. [2]. Data inference when there is no data is covered on Section 5.2.6. This work covers the static data cleaning process.53 5.2 Experimental pipeline diagram. The configuration is used to define the variables used for prediction and the target and also define the model to be used and the hyperparameters to be tuned. The metrics and the models are stored in the file system for model comparison. 56 5.3 𝑘 -fold Cross-validation and model testing processes. The data is divided into 𝑘 fragments and then 𝑘 models are trained. These models use 9 folds as input and then the other one as validation data set. Each model uses a different partition as test. Afterward, the best model configuration found is tested with the test partition. 57 5.4 Variable correlation. me is main engine, ae is auxiliary engine, inst_pow means installed power, bis beam, tis draft, lis length. 58 5.5 Relevance of variables to predict the beam. 60 5.6 Polynomial regression scatterplot for each case. 64 CHAPTER 6 6.1 Pipeline for CRBMs, Prediction and Clustering 70 6.2 Accuracy of the ship classification pipeline depending on the features. 73 6.3 Proportion of patterns by ship type. It can be seen that some ship types have similar pattern frequency, but others differ drastically. For example, both special categories 1 and 2 (class 3 and 5 respectively) are quite different as 3 is more fishing oriented than the service oriented class 5. On the other hand, carrier ships and others are similar. 73 6.4 Percentage of pollution covered for each method and pollutant with the predicted main engine power. The real data marks the 100%. 75 6.5 Example of status classification by clustering, on a trawling ship. Visualization tool at http://patrons.bsc.es.76 7.1 Thesis contribution interaction diagram. Contribution 1 offers an architectural framework for distributed ML that can be used in the other two contributions. 82 List of Tables CHAPTER 2 2.1 Example of 1-minute aggregated FCD record. Notice that position is from the receiving antenna/Edge node, not the vehicle. 21 2.2 Sampled data from the dataset. Identifiers are surrogates from the real identifiers. 23 2.3 Variables available in the registry. Only shown the variables relevant for the contributions of this thesis. 24 4.1 Comparison with baseline models VAR and CRBM s as N = 1 (5 min aggregation). Notice that the results are for the overall best configurations found. 43 CHAPTER 5 5.1 Availability in our dataset of the variables required for STEAM emission estimations. Notice this scenario is not general as the ones seen in the work of Peng et al. [ 3 ] and Huang et al. [4]. 54 5.2 Error measures for training and test for the target variable predicted with all the other variables. Only the two best algorithms are shown for each variable. The full table is available in the supplementary material. Ordered by test 𝑅2.59 5.3 Variable importance for each model and the final selection of variables. 59 5.4 Error measures for training and test for the target variable predicted only with the relevant variables. The variables used to predict are written below the variable to predict. Only the two best algorithms are shown for each variable. The full table is available in the supplementary material. Ordered by test 𝑅2.61 5.5 Difference of error when adding type variable as a predictor with respect to Table 5.4. The variables used to predict (excluding type which is used in every experiment) are written below the variable to predict. Increase in 𝑅2 and decrease in RMSE and MAE means better fit. Only the two best algorithms are shown for each variable. The full table is available in the supplementary material. Ordered by test 𝑅2.61 5.6 Error measures for training and test for the target variable. The variable used to predict is written below the variable to predict. Predicted only with the most relevant variable. Only the two best algorithms are shown for each variable. The full table is available in the supplementary material. Ordered by test 𝑅2.62 5.7 Comparison of the best algorithms found, KNN and MSV . The full table is available in the supplementary material. Ordered by test 𝑅2.63 5.8 Installed power main engine predicted with Length*Beam and (Length and Beam). The full table is available in the supplementary material. Ordered by test 𝑅2.63 xix xx ▶LIST OF TABLES CHAPTER 6 6.1 Main engine installed power regression error (Mean Absolute Error) for the best configuration found for each model. Votes aggregated with mean and median. 74 6.2 Estimated pollution in tonnes for each component, using the test-set individuals with the different input values. 74 6.3 Clusters vs. NavStatus labels. Values are normalized per row. Notice that Cluster 1 refers to the delay data not classified 75 APPENDIX A A.1 Error measures for training and test for the target variable predicted with all the other variables. Ordered by test 𝑅2.A-4 A.2 Error measures for training and test for the target variable predicted only with the relevant variables. The variables used to predict are written below the variable to predict. Ordered by test 𝑅2.A-5 A.3 Difference of error when adding type variable as a predictor with respect to Table 5.4. The variables used to predict (excluding type which is used in every experiment) are written below the variable to predict. Increase in 𝑅2 and decrease in RMSE and MAE means better fit. Ordered by test 𝑅2.A-6 A.4 Error measures for training and test for the target variable. The variable used to predict is written below the variable to predict. Predicted only with the most relevant variable. Ordered by test 𝑅2.A-7 A.5 Comparison of the best algorithms found, KNN and MSV. Ordered by test 𝑅2.A-8 A.6 Installed power main engine predicted with Length*Beam and (Length and Beam). Ordered by test 𝑅2.A-8 Part I PRELIMINARIES 1 CHAPTER 1 Thesis Introduction 1.1 THESIS CONTEXT In recent years Internet of Things ( IoT )has become a popular term in both the academic and enterprise worlds. This term can be described in a simplified way as a new paradigm of computing that is based on network-enabled devices connected providing different functionalities, from sensor measures to domotic actions. The Smart City movement makes use of the IoT paradigm as an enabler for better management of the cities, obtaining knowledge from the gathered data, and also using the connected actionable things. In this context, new architectures named Edge/Fog Computing have emerged. These architectures act as a standardized way to implement IoT and Smart Cities, e.g. VanLingen et al. [ 5 ]. These kinds of new Data-centric architectures are focused on where the data comes from, where it commutes, and where it is stored, providing data lineage and data quality assurance inside the given pipeline. Edge Computing refers to the architectures that enable the computation where the data is produced, i.e. in the edge devices which can be low-powered computers and sensor boards. Fog Computing is a term that covers both Cloud and Edge computing, as it makes use of the computation in the Edge devices and centralized Cloud resources. Moreover, it adds an intermediate layer of low-powered or mid-end computers that can act as aggregators or data processors in which intermediate operations can be executed, e.g. Machine Learning ( ML ). Figure 1.1 shows an example of an IoT network with intermediate edge devices infrastructure for data processing and aggregation. FIGURE 1.1. Example of different devices spread in a city that may be interconnected in the city of Barcelona. Intermediate edge devices may be set up to further process and aggregate the data produced in the devices. Image courtesy of David Carrera. A research field that can directly benefit from IoT and Fog Computing is Air Quality monitoring. Air Quality is an important factor for the citizens’ well-being, hence it is an important aspect to have in aSmart City. Regarding the societal impact of the Air Quality, in a recent study by Mueller et al. [ 6 ] performed in the city of Barcelona, it is shown that Air Quality is a cause, amongst other factors, of premature death. Moreover, another recent study by Bañeras et al. [ 7 ] shows that there is a correlation 3 4▶CHAP. 1 THESIS INTRODUCTION between air pollution and ST Elevation Myocardial Infarction ( STEMI ), which is a particular type of heart attack. In particular, this study shows that Particulate Matter ( PM ) and 𝑁𝑂2 pollutants increase the risk of having this kind of attack. This information has reached the citizens through the newspapers and television, making them more aware of the direct effects of pollution on their life. FIGURE 1.2. Pollution cloud over Barcelona. Photography was taken by the Fabra Observatory’s meteorologist, Alfons Puertas. Given the impact of Air Quality on our well-being and also on the environment itself, knowing how the pollution propagates has a key role in helping the governments to know their cities’ status and make policies for future improvement. To evaluate, preserve and improve the state of the atmosphere, air quality modeling is a necessary tool that provides a complete description of the problem (i.e. meteorology, emissions, and atmospheric chemistry), which complements the information obtained from air quality monitoring networks. In particular, the CALIdad del aire Operacional Para España ( CALIOPE ) air quality forecasting system 1 is a state-of-the-art modeling framework that integrates a meteorological model, an emission model, a dust model, and a chemical transport model to simulate air quality concentration with a high spatial (up to 1km 2 ) and temporal (1 hour) resolution for Europe and Spain. The air quality results are continuously evaluated with a system based on measurements from the European Environment Information and Observation NETwork ( EIONET ), and the performance of the system has been previously tested in the different evaluation and air quality management studies [8]. From the four different models that this system has, this work focuses on the emission models. The High-Elective Resolution Modelling Emission System ( HERMES ) model is the emission core of the CALIOPE system and has been fully developed by the Earth Science department of the Barcelona Supercomputing Center ( BSC ) [ 9 ], which gathers information about different areas that generate pollution (e.g. agriculture, road traffic) and estimates the pollution for each of them, as the first step of the Air Quality System. As recorded in the Barcelona Air Quality Improvement Plan (2015-2018) [ 10 ], in 2013 in Barcelona the 46% of the NOx (Nitrogen Oxides) are produced in the port and 33% in road traffic. Similar numbers are seen for PM10 (Particulate Matter of less than 10 𝜇 m in diameter), as 52% is originated in the port and 37% in road traffic. Notice that this is the total amount of generated pollution which, depending on the wind, might not affect the city fully, especially for the port emissions. As observed in these numbers, transportation takes a key role in the emissions produced in the city. However, only ships provide Global Positioning System ( GPS ) traces and other attributes to compute directly the emissions. 1http://www.bsc.es/caliope/es 1.1 THESIS CONTEXT ◀5 In particular, according to the European Community Shipowners Associations (ECSA) in 2015, maritime traffic has become a key component of the European economy [ 11 ]. According to a recent report by the International Maritime Organization ( IMO ), it is expected that this form of transport will continue increasing in the future due to globalization and the increase of global-scale trade [ 12 ]. The main reason for this is that sea transportation is more fuel-efficient than other modes of transport (e.g. trucks and trains). At the same time, it is considered an important contributor to primary atmospheric emissions in coastal areas [ 13 ] and subsequently to European coastal air quality degradation [ 14 ], especially in the North Sea and the Mediterranean basin. Maritime traffic is also responsible for about 2 . 5% of global greenhouse gas (GHG) emissions and it is expected to grow in the future for economic reasons. For instance, 𝐶𝑂2 emissions are expected to increase between 50% and 250% by 2050 [ 12 ]. Given the impact of the emissions in coastal areas and the expectations of growth of shipping emissions, it is very relevant to have as many details as possible of this type of emission origin. Inside HERMES , there is a module that calculates the emissions generated by both road, ship traffic, and other sources by distributing the total pollution measured provided by the government using emission measures, usage profiles, routes, and other information. However, it can benefit from GPS based systems that can improve its spatio-temporal granularity, as is the case of road traffic in the work of Rodriguez-Rey et al. [ 15 ]. This kind of approach is based on having data points distributed over the map and aggregating them to the resolutions required. Using this methodology, not only we can estimate correctly the emissions but also we can know with greater detail where are they located, improving the precision of the whole Air Quality system. Itisimportant to knowthe current status of acityin a fine-graindetailandin a near-realtimefashion to make short-term policies and be able to raise alarms to the citizens. Moreover, it is also important to be able to evaluate possible policies for port management. The STEAM [ 1 , 16 ] methodology enables having a system that has both features. This methodology uses data from ship registries containing static ship data, e.g. ship size or installed engine power, along with GPS enabled data, Automatic Identification System ( AIS ) data, to estimate the emissions in the precise place they are produced. Automatic Identification System ( AIS ) is a GPS -based tracking system used for collision avoidance in maritime transport, as a supplement to marine radars. AIS provides information such as a unique identifier for each transport (IMO identifier), the position as latitude and longitude ( GPS positioning), the course and speed. Such information is used by maritime authorities to track and monitor vessel movements, from AIS base stations located along the coast, and transmitted through standardized VHF transceivers. According to the IMO ’s Convention for Safety of Life at Sea, AIS equipment is required to be installed in all international voyaging ships with more than 300 Gross Tonnage ( GT ) units, and all passenger ships [17], leading to the high availability of data. Given that the information can be gathered by antennas distributed along the coast and other similar devices, Fog Computing provides a well-fitted framework for this problem. Figure 1.3 represents the conceptual infrastructure. First, in each node, the data is received and then the fitness of the data for the application is assured. Then, emissions can be computed and forecasting can be performed. After that, the derived data is obtained. This way the emission estimation is produced where the data is gathered and therefore the estimations can be provided with the minimum latency possible. This low latency provision is what enables the near-realtime emission estimation framework that provides precise geolocation. Moreover, if only statistics about pollution are required, they may be also computed in the nodes and only the required information would be sent. This approach provides storage and network efficiency as fewer data have to be stored and sent. 1.1.1 Thesis statement Even though this system is used as a vital component in ship maneuvering and cruising, it is not free of machine and human errors [ 18 , 19 ]. For example, ships can report unrealistic speeds when they 12 ▶CHAP. 2 BACKGROUND constant. Notice that 𝑛𝑣 and 𝑛ℎ refer to the dimension of 𝒗 and 𝒉 respectively. In practice, we normalize the data to have zero mean and unit variance. Moreover, 𝜎𝑖 is fixed to 1 because it empirically works well as shown in the work of Taylor et al. [24]. This kind of undirected graphical model is trained with a process called Contrastive Divergence [ 24 ] which enforces that the activations act as a code to recover the original data, as mentioned before. Conditional Restricted Boltzmann Machines The Conditional Restricted Boltzmann Machine ( CRBM ) is a GB-RBM that models static frames of a time series modified with some extra connections used to model temporal dependencies. The CRBM keeps track of the previous 𝑛 visible vectors in a 𝑛×𝑛𝑣 matrix which we call the history of the CRBM , where 𝑛𝑣 is the number of different variables. The learned parameters of the CRBM are three matrices W , A , D, as well as a two vectors of biases cand bfor the visible and hidden units respectively. W ∈R𝑛𝑣×𝑛ℎ models the connections between visible and hidden units, as in the previous section. A ∈R(𝑛𝑣·𝑛)×𝑛𝑣 is the mapping from the history to the visible units. D ∈R(𝑛𝑣·𝑛)×𝑛ℎ is the mapping from the history to the hidden units. Training and inference in the CRBM are performed using the contrastive divergence method, as with RBM s. Figure 2.1 shows how the input data and the CRBM interact in terms of reconstruction. FIGURE 2.1. Schema of CRBM training and prediction Figure 2.2 shows a graphical representation of a CRBM referencing the previously mentioned variables. In the case of this thesis, we have an interest in using the activations produced by the hidden units when fed with a sample of traffic trace plus the 𝑛 steps window. Then we use this vector of activations as a time-aware code that represents a sample with a time window for algorithms that are not thought to handle time-series, enabling them to manage temporal dependencies. Notice that even though CRBM s suffer when doing long-term predictions, therefore an alternative method is also studied for prediction. 2.2 MACHINE LEARNING ◀13 FIGURE 2.2. CRBM with window size 𝑛and 𝑛ℎhidden units 2.2.2 Gated Recurrent Unit (GRU) Network Another technique that we use for traffic modeling are Recurrent Neural Networks ( RNN s), specifically a configuration known as Gated Recurrent Unit ( GRU )network. This network is formed by one or more layers of GRU and other neural network layers, e.g. densely connected layers for prediction. With this kind of network we can predict a long period of time series. This kind of layer can deal with time dependencies using a gating mechanism. This gating mechanism is composed of two different gates for each GRU layer: the reset gate and the update gate. These two gates affect the value that the next hidden status 𝑆𝑡 will have. This 𝑆𝑡 is used for internal calculations as the state of memory and it is also used as the output of the layer. Figure 2.3 provides a graphical representation of this kind of layer. The data flow represented in this figure is a simplified version of the following equations. Biases and weights are omitted for the sake of clarity. The box containing 𝑟𝑡 is the reset gate, the box containing 𝑢𝑡 is the update gate and the one containing e 𝑆𝑡 is the proposed new state. In the following equations, 𝑥𝑡represents the input at time 𝑡. St−1 Xt St +  ut σ + e St tanh +  rt σ + FIGURE 2.3. Schema of a unit of a GRU layer First, the reset gate controls the access to the previous hidden state 𝑆𝑡−1 and is used to compute the new proposed state e 𝑆𝑡 as can be seen in Equation 2.4. The reset gate is computed as shown in 14 ▶CHAP. 2 BACKGROUND Equation 2.2. Second, the update gate is in charge of how much the state is updated, i.e. which interpolation between 𝑆𝑡−1 and e 𝑆𝑡 is desired, between the extremes of maintaining the previous state or updating it completely. This interaction is shown in Equation 2.5 The update gate is computed as shown in Equation 2.3. Finally, the proposed state e 𝑆𝑡 is the new hidden state calculated regarding the previous state and the current input. This status is calculated in Equation 2.5. Notice that ⊙ is the Hadamard or element-wise product and 𝜎 the activation function. After the gates and the proposed state is computed, we do an interpolation between the current state 𝑆𝑡−1 and the proposed next state e 𝑆𝑡 , which represents how much do we change our memory given the current input 𝑥𝑡. 𝑟𝑡=𝜎(𝑥𝑡𝑊𝑥𝑟 +𝑆𝑡−1𝑊𝑠𝑟 +𝑏𝑟)(2.2) 𝑢𝑡=𝜎(𝑥𝑡𝑊𝑥𝑢 +𝑆𝑡−1𝑊𝑠𝑢 +𝑏𝑢)(2.3) e 𝑆𝑡=𝑡𝑎𝑛ℎ(𝑥𝑡𝑊𝑥𝑠 + (𝑟𝑡⊙𝑆𝑡−1)𝑊𝑠𝑠 +𝑏𝑠)(2.4) 𝑆𝑡=(1−𝑢𝑡) ⊙ 𝑆𝑡−1+𝑢𝑡⊙e 𝑆𝑡(2.5) Each layer has a given number of units as the one represented in Figure 2.3 that have memory, i.e.feedback loop. The more units we add, the more elements the layer will be able to remember. 2.3 EMISSION ESTIMATION Air Quality Modelling Systems ( AQMS ) are systems built to estimate and analyze the quality of the air. These systems describe what pollutants there are in the air, where they are located, and when they are emitted. These systems are built of several models that take into account where, when, and how much of each pollutant is produced, how is it transported in the air, and how the pollutants react with other chemicals that are in the air. In this work, we are particularly interested in the origins of the emissions. Inside the AQMS the module that performs this task is the emission estimation module. This module makes use of an activity factor, e.g. the movements of ships in the sea, and the emission factor, i.e. for a given amount of energy produced how much pollutant is produced. With these two factors, the emissions can be computed. Specific details on this computation for a specific model are given in Section 2.3.2. In case that the emission origin can be tracked and continuous activity measurements are extracted, the emission estimation model we will be able to estimate the emissions produced continuously in a near-realtime fashion. This model is a key component to build a system that provides the status of the emissions in the air constantly so that policymakers can know the status of an area. In particular, this part of the background is required to understand the contributions of Chapters 5and 6as it is the main driving use case. 2.3.1 Top-down vs Bottom-up emission estimation In general, there are different types of emission estimation approaches: Top-down and Bottom-up. Even though there may be mixed methodologies. The top-down estimation approach estimates the emission using a global measurement for an area and then disaggregates it using activity factors, e.g. known traffic in a given set of roads. With this process, a grid of emissions is built, which represents the status of the area as a raster, i.e. a map of cells of a given size (1 𝑘𝑚2 for example) in which each contains the amount of pollutant for that particular region. On the other hand, bottom-up approaches like HERMESv3 [ 25 ], which is an estimation methodology included in the CALIOPE Air Quality System 2.3 EMISSION ESTIMATION ◀15 built in the Barcelona Supercomputing Center, make use of punctual estimations measured or estimated in the area of interest and then use them along their positions to build the emission grid. With this kind of approach, the emissions can be located and tracked. Compared to Top-down approaches, Bottom-up require access to detailed information which may be harder to obtain. However, these methodologies provide finer spatio-temporal granularity. For this work, Bottom-up methodologies are selected, as they enable the creation of a framework that can estimate emissions in a near-realtime fashion and provide better spatio-temporal resolution. 2.3.2 STEAM The Ship Traffic Emission Assesment Model ( STEAM ) model is a bottom-up ship exhaust emission model developed in the Finnish Meteorological Institute by Jalkanen et al. [ 1 , 16 , 26 ]. This model makes use of ship traces to estimate and geographically locate the pollution. STEAM2 [ 16 ] is an upgraded version of the STEAM model with improved engine characterization and the possibility of estimating different pollutants not covered in STEAM. However, in presence of missing data STEAM act as a fallback of STEAM2. Therefore this work only covers STEAM [1] and a small part of STEAM2 [16]. Ship traces can be obtained from the Automatic Identification System ( AIS ), the GPS -based tracking system used for collision avoidance in maritime transport as a supplement to marine radars. This system is used to track and monitor vessel movements from base stations located along the coast used in all the ships to prevent collisions. It is transmitted through standardized Very High Frecuency ( VHF ) transceivers. AIS provides, for each vessel, its unique IMO identifier and Maritime Mobile Service Identity ( MMSI ) number, GPS positioning, course, and speed among other information. This system is mandatory, according to IMO ’s Convention for Safety of Life at Sea, for all ships with gross tonnage greater than 300 tons, and all passenger ships [ 17 ]. This data provides basic details like position and speed which can be used, along with a ship registry, to estimate emissions as Figure 2.4 depicts. FIGURE 2.4. Estimation of Emissions from Ship Traces Our approachis a methodologybased on theSTEAM model, proposedby Jalkanen etal. [ 1 ]. STEAM is an AIS -based emission estimation model that uses the traces of the ships and their characteristics to provide information about the pollution with GPS positioning precision. Emissions are calculated using the current power consumption of the ship at a given time and the emission factor for that ship regarding a pollutant. Conceptually, the formula is the following (units in brackets): 𝐸𝑠,𝑝,𝑥,𝑡 [𝑔/ℎ]=𝑃𝑠,𝑥,𝑡 [𝑘𝑊 ] · 𝐸𝐹𝑠,𝑝 [𝑔 𝑘𝑊ℎ ] Being 𝑃 thecurrent power consumption of theship and 𝐸𝐹 theemission factor, 𝑠 shipcharacteristics (mainly engine), 𝑝 the pollutant to estimate, 𝑥 position of the ship, and 𝑡 the current time. Therefore, the emission of a given pollutant 𝑝 for a ship 𝑠 that is in the position 𝑥 and time 𝑡 is conditioned by the 16 ▶CHAP. 2 BACKGROUND ship characteristics for calculating the actual power that this engine is using and the ship characteristics plus the pollutant constants for the installed engine. Power estimation To estimate the emissions, first, we have to know how to calculate the power consumption of a ship. We have to take into account that generally there are two kinds of engines installed in ships: main engine and auxiliary engine. The first is mainly in charge of the movement of the vessel and the latter is in charge of the onboard electrical power devices but may be used for other tasks, e.g. maneuvering. Main engine The power used by the main engine at a given time 𝑡 is estimated using the current vessel speed, the design speed and the installed power. In particular, the formula to calculate the transient power is the following: 𝑃𝑡𝑟𝑎𝑛𝑠𝑖𝑒𝑛𝑡 = 𝑉3 𝑡𝑟𝑎𝑛𝑠𝑖𝑒𝑛𝑡 (𝑉𝑑𝑒𝑠𝑖𝑔𝑛 +𝑉𝑠𝑎𝑓 𝑒𝑡𝑦)3∗𝜀𝑝∗𝑃𝑖𝑛𝑠𝑡𝑎𝑙𝑙𝑒𝑑 Being 𝑉𝑡𝑟𝑎𝑛𝑠𝑖𝑒𝑛𝑡 the current speed provided by AIS , 𝑉𝑑𝑒𝑠𝑖𝑔𝑛 the maximum speed that the ship can reach by design, 𝑉𝑠𝑎𝑓 𝑒𝑡𝑦 a safety offset as ships may report speeds slightly greater than 𝑉𝑑𝑒𝑠𝑖𝑔𝑛 , 𝜀𝑝 engine load at Maximum Continuous Rating and 𝑃𝑖𝑛𝑠𝑡𝑎𝑙𝑙𝑒𝑑 the actual power installed in kilowatts. This formula acts as a ratio between the current speed and the maximum speed to find the actual power, along with an efficiency multiplier. Following the instructions from STEAM methodology,𝑉𝑠𝑎𝑓 𝑒𝑡𝑦 is fixed to 0.5 knots (2,57 m/s) and 𝜀𝑝is set to 0.8. Auxiliary engine The auxiliary engine is in charge of tasks like providing electrical power to the ship, e.g. to the sockets in the passenger rooms, or providing power for maneuvering in ports. As the usage of the auxiliary engine is not entirely reflected in any data available, we have to make some assumptions. The proposed assumptions in the work of Jalkanen et al. [1] are the following: •If the ship is a passenger ship, RoPax (ferry) or a cruiser: constant 4000kW assumed •For other ship types it depends on the current status: –Cruising (speed > 5): 750kW –Maneuvering (5 >= speed > 1): 1250kW –Hoteling (1 >= speed) : 1000kW Notice that if the assumed output power is greater than the actual installed power, the output power is lowered to match the installed power. The current status of the ship is extracted from the speed that the ship has, as reflected in the list above (in knots). There is a strong seasonal usage of the auxiliary engines for air conditioning. This is considered to be compensated as boilers are used in winter and air conditioning in summer. Finally, we must take into account that there is data that can be used for a more precise auxiliary engine estimation. However, this is covered only in STEAM2 [16]. Engine Load and Relative Specific Fuel-Oil Consumption ( SFOC )As STEAM does not cover Particulate Matter ( PM ) emissions, we need to include some characteristics from STEAM2 [ 16 ] regarding engine characterization. In particular, we need to add two concepts from STEAM2: Engine load ( 𝐸𝐿 ) and SFOC relative to the load ( 𝑆𝐹𝑂𝐶𝑅𝑒𝑙𝑎𝑡𝑖𝑣𝑒 ). With these two components, we can track the engine load at each moment and its particular fuel consumption, which is linked directly with the PM . To calculate the load of the engines we need to know how many engines there are and their rated power. 2.3 EMISSION ESTIMATION ◀17 𝐸𝐿 = 𝑃𝑇𝑜𝑡𝑎𝑙 𝑃𝐸∗𝑛𝑂𝐸 𝑛𝑂𝐸 = 𝑃𝑇𝑜𝑡𝑎𝑙 𝑃𝐸 +1 Being: •𝑃𝑇𝑜𝑡𝑎𝑙 = Actual power being used •𝑛𝑂𝐸 = Number of operative engines •𝑃𝐸= Power of one engine In STEAM2 [ 16 ] the SFOC is composed of an SFOC base value which is set according to the ship specifications and another part that acts as a multiplier of this base value. 𝑆𝐹𝑂𝐶𝑅𝑒𝑙𝑎𝑡𝑖𝑣𝑒 was extracted from a regression analysis using real engines and it is computed from the engine load as follows: 𝑆𝐹𝑂𝐶𝑅𝑒𝑙𝑎𝑡𝑖𝑣𝑒 =0.445 ∗𝐸𝐿2−0.71 ∗𝐸𝐿 +1.28 Emission Factor As shown in the equation, to calculate the exhaust pollution emitted we also need to have a value that explains how much of a given component is emitted per unit of fuel used or, as in this case, per kW produced. In this case, we will use 𝑔 𝑘𝑊 ℎ as a reference unit for the emission factor. All the factors are extracted from the supplemental materials of STEAM [1] and STEAM2 [16]. NOx The amount of NOx is obtained from a regression study made by IMO as seen in the work of Jalkanen et al. [ 1 ]. The NOx has a direct link with the Revolutions Per Minute ( RPM ) of the engine, as can be observed in the curve of Figure 2.5. The formula is the following: 𝐸𝐹 (𝑁𝑂𝑥)= 17, 𝑅𝑃𝑀 <130, 45 ∗𝑅𝑃𝑀−0.2,130 <=𝑅𝑃𝑀 <2000, 9.8, 𝑅𝑃𝑀 <=2000 SOx The amount of SOx, i.e. amount of every sulfur oxide, can be estimated by calculating the amount of SO2 as other sulfur oxides are found in much lower concentrations. We start from the idea that the number of mols of sulfur is the same as the number of mols in SO2, as it only has one atom of sulfur. First, we calculate how many mols of sulfur there are and then we relate them to SO2 to obtain the actual mass, as defined by the following equations: 𝑛(𝑆)= 𝑚(𝑆) 𝑀(𝑆) = 𝑆𝐹𝑂𝐶 ∗𝑆𝐶 𝑀(𝑆) = 𝑆𝐹𝑂𝐶 ∗0.001 32.0655 =𝑆𝐹𝑂𝐶 ∗0.001 32.0655 𝑛(𝑆)=𝑛(𝑆𝑂2) 𝐸𝐹𝑆𝑂2=𝑚(𝑆𝑂2)=𝑀(𝑆𝑂2) ∗ 𝑛(𝑆𝑂2)=64.06436 ∗𝑆𝐹𝑂𝐶 ∗0.001 32.0655 =𝑆𝐹𝑂𝐶 ∗0.001998 Being: 18 ▶CHAP. 2 BACKGROUND 0 500 1000 1500 2000 2500 10 11 12 13 14 15 16 17 NOx IMO curve (IMO, 1997) RPM g/kWh FIGURE 2.5. NOx curve as established in IMO 1997 [1] •𝑆𝐹𝑂𝐶 = Specific Fuel Oil Consumption (g/kWh) •𝑆𝐶 = Sulphur content of fuel (mass %) •𝑀(𝑆)= Molar mass of sulphur (g/mol) •𝑛(𝑆)= number of mols of sulphur (mol) •𝑚(𝑆)= mass of sulphur (g) •𝑀(𝑆𝑂2)= molar mass of sulphur dioxide (g/mol) •𝑛(𝑆𝑂2)= number of mols of sulphur dioxide (mol) •𝑚(𝑆𝑂2)= mass of sulphur dioxide (g) •𝐸𝐹𝑆𝑂2= emission factor for 𝑆𝑂2(g/kWh) Notice that we assume that 𝑆𝐶 is 1% as it is the current regulation with the Sulphur Emission Controlled Area (SECA). CO2 To calculate the mass of CO2, we follow a similar approach to what we have seen in the previous pollutant. In this particular case, the 𝐶𝐶 is 85% as shown in STEAM [1]. 𝑛(𝐶)= 𝑚(𝐶) 𝑀(𝐶) = 𝑆𝐹𝑂𝐶 ∗𝐶𝐶 𝑀(𝐶) = 𝑆𝐹𝑂𝐶 ∗0.85 12.01 =𝑆𝐹𝑂𝐶 ∗0.85 12.01 𝑛(𝐶)=𝑛(𝐶𝑂2) 𝐸𝐹𝐶𝑂2=𝑚(𝐶𝑂2)=𝑀(𝐶𝑂2) ∗ 𝑛(𝐶𝑂2)=44.00886 ∗𝑆𝐹𝑂𝐶 ∗0.85 12.01 =𝑆𝐹𝑂𝐶 ∗3.114699 Being: •𝑆𝐹𝑂𝐶 = Specific Fuel Oil Consumption (g/kWh) 2.3 EMISSION ESTIMATION ◀19 •𝐶𝐶 = Carbon content of fuel (mass %) •𝑀(𝐶)= Molar mass of carbon (g/mol) •𝑛(𝐶)= number of mols of carbon (mol) •𝑚(𝐶)= mass of carbon (g) •𝑀(𝐶𝑂2)= molar mass of carbon dioxide (g/mol) •𝑛(𝐶𝑂2)= number of mols of carbon dioxide (mol) •𝑚(𝐶𝑂2)= mass of carbon dioxide (g) •𝐸𝐹𝐶𝑂2= emission factor for𝐶𝑂2(g/kWh) PM Particulate Matter is in fact an emission that is composed of 𝑆𝑂4 , 𝐻2𝑂 , 𝑂𝐶 (Organic Carbon), 𝐸𝐶 (Elementary Carbon) and ashes. The following formulas compute the emission factor and were extracted from Jalkanen et al. [16]: 𝐸𝐹 (𝑃𝑀)=𝑆𝐹𝑂𝐶𝑅𝑒𝑙𝑎𝑡𝑖𝑣𝑒 ∗ (𝐸𝐹𝑆𝑂4+𝐸𝐹𝐻2𝑂+𝐸𝐹𝑂𝐶 ∗𝑂𝐶𝐸𝐿 +𝐸𝐹𝐸𝐶 +𝐸𝐹𝐴𝑠ℎ) Where: 𝐸𝐹𝑆𝑂4=0.312 ∗𝑆𝐶 𝐸𝐹𝐻2𝑂=0.244 ∗𝑆𝐶 𝑂𝐶𝐸𝐿 =(3.333, 𝐸𝐿 <0.15 𝑎 1+𝑏∗𝑒−𝑐∗𝐸𝐿 𝑎=1.024,𝑏 =−47.66,𝑐 =32.547 𝐸𝐹𝐸𝐶 =0.08 𝐸𝐹𝑂𝐶 =0.2 𝐸𝐹𝐴𝑠ℎ =0.06 Being: •𝑆𝐹𝑂𝐶𝑅𝑒𝑙𝑎𝑡𝑖𝑣𝑒 = Specific Fuel Oil Consumption multiplier relative to engine load •𝐸𝐿 = Engine Load (load %) •𝐸𝐹𝑆𝑂4= Emission Factor for 𝑆𝑂4(g/kWh) •𝐸𝐹𝐻2𝑂= Emission Factor for 𝐻2𝑂(g/kWh) •𝐸𝐹𝑂𝐶 = Emission Factor for 𝑂𝐶 (Organic Carbon) (g/kWh) •𝑂𝐶𝐸𝐿 = OC multiplier in terms of Engine Load (combustion efficiency) •𝐸𝐹𝐸𝐶 = Emission Factor for 𝐸𝐶 (Elementary Carbon) (g/kWh) •𝐸𝐹𝐴𝑠ℎ = Emission Factor for ashes (g/kWh) •𝑆𝐶 = Sulphur content of fuel (mass %) •𝑎,𝑏, 𝑐 = regression coefficients as defined in STEAM2 [16] 20 ▶CHAP. 2 BACKGROUND Limitations Notice that the ships may have installed devices that provide abatement techniques, i.e. techniques that reduce pollution, however, this information is not provided in the data we have available. The contribution of the sea waves is also not included for the sake of simplicity, but can be included using the work of Jalkanen et al. [1]. 2.4 DATA In this section the required datasets for the work of this thesis are introduced. Three datasets are covered for this thesis: Floating car dataset and two ship related datasets. The first dataset is used in the first contribution, in which we apply forecasting techniques to predict the amount of cars and the average speed. The other two datasets are used to estimate ship emissions, but require techniques to ensure the fitness for use of the data. 2.4.1 Floating Car Data Floating Car Data ( FCD ) is a real traffic log from one week in the city of Barcelona, provided by one of the largest road-assistance companies in Spain, comprising thousands of vehicles from their fleet only in the city. The dataset comprises data collected over one week between 10/27/2014 and 11/01/2014 across the Barcelona metropolitan area. Figure 2.6 shows a heat-map of the vehicle tracking data, comprising over 890,000 data samples and a fleet of more than 100 cars moving simultaneously around the city at some times. FIGURE 2.6. Barcelona metropolitan area map, combined with a heat-map overlay of the FCD dataset used for the simulations presented in this work. The dataset contains more than 890,000 data samples of road-assistance cars moving around the city. 2.4 DATA ◀21 FIGURE 2.7. AIS Transponder showing AIS data in the range of the antenna. Image obtained from Wikipedia. FCD represents geo-localized timestamped data of moving vehicles, collected and analyzed for various applications, including smart cities, traffic engineering, and traffic management. Typically, FCD is received through antennas deployed in the town representing a large urban zone, a localized neighborhood, a street, or a street segment, depending on which granularity is required for the specific application. That data is provided to the Edge analytics indicating the received timestamp for each vehicle transmission and its speed. Data like vehicle position, e.g. GPS , is not provided for privacy and security reasons; only the Edge node position is provided. The FCD arrives asynchronously to our Edge nodes and is aggregated periodically into summaries of traffic information, i.e., the average speed of vehicles surrounding the node (in Km/hour) and vehicles’ count, considering that vehicles will be reported once for each aggregation window time. An example of this aggregated dataset can be seen in Table 2.1. With 1-minute aggregation interval as lower bound, we aggregate the incoming data into data entries containing latitude, longitude, number of cars, speed average, and timestamp. Before performing the analytics, the Edge nodes independently collect and aggregate the FCD into a specific time interval. latitude longitude n.cars 𝜇.speed timestamp 41.362 2.095 4 17 1414365180 TABLE 2.1. Example of 1-minute aggregated FCD record. Notice that position is from the receiving antenna/Edge node, not the vehicle. 2.4.2 Ship datasets AIS dataset Automatic Identification System ( AIS ) is a system used by ships to prevent collisions among them and to help locate and manage all the ships by the port authorities. This system provides GPS data along with other information, making it possible to position ships and know other relevant variables like speed in near-realtime. This fact makes this data very useful for emission estimation, as we will see in Section 2.3. An example of an on-board AIS display can be seen in Figure 2.7. The current dataset has been provided by the Spanish Ports Authority (Puertos del Estado), from their vessel monitoring database collecting the AIS signals from all registered ships navigating national 28 ▶CHAP. 3 RELATED WORK methods based on the Cloud computing infrastructure. For example, Google implemented a distributed framework for training neural networks over Central Processing Unit ( CPU ) based on the DistBelief framework [ 45 , 46 ] which makes use of both model parallelism, and data parallelism. This model has also proved useful for computer vision problems, achieving state-of-the-art performance on a computer vision benchmark with 14 millions of images. To scale up the training phase of learning, researchers utilize accelerators such as a single or cluster of GPU s [ 47 , 48 ]. Recently, Facebook [ 49 ] announced achieving 90% scaling efficiency in training visual recognition model, using data parallelism combined with the use of GPU s. This is not limited to Cloud solutions. K. Hong et al. [ 50 ] proposed a fog-based opportunistic spatio-temporal event processing system to meet the latency requirement. Their system predicts future query regions for moving consumers, and starts the event processing early to make timely information available when consumers reaches the future locations. Yu et al. [ 51 ] proposed a Deep Reinforcement Learning based system that is able to share execution of tasks in Edge nodes taking into account the battery, quality of service and other details. However, the increasing amount of data to be processed, along with the computational demands of sufficiently-accurate neuralnetworkalgorithms, have ledto bigger computationaland memoryresource requirements. Accelerating neural networks training to competitive accuracy within a sufficiently short time is a major challenge that may lead to increase computational demands. Seeking solutions that assure scalable and efficient learning has given rise to the notion of “distributed ML ”. Federated Learning ( FL ) [ 52 ] is a promising solution when both data and resources are scattered along in the architecture, with the added challenge of the near impossibility of having all data in the same place, and the cost of constantly offloading computation to the Cloud. FL aims at keeping the data near where it is produced [ 52 , 53 ]. This solution can be understood as allowing the Edge devices, the clients, to produce a predictive model with their own local data, and then coordinate with a central node, the server, for model merging. In particular this is interesting in the contexts where data privacy is an issue as in the work of McMahan et al. [ 52 ], as the only data exchanged between the data producers and the central server are the weights, i.e. the configuration, of the neural network. On the other hand, there have been efforts like in the work of Hu et al. [ 54 ] that focus on having a model that works properly on both sides, client and server. Moreover, it has been proved Stochastic Gradient Descent (SGD) converges in this scenario [ 55 ], proving the suitability of Neural Networks for this particular task. This approach brings properties that are desirable for Edge Computing architectures, like the ability to keep on working without network connectivity when the system fails. Given that at the Edge nodes computing power is scarce, works such as Marchisio et al. [ 56 ] study how to perform ML inference in ultra-low powered devices, and review the usage of Neural Networks ( NN s) with this kind of device. This approach minimizes both power usage and hardware costs. Sudharsan et al. [ 57 ] proposed a methodology to train a kind of Convolutional Neural Network ( CNN ) and then adapt it to run in different MCU s to do prediction. Their approach reduces the size of the trained network to the 10% of the original. In the same direction, TinyML [ 58 ] enables training a NN with TensorFlow and then convert it to it can be run using TensorFlow Lite on ultra-low power MCU s. Neither of these approaches handle training on the device, but other approaches like Neuro.ZERO [ 59 ] enable training on the device by means of hardware acceleration. However, FL has yet to be covered on this kind of setup with MCU s, so that it enables to train different models and average the model configuration among nodes. Even though the methodology per se has already been described, there still is a knowledge gap regarding the actual applicability of FL on a Fog Computing architecture using low-powered devices and the effectiveness distributed models versus a centralized one. This work aims to fill this gap applying the methodologies described in Chapter 4. 3.2 FLOATING CAR DATA ◀29 3.2 FLOATING CAR DATA The appearance of Floating Car Data (FCD) as data source is expected to provide support to many practical use cases in the near future, leveraging Intelligent Transportation Systems telemetry. To complement the current lack of sensorization in cars and communications infrastructure, works like Briante et al. [ 60 ] propose the use of smartphones and Wi-Fi hotspots, also Ali et al. [ 61 ] proposes crowdsourcing architectures to collect data from smart devices on vehicles for these same purposes, or Ancona et al. [ 62 ] studies vehicle-to-vehicle networks to handle the expected escalation of FCD data volume. In the field of treating Floating Car Data, we find works like Yu et al. [ 63 ] where the framework RTIC-C presents a high level architecture to deploy traffic analytics, using Map-Reduce approaches for distributing modeling and processing algorithms. The RTIC-C authors defend the use of big data analytics on traffic data due to its increasing volume and complexity, then they focus on distributing received data for processing on anomaly detection and traffic trend prediction. Works like Moretti et al. [ 64 ] and Xia et al. [ 65 ] present different traffic modeling approaches, ensembles using bagging and Feed-Forward MLP Neural Networks the prior and Spatial-Temporal Weighted k-Nearest Neighbor the later, producing general models from the aggregated datasets and distributing computation on the Cloud. Also, works like Lv et al. [ 66 ] present a methodology where a Stack of AutoEncoders is applied for traffic flow prediction at different granularities with good results for t+1 forecasting. As presented in our work, localized models on the Edge can create in-situ specialized predictors adapted to their coverage area, using re-trainable machine learning models. Chapter 4focuses on the data transmission architecture towards receiving traffic data streams properly for being ingested by analytics methods, i.e. localized re-trainable CRBM prediction mechanisms, and could complement high level frameworks like those named here on generalist model scenarios. All the analytic process done is mainly done in the Edge, using dedicated High Performance Computing ( HPC ) only to process results. To the best of our knowledge, there currently is no evaluation of this kind of problem with FL using RNN s with server-class hardware and low-powered devices. Moreover, mechanisms are needed to stop training as soon as a reliable-enough model is obtained. We believe that FL distributed learning can be highly beneficial for data analytics over scenarios like smart cities. 3.3 SHIP CHARACTERISTICS AND EMISSION ESTIMATION Both AIS and ship characteristics data are a source for potential applications in industry and academic research as shown in the work of Svanberg et al.[ 67 ] and Miliuše et al.[ 68 ]. There is also an interest on standardizing the data access for interoperability. Lensu and Goerlandt[ 69 ] established a framework to build an AIS database for research, and apply it in particular to a use case related to navigation in ice. AIS-assisted emission estimations can be effectively used to assist policy design and corrective measures of a specific shipping sector (e.g. cruises and ferries) [ 70 ] and to improve the efficiency of ships [ 71 ]. Jalkanen et al. [ 1 , 72 ] show that AIS data can been used for the estimation of high spatial and temporal resolution maritime emissions. Compared to traditional emission estimation methodologies, the use of AIS data provides information of instantaneous speed, position and navigation status of vessels and subsequently allows for more accurate estimations of vessels’ activities and the improved reliability of emissions and fuel consumption estimations [ 73 ]. Navigational status is included on AIS data and with this attribute the current engine usage can be estimated along with other attributes like speed, however in some cases it is incorrectly set as this attribute is manually set. Both sources of datamay havemissing orinconsistent data, whichcan make thederivedapplications unreliable. Harati et al.[ 18 ] identify that attributes reported by AIS like draught are prone to error due to human errors. In their study, they conclude that 1 out of 14 messages is wrong. Moreover, 30 ▶CHAP. 3 RELATED WORK Goldsworthy and Goldsworthy[ 19 ] highlight that there may also be errors on the onboard equipment, e.g. unrealistic high speed reported. This fact is also shown in the work of Miola and Ciuffo[ 74 ] where they find speeds higher than 20 m/s inside the port of Rotterdam, which is not reasonable. On the other hand, ship registers may not have the full information about a ship. Peng et al.[ 3 ] claim that missing data is one of the main problems when estimating exhaust emissions as some information may not be recorded. Huang et al.[ 4 ] report that in their case out of 90,000 ships only 50,000 had correct values for rated power and design speed. Both of these attributes are essential to estimate exhaust emissions using this kind of methodology as they are used to estimate the current ship power. 3.3.1 Other approaches to emission estimation using Machine Learning and Statistics In this case scenario where the data might be incorrect, statistics and ML provide a good solution. Some approaches try to directly estimate the emissions using ML without any physical model, e.g. STEAM [ 1 ], behind it. Fletcher et al.[ 75 ] propose an ML method to predict the exhaust emissions of 2 ships using as input data the Shaft Speed (RPM) and the Engine Power (kW) in time. However, this solution requires sensors in the engine. Finally, they propose to mix this methodology with STEAM [ 1 ] to improve emission location as future work. Si et al.[ 76 ] also predict the emissions produced by one cogeneration unit using several engine-specific variables, which are not commonly found in ship registers. A different approach to this problem was described in the study by Peng et al.[ 3 ]. The method, based on STEAM [ 1 ], deals with missing data by sampling and extrapolating. The ships that have complete data are selected and then from those a stratified sampling methodology is followed. In the paper, they show that with 10% of the ships they have enough data to estimate the total emissions with statistical extrapolation. It is also shown that using high temporal granularity produces a more accurate estimation of the pollution as the model can catch the speed variation at each time step. However, this approach loses spatial granularity as the emissions are estimated by areas and not all the AIS traces are used. Other approaches try to estimate engine-specific characteristics intended to help with the design of the engines and that may be used to estimate the emissions. Chan and Chin [ 77 ] predict the engine power performance using the shaft power, shaft rpm, and shaft torque. Noor et al.[ 78 ] models predicting engine performance, i.e. output torque, brake power, brake specific fuel, and exhaust gas, using engine speed, engine load, fuel flow rate, and air mass flow rate. Fuel consumption in container ships is a well-studied topic. Le et al.[ 79 ] predicted the fuel consumption of this attribute using variables like sailing time and average trip speed using neural networks. Also, Uyanık et al.[ 80 ] did a similar study using noon reports, logbooks, and sensors in the vessels. This fuel consumption can be used later to estimate the exhaust emissions but this approach lacks GPS precision. Liang et al.[ 81 ] studied the prediction of propulsion power with neural networks using transient speed, weather, and other ship attributes and later on added AIS data to improve the prediction positioning. This approach provided better results overall compared to a physical model for container ships. 3.3.2 Data Quality and Pattern Mining for AIS Data AIS traces are GPS -based, therefore there are many techniques that can be applied to study the movement of ships. For example, pattern mining for GPS traces is a common practice in very different fields, looking for specific patterns in movement and behavior. Works like Qiu et al. [ 82 ] describe a methodology for mining patterns through Hidden Markov Models, producing semantic information to feed frequent pattern mining methods. Such work is also based on discovery of frequent episodes in time series [ 83 ], with the goal of discovering patterns series of events. Use cases for such techniques 3.3 SHIP CHARACTERISTICS AND EMISSION ESTIMATION ◀31 are social mining and recommendation [ 84 ], animal movement patterns [ 85 ], or elder care [ 86 ]. In Chapter 6we propose to find common patterns using CRBM s as a base for time windows, feeding them from GPS and other input sources, for discovering discriminating behaviors on a geographical space. The CRBM s, as probabilistic models derived from RBM s [ 87 , 88 ], are used in a wide range of problems like classification, collaborative filtering or modeling of motion capture, developed by the team of professor Geoffrey E. Hinton at the University of Toronto [ 24 , 89 – 91 ]. Such models are usually applied for problems where time becomes a condition on data, i.e. time-series. Other works like X.Li et al. [ 92 ] and Lee et al. [ 93 ] use the models for multi-label learning and classification. Based on their experiences and techniques, we are taking advantage on CRBMs time-series learning capabilities. These analysis require that AIS data has good quality, however this is not always the case. There are mainly two problems with this data: time gaps and outliers. Usually, time gaps are filled using interpolation techniques [ 1 , 19 ]. In the case of outliers, Goldsworthy and Goldsworthy[ 19 ] propose to mark as outliers those values that have values bigger than the 50% of the average of the trace. In the case of finding an outlier, it is removed and then the point is linearly interpolated. Velasco and Lazikis[ 94 ] performed an extensive literature review on missing data imputation of sensor timeseries data in vessels. In the study, they compared classic univariate autoregressive methods with multivariate methods for different output variables, e.g. current engine power. They found out that the Auto-Regressive Integrated Moving Average (ARIMA) outperformed the rest, showing low Mean Squared Error ( MSE ). However, this study has its limitations, as there is no time window provided for the multivariate methods, hence missing the time correlation of the data. Jeon et al.[ 2 ] proposed a preprocessing pipeline for AIS and onboard equipment data to find and correct anomalies and denoise the data. After that process, a dimension reduction is performed so that the regression algorithms are used over variables without any colinearity problem. To predict the engine performance, three different models (Generalized Additive Model (GAM), Gradient Boosting Regressor (GBR), and Multivariate Adaptive Regression Splines (MARS)) are trained with the best hyperparameters found using Bayesian optimization and used in an ensemble weighting the predictions with learned coefficients from a trained linear regression. They show that this pipeline works well for AIS data and particularly that the classic technique Kalman Filter works well for denoising this data. 3.3.3 Data Quality in ship register data In the report of the emission estimation used by National Atmospheric Emissions Inventory ( NAEI ) from the United Kingdom [ 95 ] is shown that some static data attributes, i.e. ship register data, provided by registers are not reliable, e.g. the auxiliary engine is missing in half of the ships in their study. When the data is missing a linear regression of the attributes is done, analogously to what the IMO shows in their studies [96,97]. Johansson et al.[ 26 ] propose in the STEAM3 model to use the Most Similar Vessel ( MSV ) search method, which is a 𝑘 Nearest Neighbors ( KNN ) with k=1 with a custom distance function. This method requires knowing at least the length, the design speed and the ship type to be used. In case they are not available they use a crawler to get this information. Design speed can be estimated as the 95th percentile of AIS Speed to avoid outliers. Finally, if the required information is not found, a small boat of 300 GT units is assumed. Instead of doing this assumption, Chapter 6shows that it is possible to use a neural network plus a clustering method to extract patterns from the AIS traces and use them along the ship type to predict the main engine power. This technique may be also applied to other attributes and it will be shown in the next chapter of this thesis. Liu et al.[ 98 ] propose to use statistical and ML methods to regress the missing data using the other data available. Gradient Boosted Regression Trees are finally selected because of their performance, however, there is no detail on how the process is taking place nor results. Huang et al.[ 4 ] regress the main engine power for container and tanker ships using polynomial regression using as predictive variable the length times the breadth of the ship. To 32 ▶CHAP. 3 RELATED WORK regress the design speed they use the method described by Cepowski [ 99 ]. This method is based on extensive work with regressions for the same type of ship. As shown, there are several approaches to improve the fitness for use of this kind of data, but there is no comparison nor any work that studies the relationship of the variables at a level that can be used to correct the data. Part II CONTRIBUTIONS 33 CHAPTER 4 Distributed Machine Learning on Fog Computing systems 4.1 INTRODUCTION In IoT and smart cities environments, data is produced by sensors scattered in the environment. Cloud provides extremely scalable resources from a remote data center. In contrast, in IoT scenarios, e.g., smart cities, domotics, or e-healthcare, proximity, and quick reaction are required while generating big amounts of data. As the number of sensors grows, the requirements for Cloud computing power and network bandwidth increase drastically. Cloud architectures scalability of resources that can be dynamically managed, however, there is a limit on responsiveness. The more sensors are installed in a city or environment, the more network bandwidth will be required. If a continuous analysis of the sensors is required, a constant stream of data would reach the Cloud for each sensor, overflowing the network of the system and reducing its responsiveness. Given these issues, Fog Computing architectures have emerged as an alternative for this type of environment. Fog Computing architectures, also called the Edge-Cloud continuum, make use of all the computing devices that are available in a network, instead of off-loading every process to the Cloud. This kind of architecture is the natural evolution from the classical IoT paradigm, which includes net-enabled sensors into a network so that they can communicate their readings and expose actuators. This layer, from now on called Edge is the place where the data is regularly produced. As mentioned before, the data has to be sent to the Cloud for further processing if a classical Cloud approach is used. However, using Fog Computing, this data can be processed and consumed in any intermediate point between the Edge and the Cloud, without requiring to send raw data directly to a Cloud. This architecture is represented by Figure 4.1, where the 3 levels of Fog Computing can be observed. The first level is the Edge where only low-powered devices are generally found, then the intermediate levels where mid-end computing nodes can be found, and finally the Cloud, where the resources are highly scalable. With this paradigm, critical components that require to be active at any time can remain independent of network and infrastructure failures [ 100 ] if the required analytics are pushed to the device. Specifically, Oil & Gas [ 101 ], power grid systems [ 102 ], smart cities, smart industries, and IoT applications [ 103 ]. In these environments, local analytics are required as they need a low latency QoS [ 104 ]. Given the importance of exploiting the data at the Edge level, considerable research effort was devoted to establishing a common framework to cope systematically and effectively with the restrictions proposed by this kind of environment [ 105 ]. Furthermore, some applications do not require to have fine-grain metrics from the sensors if alarms are programmed. An analytic process that constantly checks and aggregates the data could be deployed at the Edge level. This process can raise alarms while analyzing the fine grain data and only send to the Cloud those alarms and aggregations, saving network and storage usage in the Cloud. Machine Learning ( ML ) is a field that provides a big part of the analytical functions that are being currently implemented for data analysis, e.g. time series prediction, object recognition, or hardware failure time estimation. Given the compute-intensive nature of training ML models, so far this process has been pushed to the Cloud. This strategy has the advantage of using powerful computing machines, however, it has several drawbacks: it adds a cost of additional network dependency, increases latency, 35 36 ▶CHAP. 4 DISTRIBUTED ML ON FOG COMPUTING Cloud HPC Analytics and models Intermediate levels Aggregations and intermediate analytics Edge Sensoring, actuators and analytics Fog Computing Edge-Cloud Continuum FIGURE 4.1. Schema of a Fog Architecture. The Edge-Cloud continuum, from Edge to Cloud. and moves the processing away from the data producers, as defined before in the general IoT case. In contrast, using limited computing power available at Fog nodes is interesting for training ML models efficiently. Recent work shows the importance of training an ML model on Edge infrastructure. For example, Plastiras et al. [ 104 ] show the importance of doing the computation for training Deep Learning models on Fog nodes for Computer Vision tasks like object detection. The authors remark on the importance of privacy, performance, latency, and power efficiency in this kind of application, which can be a perfect fit for Edge and Fog Computing. In particular, this work focuses on using models for inference, i.e., applying the model to the input data. However, training on the Edge is also possible and desirable to enable mechanisms that protect the model from degrading, e.g. Concept Drift [ 106 ]. Considering the computing power available, models must be light enough to be able to be trained in a sensible time. In theparticular case ofthis thesis, we requirea systemthat is ableto gather datafrom transportation means sensors and use it for analysis and prediction. This would provide a mechanism for city councils and policymakers to study the traffic and gather information about what is happening at that precise moment in the city. One of the requirements of such a system is that it is a near-realtime system. With Fog computing, we are able to receive the data and process it at the same time, reducing the latency between receiving and having a result ready. In this way, we avoid sending raw data, and instead, we can send the already processed data aggregated, lowering bandwidth usage and off-loading all the processes to small and power-efficient devices. Furthermore, adding more devices to the network does not saturate Cloud Resources as installing a new device generally implies installing a computing node in the Edge, as it is required to send the gathered metrics. In our previous works (Perez et al. [ 100 ], Gutierrez-Torre et al. [ 21 ]) we explored the idea of training light enough models in Edge devices and the difference between using local models and centralized models. These centralized models were trained using all the data in the central node [ 100 ] and using Federated Learning ( FL ) [ 21 ]. This last approach is based on the idea that models can be trained in each Edge node and then merged in a central node without transferring the data. In this chapter, we extend those works using FL in a distributed Fog Computing environment. The previous approach [ 21 ] was limited to only one FL round, i.e., training at the Edge and then merging but not retraining the merged model again. Moreover, it did not provide a common initialization for all the models. This limits the accuracy when increasing the number of machines or data splits. This idea is tested in a similar setup exploring further the hyper-parameter space. It also includes a comparison of Xeon-based server and two low-powered devices, i.e., Raspberry Pi 3 and Jetson Nano, to simulate real Edge devices for 4.1 INTRODUCTION ◀37 Model broadcast ML Data reporting Central Model Model Merge ML Data/Model reporting Federated Model ML ML Model broadcast FIGURE 4.2. Federated model compared to having a centralized model and then broadcasting it. training. These two low-powered devices are used to simulate a real Edge node where computational resources available are scarce. The experiments related to this are also contained in Gutierrez-Torre et al. [21], but are included in this chapter for the sake of completeness. We present an extension of the system proposed in Gutierrez-Torre et al. [ 21 ] to automatically distribute the time-consuming task of training deep learning models on a Fog computing network consisting of low-powered and resource-constrained computing devices. The proposed approach is based on FL, which leverages the work of McMahan et al. [52] and Bonawitz et al. [53]. The framework enables training models in any level of the Fog computing architecture. In particular, we focus on making use of the Edge devices for training. We extensively evaluate the proposed system using the FCD dataset, designed for city-wide traffic modeling and prediction running on the Fog computing paradigm. The methodology can make use of any kind of NN by distributing the training on Edge devices. In particular, GRU s are selected as the model of choice to produce short/medium-term traffic predictions using the FL approach. Our evaluation investigates the effect of the FL rounds on accuracy and time requirements. The evaluation is based on real traffic logs from one week of Floating Car Data ( FCD ) in Barcelona. The data was provided by one of the largest road-assistance companies in Spain and comprises thousands of vehicles. The approach was tested in a Smart City environment, but it can be applied to any other field that requires distributing ML . This is especially interesting for the healthcare industry, as the collected patient data does not have to leave the Edge device or the healthcare center premises to be used in an anonymous and secure way. The experimental results show that the models produced using a FL approach are similar to the models using a classical central training approach. Also, they show the relationship of the hyperparameters and the error measure with a FL approach. Moreover, using this kind of light model architecture is fitting to be used with low-powered computers. In summary, this contribution expands a previous contribution [ 21 ] that showed the viability of using GRU with one round of FL. The list of contributions is the following: 1. A system for distributed modeling for city-wide applications using the Fog computing paradigm for predictive analytics using low-powered and resource-constrained devices with Federated Learning (FL). 2. Adaptation of the Data Science pipeline to a use case with a Fog Computing architecture. 3. An exploratory analysis of FL over a real Floating Car Data ( FCD ) and guidelines on how to select relevant parameters, e.g. number of FL rounds. 44 ▶CHAP. 4 DISTRIBUTED ML ON FOG COMPUTING FIGURE 4.8. Error vs. Hidden units vs. Time aggregation for the number of cars and speed estimation on CRBMs. •Hidden units: Number of GRU units that the GRU layer has. Values: 4, 6, 8. •Batch size: Number of elements to process for each gradient update. Values: 4, 32, 512. • Epochs/ FL rounds: Combination of number of times that the dataset is reviewed by the network and how many times the whole FL training is done. As these two parameters are related, their values are selected together. In case the number of nodes is 1, a number of epochs is 94 used [ 21 ]. Values (e, r): (94, 5), (31, 15), (1, 100). • Learning rate: How much the NN weights have to be updated for each step initially. In the experiments, RMSProp is used as the optimizer, which has an adaptive learning rate mechanism. Notice that it will reset after each FL round. Values: 0.01, 0.001, 0.0001. Model evolution in Federated Learning rounds First, we compare the effect of the number of FL synchronization rounds and, consequently, the number of epochs with how many models we have to train in parallel. In order to do a fair comparison, instead of adding new data for each new federated model, we split the total data we have into 𝑁 pieces so that all combinations of 𝑁use the same data, therefore making the experiments comparable. Figure 4.9 upper part shows the average error of all hyper-parameter configurations grouped by the number of nodes and number of rounds. On average, having 100 rounds with 1 epoch performs best. This result shows that having high synchronization between the models leads to stable models. On the other hand, models that do more epochs tend to provide higher errors. Figure 4.9 lower part shows the error of the best configuration found for each case. In this case, it can be seen that 100 rounds are still a good choice. However, for 𝑁= 3the other two options provide a lower RMSE in the number of car prediction. Overall it can be observed that with the FL approach it is possible to obtain models that are close to the centralized model. Moreover, in some cases, the model can be better. 4.4 EXPERIMENTS ◀45 fl_rounds 1 5 15 100 0.0 0.5 1.0 1.5 1 2 3 N. nodes Cars RMSE 0 2 4 123 N. nodes Speed RMSE Nodes vs N. FL Rounds (mean RMSE of all configuration) fl_rounds 1 5 15 100 0.0 0.5 1.0 1.5 1 2 3 N. nodes Cars RMSE 0 2 4 123 N. nodes Speed RMSE Nodes vs FL Rounds (RMSE of best configuration) FIGURE 4.9. Comparison of the Root Mean Squared Error (RMSE) regarding the number of nodes (federated models) and the number of FL rounds with (top) the average error of all the tested model configurations and (bottom) the best model configuration. Notice that the different number of rounds have an associated number of epochs. Learning rate on Federated Learning Now the focus is on the effect of the learning rate when using FL . The upper part of Figure 4.10 shows the average error of all hyper-parameter configurations with respect to the learning rate and the number of nodes. When the learning rate is small enough, splitting does not have a high impact on the error. However, if we increase the learning rate, the error increases with respect to the 𝑁 . This effect may happen because the local models are overfitting and the merged model is not able to fall in the local minima and lead to divergence. Figure 4.11 is an example of this. When the learning rate is high, the models are overfitted to the local data as is the case of the local model 2. As the data from local models 1 and 3 might be more similar, the merged model favors them as they have two-thirds of the voting when averaging. When using a smaller learning rate, the learning curve is smoother and converges to a better solution that fits all the data splits, i.e. produces a more generalized model. This can be observed in the lower part of Figure 4.10, which shows the error of the best configurations found for each parameter combination. 4.4.3 Effect of initialization when using Federated Learning It is known that using a common initialization of the models before training is required to find a good solution (McMahan et al. [ 52 ]). However, it is not clearly shown what happens when not using the initialization in the long run. Therefore, in this experiment, we show the effect of using a common random initialization versus random initialization for each model. The experiments are performed over the best configuration found for the cases of two and three models from Section 4.4.2. For each training process, random initialization and common initialization are tested. In Figure 4.12 it can be observed that initially, the non initialized setting produces a model that 46 ▶CHAP. 4 DISTRIBUTED ML ON FOG COMPUTING n_nodes 123 0.0 0.5 1.0 1.5 1e−04 0.001 0.01 Learning rate Cars RMSE 0 2 4 1e−04 0.001 0.01 Learning rate Speed RMSE Learning Rate vs Nodes (mean RMSE of all configuration) n_nodes 123 0.0 0.5 1.0 1.5 1e−04 0.001 0.01 Learning rate Cars RMSE 0 2 4 1e−04 0.001 0.01 Learning rate Speed RMSE Learning Rate vs Nodes (RMSE of best configuration) FIGURE 4.10. Comparison of the RMSE regarding the learning rate and the number of nodes (federated models) with (top) the average error of all the tested model configurations and (bottom) the best model configuration. model_node local 1 local 2 local 3 merged 1.25 1.50 1.75 2.00 2.25 0 25 50 75 100 RMSE Learning rate 0.01 1.25 1.50 1.75 2.00 2.25 0 25 50 75 100 FL Round Learning rate 0.001 1.25 1.50 1.75 2.00 2.25 0 25 50 75 100 Learning rate 0.0001 FIGURE 4.11. Cars RMSE with respect to the learning rate and the FL rounds. Notice that when the learning rate is 0.01 the merged model is overfitted towards the blue local data from models 1 and 3. When the learning rate is smaller, the model obtained is more general and is able to cover all the data splits. Also notice that for the four models, the test data is the same, therefore the data used for training in the local model 2 is more different than the other two splits. initially has a higher error. This is because the two models from the non initialized setting are initialized differently, producing different weight distributions. This makes that, for example, the hidden unit 1 recognizes one part of the input data while the unit 1 of the other model recognizes another part of the data. This makes the initial solution produced in the first step is close to random. However, when synchronization starts, both models get to similar error metrics. Finally, in this case, the speed is adjusted better in the first rounds of the non-initialized model by chance. Figure 4.13 shows a similar trend for the experiments federating 3 models. In particular, initialization provides a good solution in the first step from the start as we are training 34 epochs before synchronizing, a similar setup to what was proposed in Gutierrez-Torre et al. [ 21 ]. Notice that the first 4.4 EXPERIMENTS ◀47 model_node N2_init N2_no_init 2 3 4 0 25 50 75 100 FL Round RMSE N. Cars − RMSE vs FL rounds − N2 init 5 6 7 0 25 50 75 100 FL Round RMSE Speed − RMSE vs FL rounds − N2 init FIGURE 4.12. RMSE of the merged model for the number of cars and speed with 2 federated models comparing having a common initialization (N2_init) versus random initialization (N2_no_init). Configuration: Hidden units 6, batch size 32, epochs 1, federated rounds 100, and learning rate 0.0001. RMSE calculated with the test set. point of the green line represents the proposed method in Gutierrez-Torre et al. [ 21 ]. In that previous work, as federated rounds were not included, the error increased linearly with the number of models to federate. Moreover, we see that the non-initialized setup reaches a lower error in speed. This is not because not initializing the process is beneficial but to the stochastic nature of the model initialization. Different initialization leads the network to different configurations and then different results if the training falls into local minima. model_node N3_init N3_no_init 2 3 4 4 8 12 FL Round RMSE N. Cars − RMSE vs FL rounds − N3 init 4.5 5.0 5.5 6.0 4 8 12 FL Round RMSE Speed − RMSE vs FL rounds − N3 init FIGURE 4.13. RMSE of the merged model for the number of cars and speed with 3 federated models comparing having a common initialization (N3_init) versus random initialization (N3_no_init). Configuration: Hidden units 8, batch size 32, epochs 31, federated rounds 15, and learning rate 0.0001. RMSE calculated with the test set. In conclusion, providing a common initialization is helpful to have a usable result from the first synchronization step. However, it is not completely required, as after the second step the models will share the same structure because of the process. 4.4.4 Evaluation on low-powered devices In this experiment, we compared a FL round of the proposed solution’s effectiveness on low-power and resource constraint devices designed for the Edge, like the Raspberry Pi model 3B and the NVIDIA Jetson model Nano. Such devices are built for consuming less than 12W and embed low CPU and GPU computing resources. Raspberry Pi is used for general purposes while the Jetson integrates a GPU for AI and neural network computing on the Edge and smart devices. We measure the time of doing 48 ▶CHAP. 4 DISTRIBUTED ML ON FOG COMPUTING one FL round with the given configuration and 94 epochs to simulate the maximum time required to process one round. FIGURE 4.14. Time comparison for configurations in low-power devices vs. single CPU Xeon ref., for each amount of hidden units. Testing the grid configurations for Time Aggregation vs. Hidden Units on the Raspberry Pi and the Jetson Nano, we observed a noticeable increase in execution time in comparison with the single-CPU Xeon. Still, the training plus validation time is below 30 minutes for nearly a week worth of data. We tested 4, 32 as 512 Batch Size ( BS ), i.e., the number of samples used for each training step in the neural network to check the Jetson GPU ’s possible advantages due to data bandwidth. The bigger the batch size, the more we profit from the GPU ’s parallelism up to a certain point. The number of epochs is fixed at 94, to compare the performance of identical training processes, and the steps (iterations) per epoch are proportional to the batch size (200 steps/epoch for BS = 4, 25 steps/epoch for BS = 32, 1 step/epoch for BS =512). The objective was to test the method’s performance on low-powered devices with different properties while maintaining the error (that may vary when modifying the batch size). As a comparison metric, we show the milliseconds per step and the seconds per epoch. When computing the average milliseconds/step, the first epoch was excluded as it carries the overhead on warm-up around ×4the average epoch. Figure 4.14 shows the performance in times per step for the different configurations of the GRU in the different used technologies, for the training time with a common and proper configuration found for the GRU on the single-CPU Xeon, the Raspberry Pi ARM-based CPU , and the ARM-based and GPU enhanced Jetson. From this experiment, we concluded that our method is fully fit for use on low-power or resourceconstrained devices, as training times take at most half an hour for a model representing around six days. Moreover, we noticed that the GPU at the Jetson Nano does not provide improvement for the kind of data until the batch size reaches larger sizes. Figure 4.15 shows the absolute training time for the 3 devices, where the single Xeon outperforms the low-powered ones but for no more than a factor of 4, and how in scenarios requiring large memory bandwidth (low data aggregation and large batch sizes), the GPU starts chasing CPU execution times. 4.5 CONCLUSIONS ◀49 FIGURE 4.15. Average modeling time on different Edge devices. 4.5 CONCLUSIONS In this chapter, we have explored what Fog computing architectures are and how they are used to build distributed systems for near-realtime applications. Moreover, the Data Science pipeline was adapted to this kind of architecture, and Federated Learning ( FL ) framework was applied to it. Using this system it is possible to build centralized ML models training them where the data is produced. Doing this process on the Edge, allows the system to avoid sending unnecessary data to the backend which saves network bandwidth. Moreover, in case of connectivity failures, the training process can be continued unaffected, which provides a more robust system. In this chapter, we proposed to train the models in the Edge instead of uploading the data to the Cloud and performing the training there. This leads to two main advantages: the system can be trained online while receiving data without any additional latency and with this, a system that detects Concept Drift can be set up so that models are retrained instantly when they start failing, e.g. detecting changes with statistical mechanisms like Kullback-Leibler divergence. The architecture was evaluated with road traffic, but the same architecture applies to further chapters in which the main topic is maritime traffic and emission estimation. The experiments showed that this kind of system is possible and have extended the work from Gutierrez-Torre et al. [ 21 ]. First, the FL framework produces models that are similar in accuracy to the ones that would be produced centrally, contrary to our previous work. Moreover, in some situations the models are better which may be related to the improvement in generalization that merging models can have [ 112 , 113 ]. The initialization of the models was also tested and the experimental results showed that a common initialization of the models is recommendable but not vital for the process, as the first synchronization performs the same effect as initializing. Mind that not initializing the models leads to losing computation time of the first step. Finally, the experiments show that this approach can be used with the proposed model as it is light enough to be trained in low-powered devices. There are also limitations and future work to cover for this chapter. First, the optimization algorithm RMSProp is used, which includes an adaptive learning rate mechanism. This is generally good when training this kind of model. However, when doing a new FL round the learning rate is reset due to how the current code works internally. It will be positive to create a mechanism that takes this into account and saves the last learning rate applied to avoid jumps in the error function. Moreover, online 50 ▶CHAP. 4 DISTRIBUTED ML ON FOG COMPUTING and batch learning are not compared, only the results for batch learning are provided. As mentioned before, it is also required to study the Concept Drift in this context, however, this would require extra data and, if possible, online streaming data. Finally, other techniques like Graph Neural Networks ( NN s) could be explored and also other hardware platforms like MicroController Units (MCUs). CHAPTER 5 Ship properties missing data estimation and evaluation with Machine Learning 5.1 INTRODUCTION Maritime traffic is a key component for the European Community [ 11 ] because of its fuel efficiency compared to other means of transportation for goods, according to the European Community Shipowners Associations (ECSA). As the global economy expands, the relevance of maritime traffic grows, especially in terms of exhaust emissions. The Third IMO Greenhouse Gas study [ 96 ] showed that due to the global-scale trade the contribution to global Greenhouse Gas will increase between 50% and 250% by 2050. Given this situation, governments and organizations like the World Health Organization are interested in the advances of emission detection to create law enforcement for Air Quality Standards. Given the current technological advances, detecting the exhaust emissions from ships in near real-time is possible. By international regulation, most of the ships are equipped with the AIS system. This GPS-based tracking system is used to prevent collisions between ships, however, the data can be correlated with the ship characteristics to estimate how much pollution the ship is producing at that precise moment. The estimation of the exhaust emissions with this data is covered in the scientific literature, like in the work of Jalkanen et al.[ 1 , 16 ] with their STEAM methodology. Other methodologies based on different data sources like the HERMESv3 model [ 25 ] can benefit from this data to accurately position the emissions, improving therefore their spatial and temporal resolution. AIS-enabled methodologies make use of the AIS speed, timestamp, and position to evaluate how, when, and where the engine is being used. Along with this data a static dataset containing the characteristics of the ship is used. This dataset is crucial as it contains attributes used to compute the emissions, e.g. the total installed engine power. This dataset is required for the calculations inside the model, defining characteristics like the boundaries of how much power and fuel is being used, the type of fuel required in the ship, or the amount of auxiliary engine power at a given point, among others. Even though the methodology provides high spatio-temporal accuracy compared to other approaches [ 98 ], it is highly dependant on the quality of data, i.e. how fit is the data for a given problem as defined in Section 2.5.1. On one hand, AIS data may be incorrect due to human or machine errors or samples may be missing [ 18 , 95 ]. On the other hand, a similar situation happens with static data provided by ship registries. The data may be missing due to multiple registries managing the same area [3] or attributes that are commonly missing or incorrectly set [4,95]. IMO reports showed that important features for the emission estimation can be missing and that the methodologies for estimation should be aware of this phenomenon [ 96 ]. This is the case of RPM (91% of availability), the main engine installed power (99.1% of availability), or the length of the ship (43.2% of availability). Since vital data for maritime traffic analysis can be missing, there has been research in this direction. This process is called in the literature as error correction, data infill or missing data estimation and is part of the data preparation process in the Data Science pipeline, which is in charge of making sure that the data is fit for use for a given application. For example, Johansson et al.[ 26 ] proposed a mechanism 51 52 ▶CHAP. 5 SHIP PROPERTIES MISSINGS ESTIMATION WITH ML to estimate the missing data with ships that are similar to the one being treated. There have been other efforts using standard Machine Learning [ 98 ] and specific studies of a particular ship type [ 4 ]. However, to our knowledge, there is no comparison of methods nor a guideline for practitioners that want to use this kind of data for maritime studies or emission estimation. Moreover, scenarios with low-powered compute devices like Smart Cities or Edge Computing settings can benefit from exploring traditional fast ML techniques. The missing data estimation process can be done in the devices near where the data is produced, e.g. AIS antennas, so that the data is only transmitted after correction. Therefore, the contributions of this study are the following: •Provide a review of the methods that are currently being used for this task in the field. • Provide a comparative analysis of missing data estimation techniques applied to ship characteristics. •Apply standard ML techniques that are easy to use and fast to train. • Close the gap between practitioners and data analytic techniques providing a guide on how to successfully apply standard ML techniques. The structure of the chapter is the following: Section 5.2 presents the background and methodology to reproduce this work. Section 5.3 shows the results and the discussion of experiments. Finally, Section 5.4 contains the conclusions and limitations of this study. 5.2 METHODS AND DATA In this section all the required methods and data is presented. Some specifics on emission estimation are provided as context along with the available data required for the process. Then, the manual preprocess of the data is introduced to ensure the fitness for use of data. The basic ML and state-of-the-art techniques required to understand this chapter are introduced. Finally, the used validation protocol and metrics are introduced. All these elements define the prerequisites and key building blocks for this contribution. 5.2.1 Emission estimation Ship exhaust emissions can be estimated with different approaches and points of view. Primarily, there are two main approaches: Top-down and Bottom-up. Top-down starts from the global emission measure and tries to disaggregate the value to estimate where it comes from. On the other hand, Bottom-up approaches use positional data, e.g. GPS , to accurately position the origin of the emission. With the available characteristics from that origin, this kind of methodology can estimate how much pollution is produced by that origin. This approach is better than the former in precision and temporal resolution [ 3 ]. Notice that there might be methodologies that fall in between the two main approaches. In particular, this work makes use of the second approach using the STEAM methodology proposed by Jalkanen et al.[ 1 , 16 ]. STEAM2 from Jalkanen et al.[ 16 ] improves STEAM from Jalkanen et al.[ 1 ] in terms of the ship characterization, adding details on water friction, engine load balancing, and other factors that affect the engine usage. Both versions of the methodology make use of the data coming from the AIS and static information from the ship to position the emissions and calculate the amount of pollution that is produced. Following this methodology, we have to calculate two factors to estimate the emissions: the activity factor and the emission factor. The activity factor is measured in kWh and refers to how much power are the engines producing at a given time. The emission factor is measured in g/kWh and refers to how many grams of each pollutant is emitted for each kWh generated. Equation 5.1 represents the two 5.2 METHODS AND DATA ◀53 parts needed for the calculation. Notice that with AIS we have the timestamp and the position of each sample, therefore we can locate spatio-temporally the data with precision. 𝐸𝑚𝑖𝑠𝑠𝑖𝑜𝑛𝑠 (𝑔)=𝐸𝑚𝑖𝑠𝑠𝑖𝑜𝑛𝐹𝑎𝑐𝑡𝑜𝑟 (𝑔/𝑘𝑊ℎ) ∗ 𝐴𝑐𝑡𝑖𝑣𝑖𝑡𝑦𝐹𝑎𝑐𝑡𝑜𝑟 (𝑘𝑊ℎ)(5.1) For this purpose, we require that the data is available and correct. In STEAM2, whenever a key attribute is missing, the STEAM methodology is used as a fallback. This is because the first version is more general and simple and, therefore, it requires fewer attributes to do the calculation. In this work, we focus on STEAM so that we make as few assumptions as possible about data. To estimate the activity factor the methodology needs the current speed of the ship and the installed power on main and auxiliary engines. For the emission factor the SFOC , the engine’s RPM , and the fuel type are required. In both STEAM and STEAM2 the SFOC is fixed to a given value. If more accuracy is desired the approach followed by United Kingdom’s NAEI [ 95 ] can be followed. This approach uses other studies to estimate reference values by using the engine type and fuel type. In this case, we consider SFOC as constant following STEAM as we are already in a case where data is missing. Given this information, this work will focus on the requirements from STEAM as STEAM2 uses it as a fallback when data is missing [16]. Figure 5.1 shows a simplified data pipeline with every step needed for a correct emission estimation. Static and AIS data cleaning process and data inferencing are the data preparation steps mentioned in Section 2.5.1 that ensure the fitness for use of data for computing emissions, i.e. they ensure the data quality. In the following subsections all the processes are described. No data Static data Infer data Static data cleaning process AIS data AIS cleaning process Clean static data Clean AIS data Compute emissions FIGURE 5.1. Description of the data pipeline from raw data to the emission computation. AIS cleaning process is a simplified version of Jeon et al. [ 2 ]. Data inference when there is no data is covered on Section 5.2.6. This work covers the static data cleaning process. Notice that the complete process can be performed on-line. It is possible to use the pipeline in the system described in Chapter 4so that the data preparation is performed when the data arrives and then the emissions are computed. However, the correction of static data is also well suited for the cloud or central system as this kind of data does not evolve over time. However, it is interesting to use the approach of Chapter 6(data inference in the figure) in the Edge as the data required for the process is collected there. 5.2.2 Data description There are two datasets required to estimate emissions: the data provided by the AIS and the data provided by a ship registry. Both datasets are constrained to the area of the port of Barcelona and refer to the year 2017. AIS dataset The first dataset is a time-series dataset that contains the position, speed, and other ship characteristics. This dataset was obtained from the local port authorities. Each ship emits this data to the others by 60 ▶CHAP. 5 SHIP PROPERTIES MISSINGS ESTIMATION WITH ML inst_pow_me type_Passenger_(Cruise)_Ship type_Bitumen_Tanker type_Others type_Yacht type_Ro−Ro_Cargo_Ship type_Cement_Carrier design_speed type_Heavy_Load_Carrier type_Refrigerated_Cargo_Ship type_Oil_Products_Tanker type_LPG_Tanker type_Tug type_Passenger/Ro−Ro_Cargo_Ship type_Crude_Oil_Tanker type_Container_Ship type_Chemical/Oil_Products_Tanker type_Vehicles_Carrier type_Bulk_Carrier type_General_Cargo_Ship l t 0 5 10 15 20 Importance Variables b with Linear Regression type_Tug type_Yacht type_Cement_Carrier type_Heavy_Load_Carrier type_Passenger/Ro−Ro_Cargo_Ship type_Bitumen_Tanker type_Refrigerated_Cargo_Ship type_Ro−Ro_Cargo_Ship type_Oil_Products_Tanker type_Passenger_(Cruise)_Ship type_Chemical/Oil_Products_Tanker type_Container_Ship type_General_Cargo_Ship type_Others type_Crude_Oil_Tanker type_LPG_Tanker type_Vehicles_Carrier design_speed type_Bulk_Carrier inst_pow_me t l 0.0 0.2 0.4 0.6 0.8 Importance Variables b with Random Forest type_Tug type_Passenger/Ro−Ro_Cargo_Ship type_Chemical/Oil_Products_Tanker type_Cement_Carrier type_Oil_Products_Tanker type_Ro−Ro_Cargo_Ship type_Bitumen_Tanker type_General_Cargo_Ship type_Heavy_Load_Carrier design_speed type_Passenger_(Cruise)_Ship type_Bulk_Carrier type_LPG_Tanker type_Others type_Container_Ship inst_pow_me type_Refrigerated_Cargo_Ship type_Yacht type_Vehicles_Carrier t type_Crude_Oil_Tanker l 0.0 0.1 0.2 0.3 0.4 0.5 Importance Variables b with XGBoost FIGURE 5.5. Relevance of variables to predict the beam. Notice that the variable selection matches closely with the correlations shown in Figure 5.4. The final set of variables is used in Section 5.3.3. 5.3.3 Relevant variables Here we test the performance of using the relevant variables from Section 5.3.2. In particular, we wanted to explore the importance of the type variable because it was shown that for some attributes it was very relevant, e.g. for design speed. Therefore this experiment was done with two sets of variables: the relevant variables without type (Table 5.4) and the relevant variables with type (Table 5.5), even for variables where type was not marked as relevant. Table 5.4 shows the results using only two variables. From Table 5.2 we can observe that Beam and AE Power prediction stay in the same level of precision. ME Power (Test 𝑅2 :0 . 985 → 0 . 98), Length 5.3 RESULTS AND DISCUSSION ◀61 𝑅2RMSE MAE Target Algorithm Train Test Train Test Train Test Beam RF 0.9975 0.9900 0.5377 1.0659 0.2618 0.5651 (Length, Design Speed) XGBoost 0.9976 0.9893 0.5214 1.1075 0.3092 0.6100 Design Speed XGBoost 0.9563 0.9193 0.8381 1.1323 0.5812 0.7296 (ME Power, Draft) RF 0.9739 0.9132 0.6471 1.1747 0.4019 0.6501 AE Power RF 0.9761 0.8981 554.7271 1178.8827 257.6787 550.5837 (ME Power, Beam) XGBoost 0.9934 0.8821 290.2708 1268.1226 85.3203 511.4801 ME Power RF 0.9969 0.9802 933.4769 2443.5418 407.8315 967.2775 (Length, Design Speed) XGBoost 0.9979 0.9781 776.8909 2571.8108 524.7569 1056.9163 Length RF 0.9966 0.9854 4.3831 9.2533 2.3068 4.9576 (Beam, ME Power) XGBoost 0.9907 0.9800 7.2951 10.8370 5.2606 7.2009 ME RPM RF 0.9853 0.8721 55.6414 162.1726 22.6584 64.8916 (Draft, ME Power) XGBoost 0.9892 0.8675 47.8553 165.0145 22.8113 66.3813 Draft RF 0.9900 0.9622 0.3721 0.7214 0.1892 0.3871 (Beam, Length) XGBoost 0.9893 0.9612 0.3849 0.7305 0.2378 0.4133 TABLE 5.4. Error measures for training and test for the target variable predicted only with the relevant variables. The variables used to predict are written below the variable to predict. Only the two best algorithms are shown for each variable. The full table is available in the supplementary material. Ordered by test 𝑅2. 𝑅2RMSE MAE Target Algorithm Train Test Train Test Train Test Beam RF 0.0005 0.0011 -0.0506 -0.0611 -0.0313 -0.0613 (Length, Design Speed) XGBoost 0.0015 0.0013 -0.2103 -0.0700 -0.1832 -0.1047 Design Speed XGBoost 0.0277 0.0269 -0.3309 -0.2082 -0.2798 -0.1867 (ME Power, Draft) RF 0.0220 0.0280 -0.3925 -0.2078 -0.2702 -0.1159 AE Power RF 0.0004 -0.0009 -4.9752 5.2422 -8.7550 -16.7539 (ME Power, Beam) XGBoost -0.0151 0.0051 237.2241 -27.9569 250.9958 43.4501 ME Power RF -0.0011 -0.0012 150.1328 73.8664 248.2645 137.4452 (Length, Design Speed) XGBoost 0.0016 -0.0003 -381.3468 18.2249 -276.7815 -62.3720 Length RF 0.0019 0.0062 -1.4683 -2.2352 -0.8114 -0.9614 (Beam, ME Power) XGBoost 0.0069 0.0097 -3.5487 -3.0396 -3.3472 -3.1494 ME RPM RF 0.0115 0.0253 -29.7687 -16.9290 -11.2778 -7.2151 (Draft, ME Power) XGBoost -0.0049 0.0297 9.7729 -19.6946 0.5686 -6.1110 Draft RF 0.0068 0.0259 -0.1616 -0.3174 -0.0728 -0.1559 (Beam, Length) XGBoost 0.0092 0.0251 -0.2393 -0.2967 -0.1553 -0.1761 TABLE 5.5. Difference of error when adding type variable as a predictor with respect to Table 5.4. The variables used to predict (excluding type which is used in every experiment) are written below the variable to predict. Increase in 𝑅2 and decrease in RMSE and MAE means better fit. Only the two best algorithms are shown for each variable. The full table is available in the supplementary material. Ordered by test 𝑅2. (Test 𝑅2 :0 . 99 → 0 . 985) and Draft (Test 𝑅2 :0 . 988 → 0 . 96) show a slight decrease in precision. On the other hand, Design Speed (Test 𝑅2 :0 . 95 → 0 . 919) and ME RPM (Test 𝑅2 :0 . 92 → 0 . 87) precision fall drastically. In particular, we are increasing the mean error in 0.21 knots in Design Speed and 11.7 RPM for ME RPM . Notice that the results provided by RF and XGBoost are still better compared to the other algorithms, even using just two variables. Table 5.5 shows the results of using the previous two variables plus type. Overall the increase of precision is not increased except for Design Speed, ME RPM and Draft, which were the variables that lost more precision when reducing the variable set. Type is an important variable, however, it may not as relevant as the others, or the same information is contained in the other variables. 5.3.4 Unique variable In the extreme case where there is little information, it is still possible to predict the variables with a certain degree of accuracy. In this case, we have selected the variable that had more relevance from 5.3.2, which matched with the variable with more correlation from Figure 5.4. In Table 5.6 we can observe the results from this experiment. Compared to the relevant variables without type outcomes (Table 5.4) we can observe an overall decrease in precision. In particular, it can be seen that KNN and 1 layer 62 ▶CHAP. 5 SHIP PROPERTIES MISSINGS ESTIMATION WITH ML Neural Network appear now as good solutions to the problem. This is because RF is strong when there are more variables to sample from. When there are few variables, the trees built are more related. With this, we lose the tree independence requirement that makes RF work. Regarding the 𝑅2 ,Beam can be predicted with a 1.5% of decrease in the metric, which impacts the average error (MAE) as 0.5 more meters on average incorrectly estimated. In the case of Design Speed, it can be seen that the decrease is 6%, however, the impact on the actual values is an increase of 0.3 knots in error, which is acceptable for this task. On the other hand, ME Power falls only 2.5%, but this means that on average we increase the error by 900kW. Notice that regarding RMSE the big errors grow more than the average. Lenght also suffers from a decrease of 4%, adding 6 meters of error on average in the estimation. ME RPM keeps a stable error regarding 𝑅2 and on average it only adds 30 RPM to the error. Finally, Draft falls a 4%, but only adds about 0.3 meters to the average error. 𝑅2RMSE MAE Target Algorithm Train Test Train Test Train Test Beam XGBoost 0.9868 0.9744 1.2264 1.7085 0.8013 1.0654 (Length) RF 0.9805 0.9727 1.4892 1.7648 0.9385 1.1449 Design Speed XGBoost 0.8695 0.8574 1.4473 1.5057 0.9991 1.0932 (ME Power) KNN 0.8922 0.8561 1.3157 1.5125 0.7975 0.9997 AE Power XGBoost 0.9026 0.8624 1119.2508 1369.8897 651.3921 713.7344 (ME Power) KNN 0.8767 0.8505 1259.3877 1427.8572 611.7369 707.7976 ME Power KNN 0.9665 0.9537 3070.5436 3742.5165 1407.5615 1874.7986 (Length) XGBoost 0.9693 0.9517 2937.0998 3819.8798 1682.1618 2032.9765 Length XGBoost 0.9559 0.9473 15.8575 17.5739 9.8878 10.9411 (Beam) RF 0.9553 0.9471 15.9653 17.6154 9.9571 11.0681 ME RPM 1 layer NNet 0.8671 0.8622 167.5842 168.3189 96.4330 95.5028 (Draft) RF 0.9073 0.8597 139.9690 169.8230 78.0129 89.9753 Draft RF 0.9367 0.9216 0.9344 1.0391 0.6337 0.7072 (Beam) XGBoost 0.9345 0.9211 0.9510 1.0420 0.6555 0.7124 TABLE 5.6. Error measures for training and test for the target variable. The variable used to predict is written below the variable to predict. Predicted only with the most relevant variable. Only the two best algorithms are shown for each variable. The full table is available in the supplementary material. Ordered by test 𝑅2. As observed, with only one variable the variable prediction is still doable with some shortcomings, e.g. the big increase of error of ME Power. Attributes with strong correlation are logically still easy to predict. In the case of ME RPM , a conclusion is that ships with less Draft tend to have higher ME RPM , e.g. small yachts, and the other way around, e.g. Cruisers and Cargo ships with low RPM . Another example is Design Speed, where the more ME Power a ship has, the higher the design speed is. However, it is obvious that in this case, other characteristics have to be taken into account, like for example Draft or any of the size measures, as bigger ships need more power to move. 5.3.5 Comparison with existing solutions MSV comparison Johansson et al.[ 26 ] propose MSV which will use the characteristics of the ship that is most similar using the metric shown in Section 5.2.4. As seen there, this method is a KNN with a custom metric over Design Speed and Lenght and a parameter 𝑎 previously adjusted using a Monte Carlo procedure. To compare we use KNN with 𝑘= 1and 𝑘= 3. 𝑘= 1is the same as doing the MSV with the following metric (euclidean distance): 𝑠=√︃(𝑣−𝑣𝑐)2+(𝑙−𝑙𝑐)2(5.3) In Table 5.7 the experiments of using Design Speed and Lenght as predictors are shown. For every variable, it can be observed that the results are consistently worse than the ones in Table 5.4, which also use two variables. Moreover, tree-based algorithms are always superior. One thing to notice is that 5.3 RESULTS AND DISCUSSION ◀63 𝑅2RMSE MAE Target Algorithm Train Test Train Test Train Test Beam RF 0.9957 0.9842 0.6994 1.3413 0.3479 0.7555 XGBoost 0.9966 0.9823 0.6188 1.4219 0.3228 0.8451 3NN 0.9874 0.9823 1.1967 1.4226 0.5906 0.8152 1NN 0.9979 0.9805 0.4920 1.4902 0.0512 0.6413 MSV 0.9973 0.9730 0.5527 1.7562 0.0598 0.7836 AE Power RF 0.9729 0.8890 590.2442 1230.4580 281.1902 580.1873 XGBoost 0.9679 0.8847 642.5920 1253.9018 314.9681 597.1411 1NN 0.9848 0.8825 441.6284 1265.9871 83.2525 541.7500 3NN 0.9292 0.8789 953.9023 1285.2560 449.6223 632.9286 MSV 0.9886 0.8669 382.5517 1347.0451 75.5772 554.3957 ME Power RF 0.9963 0.9799 1025.3560 2465.9112 428.6885 978.8303 3NN 0.9871 0.9755 1901.8463 2721.2939 768.5421 1143.6786 1NN 0.9995 0.9717 368.2261 2927.1558 77.7506 963.1471 MSV 0.9995 0.9710 365.3108 2963.1109 71.6225 1041.1629 ME RPM XGBoost 0.9742 0.8710 73.7837 162.8481 36.6714 82.0743 RF 0.9759 0.8700 71.3819 163.4616 38.1288 83.3670 3NN 0.9297 0.8557 121.8638 172.2444 59.0172 91.1690 1NN 0.9963 0.8223 28.0424 191.1055 3.0852 75.2486 MSV 0.9957 0.7816 30.0128 211.8606 3.5080 85.6100 Draft RF 0.9890 0.9541 0.3890 0.7946 0.2411 0.4687 1NN 0.9963 0.9486 0.2264 0.8413 0.0377 0.3893 3NN 0.9670 0.9410 0.6747 0.9009 0.3497 0.5210 MSV 0.9970 0.9311 0.2029 0.9740 0.0325 0.4515 TABLE 5.7. Comparison of the best algorithms found, KNN and MSV . The full table is available in the supplementary material. Ordered by test 𝑅2. MSV is consistently worse than both KNN . This fact shows that the 𝑎= 0 . 35 from Johansson et al.[ 26 ] is not a global constant, i.e. it is overfitted to the data, and should be tuned for each database. Length*Beam As shown by Huang et al. [ 4 ], the ME Power can be predicted using the product of the Length and Beam, i.e. the area of the ship if it was rectangular, for Tankers. In our case, we compare this metric for all the ship types. Contrary to the situation shown in Huang et al. [ 4 ], the correlation of ME Power with Length times Beam we obtain that it is 0.8377, lower than the correlation of Length, which is 0.8428. 𝑅2RMSE MAE Target Algorithm Train Test Train Test Train Test ME Power RF 0.9787 0.9307 2444.9302 4576.5184 951.1324 2006.6138 (Length*Beam) XGBoost 0.9485 0.9257 3803.4448 4739.4473 2081.3133 2576.2111 poly2 0.7225 0.7473 8831.9435 8740.2747 5310.2186 5273.8748 LM 0.7017 0.7180 9155.9720 9232.4103 6155.3972 6231.0306 ME Power RF 0.9934 0.9699 1360.2618 3015.9177 627.2374 1302.5491 (Length, Beam) XGBoost 0.9917 0.9648 1523.9397 3262.3938 942.4226 1515.6529 poly2 0.8995 0.9008 5315.7676 5474.9995 3124.0154 3245.4752 LM 0.7924 0.7847 7637.8210 8067.4960 5432.4080 5712.9536 TABLE 5.8. Installed power main engine predicted with Length*Beam and (Length and Beam). The full table is available in the supplementary material. Ordered by test 𝑅2. Table 5.8 shows the two best results of applying all algorithms and also the linear model and squared polynomial regression for comparison with the results from Huang et al. [ 4 ]. It can be observed that in all the cases it is better to leave both variables instead of building the joint Length times Beam, as with this classifiers have more freedom to adjust how the variables are related. This fact is clear in Figure 5.6, where the curves produced by the polynomial regression are shown. Figure 5.6a shows the polynomial regression for Length times Beam. It can be seen that the dispersion along the curve is high, showing why the model is not that good. On the other hand, Figure 5.6b shows the same data points with different 𝑥 axis and the polynomial regression for Length and Beam. In this case, the surface produced by the polynomial regression is not a line but a 2D plane, which allows fitting better the data. 64 ▶CHAP. 5 SHIP PROPERTIES MISSINGS ESTIMATION WITH ML 0 2500 5000 7500 10000 12500 15000 17500 l_b 0 10000 20000 30000 40000 50000 60000 70000 inst_pow_me (A) ME power versus Length times Beam scatterplot. Blue line is the result of the polynomial regression by using Length times Beam as predictor. 50 100 150 200 250 300 350 l 0 10000 20000 30000 40000 50000 60000 70000 inst_pow_me (B) ME power versus Length scatterplot. The blue line is the result of the polynomial regression produced by using Length and Beam as predictors. FIGURE 5.6. Polynomial regression scatterplot for each case. Given these results, we can conclude that the results from Huang et al. [ 4 ] are not extrapolable to other ship types and that this metric needs to be studied before being used. 5.4 CONCLUSIONS AIS -enabled emission estimation methodologies are growing because of their ability to locate spatiotemporally the exhaust emissions produced by vessels. By combining AIS data and vessel technical databases it is possible to produce an estimation. However, both data sources may contain human and machine errors. If this data is used directly, the estimation produced will be erroneous as well. There are efforts in the literature to clean AIS data. Nevertheless, there are few approaches to provide clean data in vessel characteristic databases and there is no comparison among them. In this work, we have provided a review and a common framework of the current methods that are being used to in-fill vessel characteristics data and a comparison of the methods. Moreover, we have explored the relationship between variables to then exploit them with predictive algorithms. And finally, we have shown how to apply standard techniques for this kind of use case obtaining good accuracy. The studied variables have shown strong correlations inside of two groups: variables that are related to the size of the ship and variables related to the engines. Moreover, there are relationships between those groups, e.g. installed ME power with the length of the ship. As the variables are very correlated, the prediction methods provide good accuracy. Finally, we have found which variables are relevant to predict each variable by analyzing the linear model coefficient and the tree-based algorithms variable importance. The findings with these methods were closely related to the linear correlations computed and provided good predictive results. The type variable is a relevant variable for most of the target variables. However, the experiments show that it is not a vital part of the information for the prediction in our case. Regarding predictive methods, Random Forest ( RF )and XGBoost are the methods that work best in the case of predicting the target using two or more predictor variables, confirming that the selection done in the work of Liu et al. [ 98 ] is a good approach (XGBoost). When using only one predictive variable other methods may outperform them. Methods like KNN or MSV can provide allthe required attributes from the ship information as they are based on using the actual data directly as the prediction. This can also be done using Neural Networks if trained with a multivariate output, i.e. trained to predict an array instead of one element. Even though of the convenience of this approach, experiments show that 5.4 CONCLUSIONS ◀65 picking the correct set of predictors leads to better results. The standard KNN with 𝑘= 1has provided better results than MSV for every variable. This may happen because the 𝛼parameter from MSV may be overfitted to the data used in Johansson et al.[ 26 ] and could need retuning. Nevertheless, adopting KNN as a first baseline method is highly recommended because of its simplicity and availability in ML software. We have seen that the accuracy of the predictive models decreases with the number of predictor variables. In this case, what we propose to implement is a system in which can use different trained models regarding which variables are available in the vessel to correct. This way ships with more information available benefit from better estimations, i.e. using the All Variables model whenever it is possible and if not, fall back to the others. This study is also subject to some limitations. We have not performed the analysis of other interesting variables, e.g. build year of the ship. However, the methodology to perform this analysis would remain the same. Moreover, Neural Networks could be trained to predict a vector of targets, providing the same advantage that KNN and MSV have. Future work should cover more ship-related variables. For example deadweight as covered in the 4th IMO Greenhouse Gas report [ 97 ] or the variables used in emission estimation methodology STEAM2 [ 16 ]. Finally, as this data is going to be used in further data processes, e.g. emission estimation, an uncertainty measure could be provided for each prediction so that each estimation has an error margin. CHAPTER 6 Improving maritime traffic emission estimations on missing data with CRBMs 6.1 INTRODUCTION Maritime traffic is considered an important contributor to primary atmospheric emissions in coastal areas [ 13 ] and subsequently to European coastal air quality degradation [ 14 ], especially in the North Sea and the Mediterranean basin. It has become a key component for European economy [ 11 ], according to the European Community Shipowners Associations (ECSA) in 2015, being sea transportation more fuel-efficient than other modes of transport (e.g. trucks or trains). Nevertheless, according to recent reports by the IMO , this form of transport will continue increasing in the future due to globalization and global-scale trade [ 12 ], increasing between 50% and 250% its contribution to the global Green- House Gas (actually 2 . 5%) by 2050. World governments, specially the European Union and the World Health Organization, are specially interested in advances on detection of emissions, for proper law enforcement towards the Air Quality Standards. Given this growing tendency, Smart Cities need to be enabled to know how much pollution do the citizens suffer and act accordingly. In this case, ships can be seen as connected things like in the IoT paradigm, informing about position and other characteristics with which exhaust emissions can be estimated. With all this information the cities will be able to evaluate pollution and propose more informed measures in order to have a healthier city. Data from ship positioning and maneuvering is required to compute the emission components produced by maritime traffic and to understand levels of pollution from Environmental Research modeling techniques. This data is obtained from the AIS , a GPS based tracking system used for collision avoidance in maritime transport as a supplement to marine radars, providing for each vessel its unique identifiers, GPS positioning and speed among other information. Wellknownandvalidatedstate ofthearttechniquesto estimate emissions areusing thisinformation plus ship engine characteristics databases, like Jalkanen et al. [ 1 , 16 ]. Doing so enables spotting sources and amounts of emitted pollutants. Such estimations result in large scale simulations and complex physics models, that feed from features like speed and installed engine power. Other techniques like the HERMESv3 [ 25 ] model in CALIOPE project [ 119 ], one of the trusted sources of Air Quality estimations by Spanish and Catalan Governments, performed at the Barcelona Supercomputing Center (BSC), use emissions reports, ship estimated routes and profiles by ship type for calculating ship emissions. While the HERMESv3 uses estimated routes, AIS -based estimations can place the pollutants estimations accurately as it uses the actual ship placement, therefore improving the overall precision of the system. However, AIS data may be incomplete or faulty, e.g. information that could be used to enhance physical models like the ship operational mode (e.g. cruising) is incorrect, missing or poorly detailed too often, so are usually discarded when modeling emissions. This also may be the case of commercial databases that provide the required ship engine characteristics. Further, dealing with AIS data in populated regions is not trivial, as the average frequency of signal emission is of one message per each six seconds on average. Only in the coastal region of Barcelona represents 1.5 million registers per week. Processing this data in a periodical basis requires employing Big Data techniques, understanding Big Data as those situations where big volumes of input overwhelm 67 68 ▶CHAP. 6 IMPROVING EMISSION ESTIMATIONS ON MISSING DATA our commonly used methodologies, making us to change them for techniques designed towards automation, scalability or approximation. Applying the complex physical models and simulations over such amount of data makes the problem more complex, requiring supercomputing infrastructures on a daily basis for periodical estimations, also predictions for public health and interest (CALIOPE computes 48-hour forecasts for all European continent). To enhance such estimations, allowing better enabling features, we have available Data Mining and Machine Learning ( ML ) techniques, to refine, correct and fill missing data, allowing better accuracy on current air quality methods, also allowing experts on using once discarded features on physics models with higher confidence on the results. Data Mining provides consolidated techniques for analyzing such data, extracting relevant values, frequent and rare patterns, and also model behaviors. Most of those wanted patterns are not trivial or present at simple sight, even they can be found across huge amounts of data, unable to be handled exclusively by human experts. Considering the AIS obtained profiles for each ship of any size and characteristics as multi-dimensional time-series representing their behavior, we can discover new latent features that can enhance the AIS data-set towards modeling emissions. There are several approaches for mining patterns on time series, e.g. stream mining methods for time-changing data [ 120 ], series-aware neural networks as CRBM s [ 121 ] or Recurrent NNs, even Hidden Markov Models for time-series modeling [122]. This work provides a methodology to enhance the obtained AIS data-sets by cleaning, treating and expanding some of its features using domain knowledge, to produce better emission models and correct emission inaccuracies. The proposed methodology focuses on using CRBM s to boost clustering and prediction algorithms, to improve the correctness of features like ship main engine power, navigation status and ship category, from each ships navigation traces. The decision of using CRBM s is based on their capacity to deal with AIS as multi-dimensional time-series [ 89 ], also encouraged by the methodology proposed by Buchaca et al. [ 123 ] used for detecting phase behavior patterns on timeseries. The CRBM s are used to extract and cluster temporal patterns, also to expand features from the time series, allowing non-time-aware predictors better accuracy. Our methodology combines CRBM s with clustering techniques (i.e. 𝑘 -means) and prediction techniques (e.g. Random Forests, Gradient Boosting, Lasso) towards predicting and characterizing the engine installed power, the navigation status and ship types from their traces, for vessels do not have any of those attributes or that provide them incorrectly. To summarize, the contributions are the following: 1) Generate feature representations of local behavior of ship movements using CRBM s. This new feature representation is a key building block for 2) and 3). 2) Ship type and main engine installed power missing values correction for better emission estimations using the previously generated features plus machine learning algorithms. 3) Providean initialstep tocorrectand improveNavigationalStatusAIS feature, using thegenerated features plus a clustering technique. In particular the second contribution of this chapter links with the work done in Chapter 5, where the focus was on correcting data when other static ship attributes are present. When there is no static ship attribute available for a ship that has AIS data available, this other approach has to be used. In this sense, we reconstruct this static data out of the available dynamic data, enabling the model to work with more data, i.e., doing less assumptions about the ship. Further, this contribution can be computed completely ant the Edge following the contribution in Chapter 4as the AIS data is produced there. The current approach has been tested using real AIS data provided by the Spanish Ports Authority (Puertos del Estado), complemented by ship and engine characteristics coming from the Ship database provided by IHS-Fairplay. We validate and test our approach to enrich and complete data by comparing it against the current state of the art approaches with a methodology based on Jalkanen et al. [ 1 , 16 ] in scenarios of missing data, in a supervised manner to get emissions computed with real and complete 6.2 DATA PREPARATION ◀69 data. After the aggregation of the emissions, we show that when enhancing the data with our method we are able to detect a 45% of the previously undetected emissions (152.95 tonnes out of 343.47) when applying the proposed standard procedure. We also show how other faulty features like Navigation Status and Ship Type can be corrected or improved. This chapter is structured as follows: Section 6.2 describes the data-set, its features and details. Section 6.3 explains our methodology and machine learning pipelines. Section 6.4 details the experimentation and validation of our methodology. Finally, section 6.5 summarizes this work, and presents the future work. 6.2 DATA PREPARATION Cleaning and interpolation First of all, rows with incorrect time-stamps are removed if there is no possibility of repairing them. Names, if missing, are obtained from third party ship databases, freely providing such information, such as VesselFinder [ 124 ]. Next step is to retrieve each ship time series and then processed it for time regularization and interpolation when required. Data goes through a two step procedure: 1) Produce the time-steps for the desired time granularity, e.g. a sequence of steps of 5 seconds in between; and 2) Using the available data, linearly interpolate the steps generated in the previous operation if the time difference between samples is less than 72 hours[1]. In order to avoid bias or over-fitting on locality when searching for patterns, a new feature is added indicating the relative movement, by obtaining the difference in Latitude/Longitude between each consecutive points. This way we register the movements between registered observations instead of absolute values, having a movement feature free of geographical information. Also, the same procedure can be performed over rotation features, having as result relative rotation movements. However, rotationattributes from AIS arenot alwaysavailable, hence herewecreated arotation variablecalculated from the GPS traces as they are more reliable. Another generated feature is the zone location of vessels. Following the information provided from CEPESCA [ 125 ], we consider that sea is divided in three zones: coast, fishing area and high sea. These zones respond where bathymetry is below 50 meters, not suitable for fishing and close to coast, between 50 and 1000 meters, where fishing vessels labor, and beyond 1000 meters as high sea. After pre-processing we have a time series for each ship, with regularized time-steps between observation, and new derived features indicating relative positions and movement, allowing us to compare ships for their positioning and maneuvering, independent of the origin port or coastal point, even from length of some pattern repetitions. The final features, from now on called original features, used for training the CRBM and for comparison in the experiments are the following: •Ship ID: IMO and MMSI number •Ship type •Relative GPS rotation •Speed over Ground •Bathymetry as a 3 value categorical variable: coast, sea and high sea In Section 6.4.2 IHS dataset is used for that particular task along with the previously defined data. 76 ▶CHAP. 6 IMPROVING EMISSION ESTIMATIONS ON MISSING DATA FIGURE 6.5. Example of status classification by clustering, on a trawling ship. Visualization tool at http://patrons.bsc.es. speed); Cluster 5 is split between moving, fishing or moored, but by visualization we observed that those labeled as 5 are actually sailing towards fishing positions or returning to port. As fishing vessels usually set their NavStatus to “engaged in fishing” always, even when sailing or moored, we can determine their “real” status with this classification. Also, for those without status (“undefined”), we can use the assigned cluster label as expected status, and applying approximate NavStatus labels by using the majority label for each cluster: indicating as “moored” if Cluster classifies it as 2, “under way using engine” if Cluster is 3 or 5, “moored OR slow fishing” if cluster is 4. Even though the correlation of these clusters with the NavStatus is not clear, we can identify new latent behaviors. As an example, we can identify patterns for ships performing trawling, not present in other fishing ships, cargos and passenger boats. In this example, shown in Figure 6.5, we can identify a first cluster (n.2) indicating the maneuvering in port and when shifting trajectories before and after trawling; two clusters (n.3 and n.4) identifying the movements during trawling, slower that regular sailing, that potentially can consume more energy thus more emissions, as they are trawling fishing nets; then a cluster (n.5) for ships speeding towards or from the fishing regions and the port. For this identification pattern exercise, the validation has been done by expert visual recognition of ship movement traces and location according to port maps [ 125 ], and by identifying the vessels registry indicating whether they possessed trawling equipment on board. In future research this extra status found may be used in new emission models. Finally, this approach shows potential to be applied in other contexts for uncovering behaviors, e.g. analyzing patterns on road traffic mining or other kind of data-set containing GPS. 6.5 CONCLUSIONS Computing the pollutant emissions from maritime traffic is an important issue for coastal cities air quality, as indicated by research in environmental sciences, also a major concern for world governments and global health organizations. Current state of the art techniques to model those emissions are based on processing AIS data, from ships traces, to complement large air quality simulations currently performed in supercomputing centers. The principal problem comes when usually that data is incomplete or incorrect for a large amount of vessels. In this chapter we presented a methodology for enhancing AIS data-sets by correcting and expanding its features, towards producing better estimations when using the latest emission models. 6.5 CONCLUSIONS ◀77 Our proposed methods focus on using CRBM s to boost prediction and clustering algorithms, used for complete crucial missing data required for producing those estimations. Experiments show that ship type and navigational status may be corrected on missing data scenarios. Moreover, they show that navigational status can be expanded with new uncovered behaviors. Finally, Experiments have proved that our method is able to estimate emissions than those proposed by the current emission models, detecting around 45% of the usually undetected emissions when the required features are not available. As the CRBM architecture and the pipelines are computationally light, it is possible to use them along with the Chapter 4contribution, the distributed ML system. It provides the near-realtime system with online missing data correction, along with an inferencing process containing the Chapter 5 contribution, so that the emission estimation process can be performed with more accuracy. F Part III EPILOGUE 79 CHAPTER 7 Conclusions and Future Work 7.1 CONCLUSIONS This thesis has aimed to explore the possibilities of Fog computing systems with Machine Learning to enable near-realtime analytics and data processing. This aim was described with the following thesis: It is possible to build a distributed system in a Fog computing environment to apply complex data processes (i.e. improve data fitness for use, estimate emissions and predict future values) in a Smart City setting with results in a near-realtime fashion. Figure 7.1 shows how this thesis is explored. The first contribution provides a framework to address Data Science problems in a distributed environment like the one presented. This framework enables to do complex computations like ML or emission estimation where the data is being produced, i.e., the Edge. In it we saw how to adapt the Data Science pipeline in a Fog computing environment, also called the Edge-Cloud continuum. This kind of architecture can be effectively applied to IoT problems. It is shown that Federated Learning ( FL ) is fitting for this setting and proven that it works for predicting road traffic. From this point, we are able to distribute computing at the Edge and build centralized models by training models locally and then merging them. This approach has the advantage that the data does not leave Edge, reducing network usage and increasing privacy. The other two contributions work towards improving the fitness of the data received and estimating emissions with the improved data, i.e. addressing the data preparation step. These two contributions can be seen from the pure Data Science point of view. In this sense, both contributions address correcting data from different starting points. If the whole system is used, the users are able to improve the fitness for use of data, predict future outcomes, and perform other processes like emission estimation at the Edge. The first functionality (contribution 1) enables knowing the status of the city and the status that we will have in the short term so that the monitoring agencies can act accordingly. The second functionality (contributions 2 and 3) helps to correct the incoming AIS and the registry data, as both sensor data and human input data can be error-prone. Without correct data, it is not possible to produce correct derived information like predictions or emission estimation. The more uncertainty we have in our data, the bigger the uncertainty we will have in the derived results, and errors will increase producing a snowball effect. The three contributions of this thesis not only propose techniques, solutions, and challenges that may be found to start building a system that can manage the incoming data in an IoT/Fog computing scenario but are also interesting for other data systems and architectures. This system is able to gather, correct, and make use of data where it is produced. Compared to a classic Cloud-based system, this approach provides lower latency and distributes the computational requirements. In the following sections, the conclusions for each contribution will be summarized, final remarks about the overall contribution will be given and future work will be described. 7.1.1 Contribution 1: Machine Learning distribution for traffic prediction The first contribution explored the possibility of using ML in a distributed system setting and how can we set up a Data Science pipeline in this kind of environment. When we speak about ML is not 81 82 ▶CHAP. 7 CONCLUSIONS AND FUTURE WORK FIGURE 7.1. Thesis contribution interaction diagram. Contribution 1 offers an architectural framework for distributed ML that can be used in the other two contributions. uncommon to think about a centralized application that learns from all the data available. However, this may not be the best approach for all the different scenarios. In previous works we explored the concept of local models and training local models and merging them [ 21 , 100 ], however, in this work we went a step further. Whenever acentral modelis required, Federated Learning ( FL )approachcan beused. FL framework provides a mechanism to train models locally and then merge them by a central authority. With this approach, we can avoid network failures, as the models are trained and used locally. When a network failure occurs, the Edge node can remain independently trained and using the current model it has and when the network is again available it can be synchronized again. Also, the network bandwidth usage is reduced, as only the models are sent through the network. The data, if not required to be saved completely or in aggregations, stays in the Edge node. In a mixed setting, we can train with the finer granularity data and report aggregations to the central node. Even though the model in a global sense has not seen all the data, the local models do. Merging models provide a model comparable to a centralized model trained with all the data and, in some cases, this model is better than the original due to the regularizing effect of the merging [ 113 ]. In this contribution, a brief guideline on how to select the hyper-parameters was provided to have a successful FL training process, especially for the number of epochs and training rounds. The approach was also tested with two low-powered devices and a Xeon machine. The two low-powered devices produced good enough results in a reasonable time for this scenario, confirming the viability of the approach in resource-constrained Edge nodes. The GPU -enabled low-powered device performance was lower than the CPU -based one as the overhead of transferring the data from RAM to video RAM was higher than the performance using the GPU . This may not be the case for other workloads as, for instance, the image data workloads could perform better in this kind of device. This is due to the number of operations and the amount of data is managed at each CPU/GPU operation. 7.1.2 Contribution 2: Estimating missing data for emission modeling Chapter 5provided a review of methods to estimate ship missing registry data, a comparative analysis of these methods and standard machine learning methods, the variable importance for each attribute to be fixed, and a guideline on how to fix this kind of data. This chapter provided a key element to enable the emission estimation process in general, as incorrect data lead to incorrect estimations. This contribution wanted to fill the gap between the different proposed methods for the ship registry data and the practitioners, establishing a fair comparison of the 7.1 CONCLUSIONS ◀83 methods. Moreover, with models that enable knowing the variable importance to predict the other variables, a table of variable relevance is given. With this, practitioners will know which variables are good to start with for doing this process. Because of the high availability of the ML algorithms used, implementation in their systems will be easy enough to have at least a baseline running in a short period of time. As these methods are also fast to produce outputs if they have a favorable configuration, we can utilize them in low-powered edge devices instead of in the backend, correcting erroneous data locally. Finally, as the study is done departing from using all the variables available to using only one variable, a multi-tier prediction method can be built using different models regarding which data is available and correct. Notice that this contribution can be located both in the Edge and Cloud in the final system. However, as the data records are highly static, it is more suitable for the Cloud. 7.1.3 Contribution 3: Feature extraction and missing data estimation from alternative data sources Chapter 6showed how to build new features from an available time series. In particular, from ship trajectories, movement patterns are extracted by grouping codes derived from available data time windows. These patterns are considered the behaviors of the ships at each time point. These patterns were used to predict the type of ship, generate a new variable related to the navigational status of the ship, and to predict the main engine. Even though this contribution is exploratory, it provides useful results for the emission estimation process. This method can be used when no registry data is available. It can be used as part of a methodology along with the processes discussed in Chapter 5to provide a complete missing data estimation solution that considers the availability of data for each ship (from no data available to one missing field). Considering that this approach is based on the one used in Chapter 4, this methodology is well fitted for Fog computing settings. Regarding the application for emission estimation, the method showed that it can outperform the general assumptions when ship registry data is not available. Even if the complete method is not used, using the ship traces to estimate the engine power is better than assuming the average of engine power for the ship type. With the full methodology, we were able to estimate 45% more pollution. Given the variability of the main engine attribute, it is difficult to estimate it with a high level of accuracy. However, this method is a good start towards this task. A final remark about this approach is that with these new uncovered behaviors we may be able to generate a new more refined Navigational Status value that has a finer granularity than the one already available in the AIS data. In particular, most of the fishing ships emit the Engaged in fishing even though they may be hoteling at the port. With this new variable, we can see what these kinds of ships are doing. Finally, with respect to the Fog architecture, this data preparation process is well suited to run in the Edge as the input data is the AIS data which comes in streams directly from the ships. 7.1.4 Overall conclusions The three contributions work in different directions towards the same objective: providing a suitable framework and techniques to build a near-realtime system with error correction, forecasting capabilities, and feature generation. In a system like this, the fitness for use of data is relevant as derived information will carry the original errors and even multiply them, losing then accuracy. Therefore these contributions have to be understood holistically having two parts: A way to distribute computing with Fog computing (Computer Architectures) and a way to adapt the data processing pipeline to this environment with a special focus on data preparation (Data Science). From the user perspective, policymakers like the city councils need to have actionable knowledge to properly address the city issues. Forecasting provides them with a glimpse of a possible future so that 84 ▶CHAP. 7 CONCLUSIONS AND FUTURE WORK they can act accordingly in the short term. Nevertheless, this is not only useful for policymakers, as the companies maintaining the infrastructure may also benefit from this capability, e.g. predicting when a device or the network is going to fail and deploying countermeasures. Finally, the feature generation procedure enables the development of new markers that can be useful to generate new information or to refine the actual data that the system has. This can help provide extra information for future tasks that the system tenant may have. These functionalities were tested in a low-powered device distributed system with network fault tolerance, mimicking a realistic system that may be available in the real world. This work provided an analysis of alternative ways to make use of distributed ML and its application in data preparation. The capabilities were evaluated with two real use cases: road and ship traffic. In particular, for ship traffic, there was an emphasis on correctly evaluating the data to provide good exhaust emission estimation. Both use cases were satisfied by the proposed methods and architecture. The data preparation processes produceddataensuringthatisfitfortheapplication, enablingtheuseoftheapplication. Moreover, when there is no ship registry data these approaches provided a better solution than the standard methods leading to the detection a 45% more of the undetected pollution. Considering what is mentioned before, this thesis offers a framework, references, ideas, and details on how to build a system that can clean data, estimate emissions and predict the future status of the city in a data-centric approach. Finally, the thesis has opened collaborations inside the Barcelona Supercomputer Center between Computer Sciences and Earth Sciences departments. Moreover, it has also opened collaborations with the Spanish Port Authorities, University of Padua, the Punjab University, and the company NearbyComputing, where a patent extracted from this work is currently in industrial use. The emission estimation module produced for this thesis has been used effectively in the FemIoT project (SIFECAT/RIS3CAT 001-P-00166). The research on FL has been a starting point to important architectural contributions in the INCISIVE and CALLISTO EU2020 Horizon projects (grant agreement No.952179 and No.101004152), in which our expertise in FL is being used for medical and satellite data security and privacy. 7.2 FUTURE WORK This work has also its limitations, especially due to time constraints. This section covers possible future lines of research and the application of this thesis. Complete system integration Even though the emission estimation pipeline is completely implemented, the work done has been performed in an experimental setting. A possible future line of research would be to gather all the knowledge contributed to this thesis and build the complete near-realtime system in real edge nodes distributed in the city or different places on the coast of Spain. We made a Raspberry Pi-based edge device with AIS gathering capabilities which were used for experimental data gathering, therefore it is possible to make such a device and create a network as described in this thesis. Moreover, in a real environment, the failures, in general, must be taken into account. Sensor failures can be addressed using the defined ML at the edge nodes and network errors are also regarded in the present work. However, other ways to mitigate errors can be devised, e.g. node redundancy at the edge. Ship emission estimation In this work STEAM [ 1 ] and STEAM2 [ 16 ] were implemented. Also, considerations from other methodologies like HERMESv3 [ 25 ] or NAEI emission inventory [ 95 ] were included. However, to provide a reliable system more effort should be done in this direction regarding the evaluation of the estimated pollutants Moreover, Chapter 5work can be expanded to cover more ship-related variables. In particular, it needs to evaluate the usage of the deadweight variable as used in the Fourth Greenhouse Gas study performed by the IMO [ 97 ]. In terms of emission estimation methodology, STEAM2 [ 16 ] makes use of a bigger amount of input variables to produce better emission estimations. These variables should be verified as this work does with the ones from STEAM. Even though STEAM is the default backup method for STEAM2 when there is data missing, it is interesting 7.2 FUTURE WORK ◀85 to apply the methodology to the missing variables so that STEAM2 can be used. Finally, as the corrected data is going to be used in further data processes, e.g. emission estimation, an uncertainty measure could be provided for each prediction so that each estimation has an error margin. This would enable users to evaluate how trustable are the derived values. Concept drift In the development and execution of such a system, new questions should be addressed. For example, this kind of temporal data is sensitive to concept drift as mentioned in the work of Bifet [ 106 ]. Therefore, this should be studied and addressed by building policies on how and when to update both local models and federated models. Minimization of power Even though the present work explores the usage of low-powered computing resources, in extreme cases we may be required to have devices that consume even less electric power. There is a new interesting trend in the ML area towards using MCU s to perform predictive tasks, e.g. TinyML [ 58 ]. Even though there are already systems that can learn from the data in these devices, there is no work to our knowledge that makes use of FL along with several devices. Further exploration of Federated Learning and Swarm Learning Federated Learning ( FL ) provides a framework in which learning tasks can be done where the data is produced and without it leaving the system. This reduces avoids sending the data over the network and enables using learning methods with privacy in multi-tenant environments. However, in this work, we have applied the most basic way of merging the learning models. In the work of Li et al. [ 110 ] they propose a regression/classification tree-based approach that can establish weights for each local model to be merged. As can be seen in the work of Perez et al. [ 100 ], local models may be better fitted to their region because each region may have a different data distribution behind. Regarding this, we may be able to build a set of centralized models that take into account these distributions but remain general enough to predict bigger areas or use models like Graph NN that can take into account this kind of relationship between the data and their position. On the other hand, using similar ideas to the ones found in the work of Li et al. [ 110 ], Warnat et al. [ 127 ] propose the Swarm Learning framework. This framework is similar to the FL framework but the synchronization mechanism is not centralized and it happens in each node. This way in case of losing back-haul connectivity, the devices that remain connected between them may keep collaborating in their learning task independently. A-6 ▶APPENDIX A SUPPLEMENTARY INFORMATION FOR CHAPTER 4 𝑅2RMSE MAE Target Algorithm Train Test Train Test Train Test Beam RF 0.0005 0.0011 -0.0506 -0.0611 -0.0313 -0.0613 (Length, Design Speed) XGBoost 0.0015 0.0013 -0.2103 -0.0700 -0.1832 -0.1047 KNN 0.0006 0.0037 -0.0314 -0.1820 -0.0249 -0.0825 1_nnet 0.0229 0.0230 -0.6475 -0.6464 -0.5835 -0.5942 2_nnet 0.0146 0.0160 -0.3869 -0.4239 -0.3212 -0.3688 LM 0.0265 0.0266 -0.6544 -0.6594 -0.5671 -0.5682 Design Speed XGBoost 0.0277 0.0269 -0.3309 -0.2082 -0.2798 -0.1867 (ME Power, Draft) RF 0.0220 0.0280 -0.3925 -0.2078 -0.2702 -0.1159 1_nnet 0.0275 0.0188 -0.1666 -0.1141 -0.1400 -0.1628 KNN -0.0264 0.0180 0.1742 -0.1081 0.2326 0.0070 2_nnet 0.0531 0.0028 -0.3302 -0.0164 -0.3661 -0.1452 LM 0.2033 0.1944 -0.8699 -0.8490 -0.8367 -0.8152 AE Power RF 0.0004 -0.0009 -4.9752 5.2422 -8.7550 -16.7539 (ME Power, Beam) XGBoost -0.0151 0.0051 237.2241 -27.9569 250.9958 43.4501 KNN 0.0001 0.0001 -0.8868 -0.4871 -2.3689 -2.3310 1_nnet 0.0412 0.0283 -184.2369 -130.9249 -146.6328 -108.9719 2_nnet -0.0136 -0.0079 54.4307 33.6192 82.1859 49.9145 LM 0.0392 0.0386 -146.7625 -154.7597 -82.0153 -103.5795 ME Power RF -0.0011 -0.0012 150.1328 73.8664 248.2645 137.4452 (Length, Design Speed) XGBoost 0.0016 -0.0003 -381.3468 18.2249 -276.7815 -62.3720 KNN 0.0003 0.0003 -22.3113 -17.6821 -36.3525 -53.4362 2_nnet 0.0143 0.0090 -666.4766 -427.7605 -303.5019 -159.7036 1_nnet 0.0127 0.0099 -576.0113 -466.4431 -283.3240 -190.4030 LM 0.0734 0.0722 -1651.9714 -1671.6840 -1331.5225 -1394.5369 Length RF 0.0019 0.0062 -1.4683 -2.2352 -0.8114 -0.9614 (Beam, ME Power) XGBoost 0.0069 0.0097 -3.5487 -3.0396 -3.3472 -3.1494 1_nnet 0.0105 0.0099 -2.3676 -2.2438 -1.4518 -1.4262 2_nnet 0.0135 0.0137 -2.9168 -2.9703 -1.9030 -2.0084 LM 0.0136 0.0151 -2.7539 -3.0579 -2.0267 -2.1668 KNN 0.0001 -0.0001 -0.0283 0.0171 -0.0590 0.0124 ME RPM RF 0.0115 0.0253 -29.7687 -16.9290 -11.2778 -7.2151 (Draft, ME Power) XGBoost -0.0049 0.0297 9.7729 -19.6946 0.5686 -6.1110 2_nnet 0.0409 0.0302 -28.2491 -19.7805 -16.2814 -10.8410 1_nnet 0.0379 0.0263 -25.6869 -16.8007 -18.3823 -13.8981 KNN 0.0107 0.2162 -6.7456 -99.9706 52.4929 1.3610 LM 0.2386 0.0031 -111.4247 -1.1652 -135.4681 -71.9654 Draft RF 0.0068 0.0259 -0.1616 -0.3174 -0.0728 -0.1559 (Beam, Length) XGBoost 0.0092 0.0251 -0.2393 -0.2967 -0.1553 -0.1761 KNN 0.0061 0.0299 -0.0668 -0.2749 0.0995 -0.0221 2_nnet 0.0751 0.0827 -0.5846 -0.6162 -0.4035 -0.4243 1_nnet 0.0785 0.0678 -0.6115 -0.4578 -0.5593 -0.4689 LM 0.0692 0.0768 -0.4575 -0.4900 -0.3315 -0.3574 TABLE A.3. Difference of error when adding type variable as a predictor with respect to Table 5.4. The variables used to predict (excluding type which is used in every experiment) are written below the variable to predict. Increase in 𝑅2and decrease in RMSE and MAE means better fit. Ordered by test 𝑅2. APPENDIX A SUPPLEMENTARY INFORMATION FOR CHAPTER 4◀A-7 𝑅2RMSE MAE Target Algorithm Train Test Train Test Train Test Beam XGBoost 0.9868 0.9744 1.2264 1.7085 0.8013 1.0654 (Length) RF 0.9805 0.9727 1.4892 1.7648 0.9385 1.1449 KNN 0.9785 0.9721 1.5636 1.7839 0.8181 1.0666 2_nnet 0.9166 0.9154 3.0818 3.1067 2.2648 2.2795 1_nnet 0.9109 0.9120 3.1856 3.1693 2.2747 2.2939 LM 0.9001 0.9006 3.3731 3.3675 2.4921 2.4923 Design Speed XGBoost 0.8695 0.8574 1.4473 1.5057 0.9991 1.0932 (ME Power) KNN 0.8922 0.8561 1.3157 1.5125 0.7975 0.9997 RF 0.8853 0.8495 1.3572 1.5467 0.8984 1.0560 1_nnet 0.7529 0.7831 1.9919 1.8567 1.4820 1.4357 2_nnet 0.7359 0.7678 2.0593 1.9211 1.5473 1.4991 LM 0.6616 0.6813 2.3309 2.2508 1.8127 1.7850 AE Power XGBoost 0.9026 0.8624 1119.2508 1369.8897 651.3921 713.7344 (ME Power) KNN 0.8767 0.8505 1259.3877 1427.8572 611.7369 707.7976 RF 0.9158 0.8330 1040.4658 1508.7723 576.0408 728.9788 1_nnet 0.7504 0.7645 1791.5748 1791.8935 978.9485 975.6295 LM 0.7432 0.7585 1817.1219 1814.8075 1000.7697 1007.3105 2_nnet 0.7431 0.7582 1817.5333 1815.7456 1006.2254 1013.1059 ME Power KNN 0.9665 0.9537 3070.5436 3742.5165 1407.5615 1874.7986 (Length) XGBoost 0.9693 0.9517 2937.0998 3819.8798 1682.1618 2032.9765 RF 0.9745 0.9517 2675.5138 3820.3715 1473.3089 1941.0761 1_nnet 0.8564 0.8730 6353.7081 6195.3436 3889.8189 3849.9655 2_nnet 0.8566 0.8729 6348.0268 6198.7748 3786.8094 3753.9687 LM 0.7103 0.7116 9023.7655 9336.1202 6694.5049 6891.3160 Length XGBoost 0.9559 0.9473 15.8575 17.5739 9.8878 10.9411 (Beam) RF 0.9553 0.9471 15.9653 17.6154 9.9571 11.0681 KNN 0.9335 0.9288 19.4619 20.4260 10.2588 10.9091 LM 0.9001 0.9006 23.8586 24.1373 17.5235 17.8596 1_nnet 0.8995 0.9004 23.9278 24.1684 17.6645 17.9829 2_nnet 0.9001 0.9002 23.8561 24.1844 17.5174 17.8817 ME RPM 1_nnet 0.8671 0.8622 167.5842 168.3189 96.4330 95.5028 (Draft) RF 0.9073 0.8597 139.9690 169.8230 78.0129 89.9753 2_nnet 0.8648 0.8576 169.0427 171.0586 99.3597 97.5212 XGBoost 0.9206 0.8570 129.5553 171.4625 70.7456 89.7742 KNN 0.9203 0.8434 129.8078 179.4019 61.9109 87.0557 LM 0.6123 0.6262 286.2200 277.1728 205.7639 197.9765 Draft RF 0.9367 0.9216 0.9344 1.0391 0.6337 0.7072 (Beam) XGBoost 0.9345 0.9211 0.9510 1.0420 0.6555 0.7124 KNN 0.9241 0.9123 1.0232 1.0991 0.6926 0.7264 1_nnet 0.8933 0.8879 1.2133 1.2421 0.8778 0.9168 2_nnet 0.8906 0.8840 1.2285 1.2636 0.9186 0.9569 LM 0.8820 0.8727 1.2761 1.3237 0.9733 1.0181 TABLE A.4. Error measures for training and test for the target variable. The variable used to predict is written below the variable to predict. Predicted only with the most relevant variable. Ordered by test 𝑅2. A-8 ▶APPENDIX A SUPPLEMENTARY INFORMATION FOR CHAPTER 4 𝑅2RMSE MAE Target Algorithm Train Test Train Test Train Test Beam RF 0.9957 0.9842 0.6994 1.3413 0.3479 0.7555 XGBoost 0.9966 0.9823 0.6188 1.4219 0.3228 0.8451 3NN 0.9874 0.9823 1.1967 1.4226 0.5906 0.8152 1NN 0.9979 0.9805 0.4920 1.4902 0.0512 0.6413 MSV 0.9973 0.9730 0.5527 1.7562 0.0598 0.7836 1_nnet 0.9505 0.9496 2.3753 2.3974 1.7842 1.8258 2_nnet 0.9493 0.9476 2.4039 2.4455 1.8259 1.8725 LM 0.9121 0.9124 3.1644 3.1621 2.4926 2.4942 AE Power RF 0.9729 0.8890 590.2442 1230.4580 281.1902 580.1873 XGBoost 0.9679 0.8847 642.5920 1253.9018 314.9681 597.1411 1NN 0.9848 0.8825 441.6284 1265.9871 83.2525 541.7500 3NN 0.9292 0.8789 953.9023 1285.2560 449.6223 632.9286 MSV 0.9886 0.8669 382.5517 1347.0451 75.5772 554.3957 1_nnet 0.8093 0.8194 1565.8429 1569.1679 838.8283 823.0631 2_nnet 0.7985 0.8089 1609.7925 1614.1963 888.2305 853.7966 LM 0.6904 0.7046 1995.3682 2006.9952 1293.5314 1261.6120 ME Power RF 0.9963 0.9799 1025.3560 2465.9112 428.6885 978.8303 3NN 0.9871 0.9755 1901.8463 2721.2939 768.5421 1143.6786 XGBoost 0.9889 0.9749 1765.0277 2755.9600 1071.7574 1360.7880 1NN 0.9995 0.9717 368.2261 2927.1558 77.7506 963.1471 MSV 0.9995 0.9710 365.3108 2963.1109 71.6225 1041.1629 1_nnet 0.9607 0.9612 3323.5682 3426.6575 1716.1289 1813.7950 2_nnet 0.9601 0.9609 3350.3343 3439.1123 1756.7301 1868.6926 LM 0.8222 0.8208 7068.9221 7360.7513 5446.5547 5667.8594 ME RPM XGBoost 0.9742 0.8710 73.7837 162.8481 36.6714 82.0743 RF 0.9759 0.8700 71.3819 163.4616 38.1288 83.3670 3NN 0.9297 0.8557 121.8638 172.2444 59.0172 91.1690 1_nnet 0.8302 0.8307 189.4050 186.5293 113.5908 110.3079 2_nnet 0.8213 0.8289 194.3407 187.5346 113.9136 111.6540 1NN 0.9963 0.8223 28.0424 191.1055 3.0852 75.2486 MSV 0.9957 0.7816 30.0128 211.8606 3.5080 85.6100 LM 0.5209 0.5222 318.1662 313.3820 241.4797 236.8057 Draft RF 0.9890 0.9541 0.3890 0.7946 0.2411 0.4687 1NN 0.9963 0.9486 0.2264 0.8413 0.0377 0.3893 3NN 0.9670 0.9410 0.6747 0.9009 0.3497 0.5210 XGBoost 0.9553 0.9331 0.7857 0.9594 0.5346 0.6618 MSV 0.9970 0.9311 0.2029 0.9740 0.0325 0.4515 1_nnet 0.9275 0.9192 1.0004 1.0547 0.6880 0.7527 2_nnet 0.9251 0.9155 1.0168 1.0789 0.7119 0.7880 LM 0.8658 0.8531 1.3607 1.4220 1.0250 1.0796 TABLE A.5. Comparison of the best algorithms found, KNN and MSV. Ordered by test 𝑅2. 𝑅2RMSE MAE Target Algorithm Train Test Train Test Train Test ME Power RF 0.9787 0.9307 2444.9302 4576.5184 951.1324 2006.6138 (Length*Beam) XGBoost 0.9485 0.9257 3803.4448 4739.4473 2081.3133 2576.2111 KNN 0.9485 0.9156 3805.4634 5052.3433 1482.7439 2236.7024 1_nnet 0.7253 0.7497 8786.1284 8699.0627 5153.0976 5164.2718 2_nnet 0.7251 0.7480 8789.1669 8728.6609 5179.9932 5202.7271 poly2 0.7225 0.7473 8831.9435 8740.2747 5310.2186 5273.8748 LM 0.7017 0.7180 9155.9720 9232.4103 6155.3972 6231.0306 AE Power RF 0.9934 0.9699 1360.2618 3015.9177 627.2374 1302.5491 (Length, Beam) XGBoost 0.9917 0.9648 1523.9397 3262.3938 942.4226 1515.6529 KNN 0.9810 0.9630 2308.7373 3343.5428 1083.6797 1572.7905 2_nnet 0.9197 0.9269 4749.8280 4700.3711 2961.2582 3018.5387 1_nnet 0.9193 0.9210 4762.0252 4888.1198 2896.2361 3046.5558 poly2 0.8995 0.9008 5315.7676 5474.9995 3124.0154 3245.4752 LM 0.7924 0.7847 7637.8210 8067.4960 5432.4080 5712.9536 TABLE A.6. Installed power main engine predicted with Length*Beam and (Length and Beam). Ordered by test 𝑅2. A.3 GLOSSARY ◀M-1 A.3 GLOSSARY AE Auxiliary Engine ........................................ 24 AIS Automatic Identification System ............................... 5 AQMS Air Quality Modelling Systems .............................. 14 BSC Barcelona Supercomputing Center .............................. 4 BS Batch Size ............................................ 48 CALIOPE CALIdad del aire Operacional Para España ...................... 4 CNN Convolutional Neural Network ............................... 28 CPU Central Processing Unit ................................... 28 CRBM Conditional Restricted Boltzmann Machine ....................... 9 CoG Course over Ground ..................................... 23 EIONET European Environment Information and Observation NETwork ........... 4 FCD Floating Car Data ....................................... 20 FL Federated Learning ....................................... 7 GB-RBM Gaussian Bernoulli RBM ................................ 11 GPS Global Positioning System .................................. 4 GPU Graphics Processing Unit .................................. 8 GRU Gated Recurrent Unit .................................... 8 GT Gross Tonnage ......................................... 5 M-2 ▶APPENDIX A SUPPLEMENTARY INFORMATION FOR CHAPTER 4 HERMES High-Elective Resolution Modelling Emission System ................ 4 HPC High Performance Computing ................................ 29 IID Independent and Identically Distributed ........................... 42 IMO International Maritime Organization ............................ 5 IoT Internet of Things ....................................... 3 KNN 𝑘Nearest Neighbors ..................................... 31 MAE Mean Absolute Error ..................................... 57 MCU MicroController Unit .................................... 8 ME Main Engine .......................................... 24 MLP Multi-Layer Perceptron ................................... 55 ML Machine Learning ....................................... 3 MMSI Maritime Mobile Service Identity ............................. 15 MSE Mean Squared Error ..................................... 31 MSV Most Similar Vessel ...................................... 31 NAEI National Atmospheric Emissions Inventory ........................ 31 NN Neural Network ........................................ 28 PM Particulate Matter ....................................... 4 RBM Restricted Boltzmann Machine ............................... 11 RF Random Forest ......................................... 56 A.3 GLOSSARY ◀M-3 RMSE Root Mean Squared Error ................................. 45 RNN Recurrent Neural Network ................................. 13 RPM Revolutions Per Minute ................................... 17 SFOC Specific Fuel-Oil Consumption ............................... 16 STEAM Ship Traffic Emission Assesment Model ......................... 15 STEMI ST Elevation Myocardial Infarction ........................... 4 SoG Speed over Ground ...................................... 22 SWA Stochastic Weight Averaging ................................. 42 VAR Vector Auto-Regression ................................... 43 VHF Very High Frecuency ..................................... 15 Bibliography [1] J.-P. Jalkanen, a. Brink, J. Kalli, H. Pettersson, J. Kukkonen, and T. Stipa. A modelling system for the exhaust emissions of marine traffic and its application in the Baltic Sea area. Atmospheric Chemistry and Physics Discussions 9 (4), 15339–15373 (2009). ISSN 1680-7375. doi: 10.5194/acpd-9-15339-2009. Cited on page/s xv,5,8,15,16,17,18,20,29,30,31,51,52,57,67,68,69,71,72,73,74,84. [2] Miyeon Jeon, Yoojeong Noh, Kyunghwan Jeon, Sangbong Lee, and Inwon Lee. Data gap analysis of ship and maritime data using meta learning. Applied Soft Computing 101, 107048 (2021). Cited on page/s xvii,8,31,53,54. [3] Xin Peng, Yuanqiao Wen, Lichuan Wu, Changshi Xiao, Chunhui Zhou, and Dong Han. A sampling method for calculating regional ship emission inventories. Transportation Research Part D: Transport and Environment 89, 102617 (2020). Cited on page/s xix,6,30,51,52,54. [4] Liang Huang, Yuanqiao Wen, Yimeng Zhang, Chunhui Zhou, Fan Zhang, and Tiantian Yang. Dynamic calculation of ship exhaust emissions based on real-time ais data. Transportation Research Part D: Transport and Environment 80, 102277 (2020). Cited on page/s xix,30,31,51,52,54,63,64. [5] Frank Van Lingen, et al. The Unavoidable Convergence of NFV, 5G, and Fog: A Model-Driven Approach to Bridge Cloud and Edge. IEEE Communications Magazine 55 (8), 28–35 (2017). ISSN 01636804. doi: 10.1109/MCOM.2017.1600907. Cited on page/s 3. [6] Natalie Mueller, David Rojas-Rueda, Xavier Basagaña, Marta Cirach, Tom Cole-Hunter, Payam Dadvand, David Donaire-Gonzalez, Maria Foraster, Mireia Gascon, and David Martinez. Urban and transport planning related exposures and mortality: a health impact assessment for cities. Environ Health Perspect 125, 89–96 (2017). Cited on page/s 3. [7] Jordi Bañeras, Ignacio Ferreira-González, Josep Ramon Marsal, José A. Barrabés, Aida Ribera, Rosa Maria Lidón, Enric Domingo, Gerard Martí, and David García-Dorado. Short-term exposure to air pollutants increases the risk of ST elevation myocardial infarction and of infarctrelated ventricular arrhythmias and mortality. International Journal of Cardiology 250, 35–42 (2018). ISSN 18741754. doi: 10.1016/j.ijcard.2017.10.004. URL https://doi.org/10.1016/j.ijcard. 2017.10.004.Cited on page/s 3. [8] A. Soret, M. Guevara, and J.M. Baldasano. The potential impacts of electric vehicles on air quality in the urban areas of barcelona and madrid (spain). Atmospheric Environment 99, 51 – 63 (2014). ISSN 1352-2310. doi: http://dx.doi.org/10.1016/j.atmosenv.2014.09.048. Cited on page/s 4. [9] M. Guevara, F. Martínez, G. Arevalo, S. Gasso, and J. Baldasano. An improved system for modelling spanish emissions: Hermesv2.0. Atmospheric environment 81, 209–221 (Dec 2013). doi: 10.1016/j.atmosenv.2013.08.053. Cited on page/s 4. [10] Ajuntament de Barcelona. Pla de millora de la qualitat de l’aire de barcelona 2015-2018 (2015). URL http://hdl.handle.net/11703/83944.Cited on page/s 4. M-5 M-6 ▶BIBLIOGRAPHY [11] European Community Shipowners Associations (ECSA). The economic value of the eu shipping industry. update (February 2015). Cited on page/s 5,51,67. [12] Tristan Smith et al. Third imo greenhouse gas study (2014). Cited on page/s 5,67. [13] Francesco Di Natale and Claudia Carotenuto. Particulate matter in marine diesel engines exhausts: Emissions and control strategies. Transportation Research Part D: Transport and Environment 40, 166 – 191 (2015). ISSN 1361-9209. doi: http://dx.doi.org/10.1016/j.trd.2015.08.011. Cited on page/s 5,67. [14] Mar Viana, Pieter Hammingh, Augustin Colette, Xavier Querol, Bart Degraeuwe, Ina de Vlieger, and John van Aardenne. Impact of maritime transport emissions on coastal air quality in europe. Atmospheric Environment 90, 96 – 105 (2014). ISSN 1352-2310. doi: http://dx.doi.org/10.1016/j. atmosenv.2014.03.046. Cited on page/s 5,67. [15] Daniel Rodriguez-Rey, Marc Guevara, Ma Paz Linares, Josep Casanovas, Juan Salmerón, Albert Soret, Oriol Jorba, Carles Tena, and Carlos Pérez García-Pando. A coupled macroscopic traffic and pollutant emission modelling system for barcelona. Transportation Research Part D: Transport and Environment 92, 102725 (2021). Cited on page/s 5. [16] J.P. Jalkanen, L. Johansson, J.Kukkonen, A. Brink, J. Kalli, and T. Stipa. Extension of anassessment model of ship traffic exhaust emissions for particulate matter and carbon monoxide. Atmospheric Chemistry and Physics 12 (5),2641–2659(2012). ISSN16807316. doi: 10.5194/acp-12-2641-2012. Cited on page/s 5,8,15,16,17,19,23,51,52,53,65,67,68,73,74,84. [17] International Maritime Organization. Ais transponders (February 2017). Cited on page/s 5,15. [18] Abbas Harati-Mokhtari, Alan Wall, Philip Brooks, and Jin Wang. Automatic identification system (ais): data reliability and human error implications. The Journal of Navigation 60 (3), 373 (2007). Cited on page/s 5,29,51. [19] Laurie Goldsworthy and Brett Goldsworthy. Modelling of ship engine exhaust emissions in ports and extensive coastal waters based on terrestrial ais data–an australian case study. Environmental Modelling & Software 63, 45–60 (2015). Cited on page/s 5,30,31. [20] A. Miola, B. Ciuffo, E. Giovine, and M. Marra. Regulating air emissions from ships. the state of the art on methodologies, technologies and policy options. Joint Research Centre Reference Report, EUR24602EN, 978-92 (2010). Cited on page/s 6. [21] Alberto Gutierrez-Torre, Kiyana Bahadori, Shuja-ur-Rehman Baig, Waheed Iqbal, Tullio Vardanega, Josep Lluís Berral, and David Carrera. Automatic distributed deep learning using resource-constrained edge devices. IEEE Internet of Things Journal (2021). doi: https: //doi.org/10.1109/JIOT.2021.3098973. Cited on page/s 8,36,37,39,43,44,46,47,49,82. [22] Graham W. Taylor, Geoffrey E Hinton, and Sam T. Roweis. Modeling human motion using binary latent variables. In P. B. Schölkopf, J. C. Platt, and T. Hoffman, editors, Advances in Neural Information Processing Systems 19 pages 1345–1352. MIT Press (2007). Cited on page/s 11. [23] Kyunghyun Cho, Bart van Merrienboer, Caglar Gulcehre, Dzmitry Bahdanau, Fethi Bougares, Holger Schwenk, and Yoshua Bengio. Learning phrase representations using rnn encoderdecoder for statistical machine translation (2014). Cited on page/s 11. [24] Graham W. Taylor, Geoffrey E. Hinton, and Sam Roweis. Modeling human motion using binary latent variables. In Advances in Neural Information Processing Systems page 2007. MIT Press (2006). Cited on page/s 12,31. BIBLIOGRAPHY ◀M-7 [25] Marc Guevara, Carles Tena, Manuel Porquet, Oriol Jorba, and Carlos Pérez García-Pando. Hermesv3, a stand-alone multi-scale atmospheric emission modelling framework–part 1: global and regional module. Geoscientific Model Development 12 (5), 1885–1907 (2019). Cited on page/s 14,51,67,84. [26] Lasse Johansson, Jukka-Pekka Jalkanen, and Jaakko Kukkonen. Global assessment of shipping emissions in 2015 on a high spatial and temporal resolution. Atmospheric Environment 167, 403–415 (2017). Cited on page/s 15,31,51,55,62,63,65. [27] Amrapali Zaveri, Anisa Rula, Andrea Maurino, Ricardo Pietrobon, Jens Lehmann, and Soeren Auer. Quality assessment for linked data: A survey. Semantic Web 7(1), 63–93 (2016). Cited on page/s 25. [28] Barna Saha and Divesh Srivastava. Data quality: The other face of big data. In 2014 IEEE 30th international conference on data engineering pages 1294–1297. IEEE (2014). Cited on page/s 25. [29] Swarnava Dey, Ankur Chakraborty, Soumitra Naskar, and Prateep Misra. Smart city surveillance: Leveraging benefits of cloud data stores. In 37th Annual IEEE Conference on Local Computer Networks-Workshops pages 868–876. IEEE (2012). Cited on page/s 27. [30] Kehua Su, Jie Li, and Hongbo Fu. Smart city and the applications. In 2011 international conference on electronics, communications and control (ICECC) pages 1028–1031. IEEE (2011). Cited on page/s 27. [31] Miguel Castro, Antonio J Jara, and Antonio FG Skarmeta. Smart lighting solutions for smart cities. In 2013 27th International Conference on Advanced Information Networking and Applications Workshops pages 1374–1379. IEEE (2013). Cited on page/s 27. [32] A. Corsaro. Connected boulevard – it’s what makes nice, france, a smart city (September 2014). URL https://goo.gl/sFjCUq. "on-line; accessed in: 15-Nov-2017". Cited on page/s 27. [33] L. Sanchez, V. Gutierrez, J. A. Galache, P. Sotres, J. R. Santana, J. Casanueva, and L. Muñoz. Smartsantander: Experimentation and service provision in the smart city. In 16th International Symposium on Wireless Personal Multimedia Communications (WPMC) pages 1–6 (June 2013). Cited on page/s 27. [34] Technology Review. Cities get smarter (2015). URL https://goo.gl/fSd1mu. "on-line; accessed in: 15-Nov-2017". Cited on page/s 27. [35] Yu Chao Hu, Milan Patel, Dario Sabella, Nurlt Sprecher, and Valerie Young. Mobile edge computing: A key technology towards 5g, white paper, etsi (2015). URL https://goo.gl/Qx9W4k. "on-line; accessed in: 15-Nov-2017". Cited on page/s 27. [36] Shanhe Yi, Zijiang Hao, Qingyang Zhang, Quan Zhang, Weisong Shi, and Qun Li. Lavea: Latencyaware video analytics on edge computing platform. In Proceedings of the Second ACM/IEEE Symposium on Edge Computing. ACM (2017). Cited on page/s 27. [37] M. Yannuzzi, et al. A new era for cities with fog computing. IEEE Internet Computing 21 (2), 54–67 (Mar 2017). ISSN 1089-7801. doi: 10.1109/MIC.2017.25. Cited on page/s 27. [38] SHI Xingjian, Zhourong Chen, Hao Wang, Dit-Yan Yeung, Wai-Kin Wong, and Wang-chun Woo. Convolutional lstm network: A machine learning approach for precipitation nowcasting. In Advances in neural information processing systems pages 802–810 (2015). Cited on page/s 27. M-14 ▶BIBLIOGRAPHY [117] Tianqi Chen and Carlos Guestrin. XGBoost: A scalable tree boosting system. In Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining KDD ’16 pages 785–794 New York, NY, USA (2016). ACM. ISBN 978-1-4503-4232-2. doi: 10.1145/ 2939672.2939785. URL http://doi.acm.org/10.1145/2939672.2939785.Cited on page/s 56. [118] Jasper Snoek, Hugo Larochelle, and Ryan P Adams. Practical bayesian optimization of machine learning algorithms. arXiv preprint arXiv:1206.2944 (2012). Cited on page/s 57. [119] Sistema caliope, prediction of air quality (May 2019). URL http://www.bsc.es/caliope/es. Cited on page/s 67. [120] Albert Bifet and Ricard Gavalda. Learning from time-changing data with adaptive windowing. In Proceedings of the 2007 SIAM international conference on data mining pages 443–448. SIAM SIAM (2007). Cited on page/s 68. [121] Graham W. Taylor and Geoffrey E. Hinton. Factored conditional restricted Boltzmann Machines for modeling motion style. Proceedings of the 26th International Conference on Machine Learning (ICML 09) pages 1025–1032 (2009). ISSN 1520510X. doi: 10.1145/1553374.1553505. Cited on page/s 68. [122] Zoubin Ghahramani. Hidden markov models. In Hidden Markov Models: Applications in Computer Vision chapter An Introduction to Hidden Markov Models and Bayesian Networks, pages 9– 42. World Scientific Publishing Co., Inc. River Edge, NJ, USA (2002). ISBN 981-02-4564-5. Cited on page/s 68. [123] D. B. Prats, J. L. Berral, and D. Carrera. Automatic generation of workload profiles using unsupervisedlearningpipelines. IEEE Transactions on Network and Service Management 15 (1), 142– 155 (March 2018). ISSN 1932-4537. doi: 10.1109/TNSM.2017.2786047. Cited on page/s 68. [124] VesselFinder. Free AIS Ship Tracking of Marine Traffic (May 2019). URL http://www. vesselfinder.com.Cited on page/s 69. [125] Cepesca. El arrastre: El arte de la pesca sostenible (February 2017). Cited on page/s 69,76. [126] Ihs fairplay ship data base (May 2019). URL https://fairplay.ihs.com/.Cited on page/s 73. [127] Stefanie Warnat-Herresthal, et al. Swarm learning for decentralized and confidential clinical machine learning. Nature 594 (7862), 265–270 (2021). Cited on page/s 85.