scieee AI-readable full text Open interactive document viewer

Design and evaluation of a cognitive vehicle system: emphasizing user routine learning and interaction

Dias, Pedro Henrique Sampaio

Abstract

Driving a vehicle is often a routine activity that involves visiting the same places at roughly the same times on specific days of the week. Hence, personal vehicles typically transport the same occupants along with their specific items. Therefore, the development of cognitive/intelligent vehicles capable of learning and adapting to their occupants’ routines can assist drivers autonomously during their daily trips. This dissertation aims to develop an integrated system that allows extraction of stop locations from the user’s mobility information and learning of their respective spatio-temporal routines. The system comprises a User Interface/Authentication module, User Stop Location Extraction module, and a User Routine Learning Cognitive module. The User Stop Location Extraction module consists in a machine learning approach, incorporating clustering and artificial neural networks methods to identify and classify stop locations in a given user mobility dataset. This module interacts and supports an already existent User Routine Learning Cognitive module, based on Dynamic Neural Fields (DNFs), which is responsible for the implicit learning of various destinations and their associated time characteristics. Additionally, the Interface/Authentication module involves the development of a basic interface to aid in visualizing the resulting stop locations, provide basic User-Vehicle interaction with the system, and enable user authentication. Experiments conducted with real data regarding the routines of various vehicles have validated the newly developed modules and respective integration with cognitive module. The results notably highlighted the Stop Location Extraction module's particularly satisfactory performance in accurately identifying and classifying stop locations. This module also allows visualization of stop locations thus enhancing the interpretability of predictions generated by the cognitive module when compared to a prior Stop Location Extraction approach based on DNFs. However, despite the improved performance of the new Stop Location Extraction module, it did not necessarily translate into enhanced prediction accuracy by the cognitive module. The prediction errors occur in cases of exceptional, one-time deviations from routine behavior. In essence, this dissertation has contributed to further advance the research within Project BEN, specifically aiming to equip BEN vehicles with cognitive capabilities.

Full text

Universidade do Minho Escola de Engenharia Pedro Henrique Sampaio Dias Design and Evaluation of a Cognitive Vehicle System: Emphasizing User Routine Learning and Interaction January 2024 Design and Evaluation of a Cognitive Vehicle System: Emphasizing User Routine Learning and Interaction. Pedro Dias UMinho | 2024 Universidade do Minho Escola de Engenharia Pedro Henrique Sampaio Dias Design and Evaluation of a Cognitive Vehicle System: Emphasizing User Routine Learning and Interaction M aster’s Dissertation Master in Industrial Electronics and Computers Engineering Work developed under the supervision of: Professor Doctor Estela Bicho Doctor Flora Ferreira January 2024 i Direitos de Autor e Condições de Utilização do Trabalho por Terceiros Este é um trabalho académico que pode ser utilizado por terceiros desde que respeitadas as regras e boas práticas internacionalmente aceites, no que concerne aos direitos de autor e direitos conexos. Assim, o presente trabalho pode ser utilizado nos termos previstos na licença abaixo indicada. Caso o utilizador necessite de permissão para poder fazer um uso do trabalho em condições não previstas no licenciamento indicado, deverá contactar o autor, através do RepositóriUM da Universidade do Minho. Licença concedida aos utilizadores deste trabalho Atribuição CC BY https://creativecommons.org/licenses/by/4.0/ Guimarães, 31 de janeiro 2024 ______________________________________ (Pedro Henrique Sampaio Dias) ii Acknowledgements Firstly, I express my gratitude to my supervisors, Professor Dr. Estela Bicho and Dr. Flora Ferreira, for their constant help, motivation, support, and scientific guidance throughout this dissertation. A special thank you also goes to Pedro Guimarães for his valuable support and mentoring in the development of this work. Secondly, to my parents, Ana and Henrique, my brothers, Gonçalo and Francisco, and the rest of my family, for all the support, love, and dedication in every moment of this journey. I am thankful for all the good memories and pleasant moments provided over the years. It is thanks to you that I have the solid foundation that has allowed me to reach this point. I am deeply grateful to have you as my family. I also express my gratitude to my closest friends Diogo, Nuno, Razvan, Hugo, Duarte, and Guilherme, for all the happy moments shared during this journey. Thank you for being an essential part of shaping the person I am today. A special thanks to all the friends and colleagues from the Mobile and Anthropomorphic Robotics Laboratory at the University of Minho, for sharing knowledge and valuable advice that significantly contributed to the improvement of my work. Lastly, I thank the friends I made over these five years, whom I will carry with me for life, as well as all the other friends and colleagues who, with their presence, have marked my academic journey. This work is supported by: PRR Be.Neutral (Agendas/Alianças Verdes para a Reindustrialização 02-C05-i01.02-2022.PC644874240-00000016). Subprojecto PPS 14 - Ben-New Generation Projeto financiado pelo Plano de Recuperação e Resiliência (PRR), Programa Operacional C5. Capitalização e Inovação Empresarial, Agendas/Alianças (.01) Mobilizadoras para a Reindustrialização e (.02) Verdes para a Inovação Empresa. iii Declaração de Integridade Declaro ter atuado com integridade na elaboração do presente trabalho académico e confirmo que não recorri à prática de plágio nem a qualquer forma de utilização indevida ou falsificação de informações ou resultados em nenhuma das etapas conducente à sua elaboração. Mais declaro que conheço e que respeitei o Código de Conduta Ética da Universidade do Minho. Guimarães, 31 de janeiro 2024 ______________________________________ (Pedro Henrique Sampaio Dias) iv Abstract Driving a vehicle is often a routine activity that involves visiting the same places at roughly the same times on specific days of the week. Hence, personal vehicles typically transport the same occupants along with their specific items. Therefore, the development of cognitive/intelligent vehicles capable of learning and adapting to their occupants’ routines can assist drivers autonomously during their daily trips. This dissertation aims to develop an integrated system that allows extraction of stop locations from the user’s mobility information and learning of their respective spatio-temporal routines. The system comprises a User Interface/Authentication module , User Stop Location Extraction module , and a User Routine Learning Cognitive module . The User Stop Location Extraction module consists in a machine learning approach, incorporating clustering and artificial neural networks methods to identify and classify stop locations in a given user mobility dataset. This module interacts and supports an already existent User Routine Learning Cognitive module , based on Dynamic Neural Fields (DNFs), which is responsible for the implicit learning of various destinations and their associated time characteristics. Additionally, the Interface/Authentication module involves the development of a basic interface to aid in visualizing the resulting stop locations, provide basic User-Vehicle interaction with the system, and enable user authentication. Experiments conducted with real data regarding the routines of various vehicles have validated the newly developed modules and respective integration with cognitive module. The results notably highlighted the Stop Location Extraction module's particularly satisfactory performance in accurately identifying and classifying stop locations. This module also allows visualization of stop locations thus enhancing the interpretability of predictions generated by the cognitive module when compared to a prior Stop Location Extraction approach based on DNFs. However, despite the improved performance of the new Stop Location Extraction module, it did not necessarily translate into enhanced prediction accuracy by the cognitive module. The prediction errors occur in cases of exceptional, one-time deviations from routine behavior. In essence, this dissertation has contributed to further advance the research within Project BEN, specifically aiming to equip BEN vehicles with cognitive capabilities. Keywords: Human-vehicle interaction, Intelligent vehicles, Learning user habits, Spatial clustering v Resumo Conduzir um veículo é geralmente uma atividade rotineira, em que, normalmente, se visitam os mesmos lugares à mesma hora em dias específicos. Devido a esta repetição, é comum que veículos pessoais transportem os mesmos ocupantes e respetivos objetos. Considerando isto, o desenvolvimento de veículos inteligentes capazes de se adaptar às rotinas dos ocupantes pode proporcionar assistência autónoma aos condutores durante as suas deslocações diárias. Esta dissertação visa desenvolver um sistema integrado com módulos de Interface/Autenticação do Utilizador, Extração de Stop Locations , e Aprendizagem Cognitiva de Rotinas do Utilizador. O módulo de Extração de Stop Locations recorre a Machine Learning , incorporando métodos de Clustering e Redes Neurais Artificiais para identificar e classificar s top locations num determinado conjunto de dados de mobilidade do utilizador. O módulo Cognitivo, por sua vez, baseia-se num modelo de Dynamic Neural Fields (DNFs), para aprender os diversos destinos e suas características temporais. Por último, o módulo de Interface/Autenticação, é composto por uma interface básica para visualizar stop locations , permitir interação Utilizador-Veículo e autenticação do utilizador. Os testes realizados com dados reais sobre as rotinas de vários veículos validaram os módulos recém-desenvolvidos e a sua integração com o módulo cognitivo. Os resultados destacaram, de forma notável, o desempenho particularmente satisfatório do módulo de Extração de Stop Locations na identificação e classificação precisa das mesmas. Este módulo ofereceu vantagens relativamente à visualização de stop locations e maior interpretabilidade das previsões geradas pelo módulo Cognitivo em comparação com uma abordagem anteriormente adotada de Extração de Stop Locations baseada em DNFs. No entanto, apesar do desempenho superior do novo módulo de Extração de Stop Locations , isto não se traduziu necessariamente numa maior precisão de previsão pelo módulo cognitivo. Os erros existentes na previsão devem-se a casos de desvios excecionais e pontuais do comportamento rotineiro. Em essência, esta dissertação contribuiu significativamente para o avanço da pesquisa no âmbito do Projeto BEN, com o objetivo específico de dotar os veículos BEN com capacidades cognitivas. Palavras-Chave: Agrupamento espacial, Aprendizagem das Rotinas do Utilizador, Interação Humano- Veículo, Veículos Inteligentes. vi Acronyms ADAS: Advanced Driver-Assistance System Adam: Adaptive Moment Estimation ANN: Artificial Neural Network AV: Autonomous Vehicle DBSCAN: Density-Based Spatial Clustering of Applications with Noise DNN: Deep Neural Network DNF: Dynamic Neural Field GPS: Global Positioning System HDBSCAN: Hierarchical Density-Based Spatial Clustering of Applications with Noise HMI: Human-Machine Interaction HRI: Human-Robot Interaction HVI: Human-Vehicle Interaction IV: Intelligent Vehicle LSTM: Long Short-Term Memory ML: Machine Learning OPTICS: Ordering Points to Identify the Clustering Structure PRR: Plano de Recuperação e Resiliência Português ROS: Robot Operating System 1 1 Introduction This chapter serves as an introduction to the subject of the dissertation project, outlining both its focus and the reasons behind its pursuit. It will be demonstrated why this effort is significant, and the research question will be given. Following that, the project goals, as well as the expected results and contribution of this study, are provided. The structure of this dissertation is described at the end of this chapter. 1.1 Contextualization and Motivation Integrated into the PRR (Portuguese Recovery and Resilience Plan) agenda, Project BE.Neutral aspires to position Portugal as a global exporter of zero-carbon mobility cyber-physical products for cities worldwide. At the forefront of this agenda is the innovative vehicle named "BEN". BEN is a small, multi-applicational, lightweight, four-wheeled vehicle with zero carbon emissions, purposefully designed to accommodate new ownership models and urban services. Its primary goal is to optimize community utilization, while simultaneously creating substantial value for its users. Leveraging the cutting-edge advancements in robotics and intelligent/cognitive systems, part of the BEN project is dedicated to equipping BEN vehicles with cognitive capabilities. These include autonomous learning, adaptation, prediction/anticipation, and decision-making under real-world constraints, all centred around users' daily routines. Particular emphasis is placed on exploring already developed models based on the Dynamic Neural Fields framework to endow vehicles with online learning capabilities and predict users' routines. Through these sophisticated features, BEN vehicles will aim to provide a seamless and personalized mobility experience and proactive assistance to its users, revolutionizing the way people interact with transportation technology. In recent years, due to more sophisticated computer hardware and numerous data-driven technologies, the automotive industry has been able to endow vehicles with improved advanced driver assistant systems (ADAS). These systems are commonly utilized to mitigate the risk of accidents and proactively prevent potential collisions, employing features like collision avoidance and distraction detection. Moreover, some of these systems focus on enhancing user comfort and providing drivers with valuable information and services, such as recommendation services and interactive assistance (Belmonte et al., 2021; Yi et al., 2020a). Anticipated growth in the demand for Advanced Driver Assistance Systems (ADAS) is attributed to factors such as strict safety regulations and a rising consumer preference 2 for applications that prioritize comfort and fuel efficiency (S. Choi et al., 2016; S. Gospodinova & F. Miccoli, 2022). However, ADAS have advanced beyond generic designs, with a notable focus on personalization for individual drivers (Yi et al., 2020a). By considering specific user preferences and traits, vehicles can offer more effective and tailored assistance, thereby enhancing acceptability and trust in these systems. The overarching objective is to develop cognitive vehicles capable of continuously learning and adapting to individual user habits, aiding drivers in their daily travel routines. Scholars and vehicle manufacturers emphasize the importance of equipping vehicles with the ability to perceive mobility data, reason, evaluate, respond, and learn from diverse experiences (Hoch et al., 2007; Vitello et al., 2017). A 2021 survey by Patel in (Patel et al., 2021) gathered public opinions regarding cognitive vehicles, revealing enthusiastic responses to potential assisting features such as learning drivers' routines, predicting the next destination and departure times, and preparing comfort settings in the vehicle for upcoming trips. Respondents expressed a highly positive attitude towards these proposed features, deeming them intriguing and highly valuable. In addition to this, the more technologically advanced systems embedded in the car’s cockpit have aided in increased availability of spatiotemporal information on human mobility. These reasons combined opened new opportunities in the research topic of humanvehicle interaction regarding more personalized/human-centred assistive systems. Until now, the focus of research in the field of personalized ADAS has been on systems that solve safety concerns by monitoring human driving behaviour and style (Hasenjäger et al., 2020; Hasenjäger & Wersing, 2017; Yi et al., 2020b). Personalization should be addressed while profiling mobility procedures to lower the driver’s cognitive load and offer an excellent user experience. As this project explores shared vehicle ownership and proactive assistance to BEN’s users, it is crucial for the system to make predictions according to the learned routines of different drivers (Wojtak et al., 2021). Human mobility is distinguished by an elevated level of spatial-temporal regularity (Eagle & Pentland, 2009; González et al., 2008; Song, Qu, et al., 2010), a trend to visit specific areas at specified times (González et al., 2008; Ramos et al., 2020; Rinzivillo et al., 2014; Song, Koren, et al., 2010), and a considerable tendency to spend the majority of time in a few locations (Song, Koren, et al., 2010). Driving a car is usually bound to a person’s daily routines, such as driving to work every weekday or other habits on different time scales such as going to the gym or sports practice on specified days of the week. Navigation systems can profile a given driver's mobility pattern to enhance the individual’s travel experience by, for example, notifying the driver of traffic circumstances that may cause a late arrival. Future automobiles may be able to forecast where a specific driver wants to travel and when the driver should arrive or depart (Kun, 2018). 3 Numerous ways for forecasting the next location/destination in human mobility have been developed, most of which are statistical models based on big data (Boukhechba et al., 2018; Simmons et al., 2006). Traditional Markov models function effectively for a limited set of behaviours, but destinations must be predetermined. Deep learning algorithms have recently been used to accurately predict user destinations (e.g., Fernandes et al., 2020a; Xu et al., 2021). A Long Short-Term Memory recurrent neural network is employed in (Fernandes et al., 2020a) to predict drivers' destinations and their departure timings. In this architecture, the destinations (places visited by a driver regularly) are first identified using a clustering technique, and updating new destinations necessitates restarting the learning system. The deep learning strategy in (Xu et al., 2021) is based on dividing the spatial map into grids, each with a unique ID number, and presenting the IDs of all probable destinations at the start of the learning process. Although the model considers the temporal aspects of GPS (Global Positioning System) trajectories, it does not use this information to estimate departure or arrival times (Wojtak et al., 2021). A model capable of learning ordinal and temporal features of a daily driver routine based on the theoretical framework of Dynamic Neural Fields (DNFs) was also proposed (Ferreira et al., 2019). The learning is implicit (i.e., the driver is not asked for his/her destinations), ongoing, and adaptable to varied time scales in contrast to the Markov models. The theoretical framework of DNFs has been demonstrated to provide key brain-inspired processing mechanisms to implement working memory, decision-making, and prediction in cognitive systems (Sandamirskaya et al., 2013; Schöner, 2008), including the learning of temporal and ordinal properties of sequential tasks (Cunha et al., 2020; Ferreira et al., 2014; Ferreira, Wojtak, Sousa, et al., 2021). Since then, advancements have been made, with the most significant being the incorporation of long-term memory, which allows for the continuous updating and consolidation of the memory of driving experiences on a specific weekday over weeks, and the ability to learn and distinguish the routines of different drivers (Wojtak et al., 2021). Recently, the approach based on DNFs has been extended to allow the dynamic Identification of Stop Locations from GPS trajectories based on their temporal and spatial characteristics (Ferreira, Wojtak, Fernandes, et al., 2021). Building upon prior research, Guimarães in (Guimarães et al., 2023), has expanded the DNF model in (Wojtak et al., 2021) for learning travel routines. This advancement involves incorporating the approach developed in (Ferreira, Wojtak, Fernandes, et al., 2021) to online clustering of geographical locations, enabling the identification of regions of interest on a topographic map. Notably, the model achieves continuous and implicit learning from GPS data without explicit prompts from the driver regarding preferences or habits. It encompasses comprehensive learning of the vehicle's mobility routines, encompassing the driver, passengers, and objects. Additionally, the model possesses the ability to adapt to evolving driver habits, encompassing alterations in the timing of 4 specific arrivals or departures, as well as the ability to forget visits that are no longer part of routine behaviour. A key feature is the autonomous recall of learned sequences of travel events, enabling the ADAS to provide timely alerts to the driver regarding upcoming arrivals or departures, as well as potential changes in the status of passengers and objects. This last iteration of the neuro-inspired model will be the one adopted in this work to tackle the challenge for learning travel routines. However, despite of the online clustering of geographical locations approach, based on DNF, proved quite successful, it didn’t allow any visualization or correction of the resulting/discovered clusters, which means that incorrect assumption may be fed to the cognitive model that learns the routines. In clustering algorithms, especially in the domain of geographical location clustering, is inherently difficult to optimize hyperparameters for a wide range of situations and contexts, particularly considering that one car can be shared among multiple drivers. Even advanced and intricate algorithms struggle to effectively tune hyperparameters, which tend to increase in complexity, to accurately determine stop locations for different drivers. A straightforward example of this challenge can be illustrated by considering a user arriving at their workplace. The surrounding area may offer multiple parking options, and the user might alternate between them, based on factors such as convenience or varying circumstances. In this scenario, it is desirable for the clustering algorithm to associate all these parking spaces with the location "Work". However, if the same user is in another area of the town, they might have three distinct locations (e.g., Gym, Supermarket, Doctor) all within a close radius. In this case, we want the clustering algorithm to identify and differentiate these three distinct locations. Unfortunately, the clustering algorithm might struggle to accommodate both scenarios effectively. When configuring a clustering algorithm, it's important to acknowledge that some locations may be neglected, while others might be erroneously created. Once again accurate determination of stop locations is crucial for the correct functioning of the model for learning travel routines. Addressing this challenge and finding a solution to accurately identify diverse stop locations will be one of the main focuses during the execution of this project. 1.2 Objectives and Contributions The general objective of this dissertation is to develop an integrated system that allows extraction of stop locations from the user’s mobility information and learning of their respective spatio-temporal routines. To achieve that it comprises a User Interface/Authentication module, User Stop Location Extraction module and a User Routine Learning Cognitive module. The User Interface/Authentication module will consist in the development of a basic interface to, aid in visualization of the resulting stop locations 5 obtained, provide basic user interaction and authentication. As for the User Stop Location Extraction and User Routine Learning Cognitive modules, as previously stated in section 1.1, the ultimate goal of this dissertation is to build, implement, and evaluate a machine learning based model to uncover Stop Locations in a given user mobility dataset, that will interact and support a DNFs-based model based on the architecture proposed by (Guimarães et al., 2023). This framework will learn numerous destinations and their associated time characteristics. To achieve the objectives, it is necessary to complete a whole set of steps/tasks listed below: • State-of-the-art: study different Machine Learning techniques (Dynamic Neural Fields, Neural Networks, Deep Learning) to analyse and extract important features from daily driving routines (time series data). Study possible algorithms for face biometrics authentication implementation. • Develop a basic interface that allows result visualization, and basic user interaction and respective authentication (2 step verification with face biometrics). • Based on Machine Learning Approaches develop a model to accurately identify diverse stop locations, that include the user in the learning cycle. • Study models and algorithms to learn and reproduce complex time-constrained sequences, i.e., BEN vehicle routines. • Integration of the different modules (Interface/Authentication, Stop Location Extraction and Routine Learning Cognitive module). • Implement and test the system in (quasi)real driving scenarios within the scope of the BEN project. With these steps achieved, the expected result is a Smart(er) BEN vehicle able to learn flexibly and robustly the spatial-temporal routine of its users at different time scales, and thus predict who will be the following driver/user, predict where he/she intends to go, when he/she intends to leave, when he/she intends to arrive at the destination and how long he/she intends to stay at that destination. This will enable a BEN vehicle to adapt in advance to its occupants and future situations and to be intelligently shared. This technology is currently in high demand in the automotive industry and mobility in smart cities (e.g., (Patel et al., 2021)). 6 1.3 Organization of the Document The remainder of this document is organized as follows: Chapter 2, which consists of four sections, presents the state of art relevant to user authentication and vehicle routine prediction: • The first section goes through the state of art in Face biometrics tackling every aspect of the face biometrics pipeline, face detection and alignment, feature extraction and recognition. • The second addresses the problem of extracting the stop points in greater detail. First, it goes through the terms/concepts of stop point, trajectory, clustering, and spatiotemporal data. The clustering methodologies used to address this issue are then detailed. • The third section examines current progress in Human-Machine Interaction by providing a brief history of the subject and describing new advances and methods regarding human-vehicle interaction. • The last section focuses more specifically on the problem of Driver Routine Prediction. It details current approaches employed to tackle this issue, namely Artificial Neural Networks, Hidden Markov Models, and Dynamic Field Theory. Chapter 3 presents the development of the system. It comprises the general system architecture and methods and materials, containing the used datasets, learning methods and open-source libraries relevant for this dissertation. Chapter 4 has four sections dedicated to the implementation of different parts and modules of the system, frontend and backend, face recognition authentication, stop location extraction and cognitive modules. Chapter 5 describes the results of the simulations performed to validate the stop location extraction and cognitive modules. Chapter 6 presents the conclusion by briefly reviewing the developed work and contributions, finally providing ideas/extensions for future work. 7 2 State of the Art In this chapter, several concepts related to the area of this work are presented. Firstly, a brief introduction to the Face biometrics concepts and existing work, needed for user authentication into the system. Following, a short literature review and concepts regarding Stop Location extraction and available and possible Clustering algorithms for the task. An introduction to the Human-Machine interaction concept is then made, and more emphasis is put on the Human-Vehicle interaction due to the nature of this project. Finally, a collection of methods found in the literature to access the driver routine prediction problem is analysed. 2.1 Face Biometrics Face recognition involves identifying or verifying an individual by analysing their facial features from a video or photo. In this computer vision task, patterns in a person's facial characteristics are captured, analysed, and compared. Face recognition systems can function in either or both of the following modes (i) Face Verification (ii) Face Identification (S. Z. Li & Jain, 2011). The first mode, Face Verification (Authentication), involves a one-to-one comparison of a provided face with a known identity (e.g., determining if this person is who they claim to be). For the second mode, Face Identification (Recognition), the system performs a one-to-many comparison of a given face against a database of known faces (e.g., identifying the person in the image and linking them to a specific identity. According to (Barnouti et al., 2016), the process of face recognition can be broken down into three distinct stages: face detection, feature extraction (face embedding), and actual face recognition (feature matching). Although this is true, some authors consider an extra step to the face recognition pipeline, face alignment (S. Z. Li & Jain, 2011), has shown in Figure 2.1. Figure 2.1: Face Recognition Pipeline. 8 In the following sections, we will explore the latest advancements in the algorithms regarding face detection, feature extraction (face embedding), and actual face recognition/authentication (feature matching). Given the prevalent approach of integrating feature extraction and face recognition into a unified model using deep learning, we will discuss these two processes in conjunction. 2.1.1 Face detection When provided with an image or video stream, the primary objective of face detection is to determine the location and extract all human faces within the input. This process holds immense significance, not only in biometric face recognition but also in face tracking, person identification across surveillance cameras, recognizing expressions and emotions, and analysing soft biometrics like gender or age (Kumar et al., 2018; Zafeiriou et al., 2015). In earlier, simpler approaches, skin color was a main factor for face detection in images (Crowley, 1997; Kjeldsen & Kender, 1996), offering orientation-invariant capabilities that enabled face detection even in non-frontal poses. However, these approaches fell short in accommodating the diverse spectrum of skin tones resulting from both natural variations among individuals and varying lighting conditions. More advanced algorithms have since been introduced. For instance, (Sirovich & Kirby, 1987a) proposed a method based on eigenvectors derived from extensive face image datasets. Viola and Jones, in (Viola & Jones, 2001) introduced a method employing cascades of Haar transform filters selected through AdaBoost, while histograms of intensity gradients and orientations from image regions were utilized in (Dalal & Triggs, 2005). Although these methods often provided rapid and efficient detection suitable for real-time systems, they struggled with non-frontal face detection and faces of vastly different scales. In line with the evolution of pattern recognition tasks, traditional methods from earlier literature have been replaced in favor of deep learning algorithms. These newer approaches offer superior and accurate face detection, particularly excelling in non-frontal face detection. Mainly due to the abundance of open-source datasets that are now readily available. Notably, datasets such as the WIDER face dataset (Yang et al., 2016) and the Face Detection Database (FDDB) (V. Jain & Learned-Miller, 2010) serve as public benchmarks, allowing for fair and direct comparisons with state-of-the-art methods. Currently these benchmarks are dominated by deep learning approaches. In the WIDER Face benchmark TinaFace (Zhu et al., 2020), Poly-NLand (Babiloni et al., 2021) and ASFD- D6 (Zhang et al., 2020) stand out with the highest scores. TinaFace leads the benchmark, it is a face detection method rooted in generic object detection principles, leverages ResNet-50 and a 6-level Feature Pyramid Network to extract multi-scale features from input images. To enhance feature comprehension 9 and augment the receptive field, it integrates an inception block. Additionally, TinaFace utilizes a single convolutional layer dedicated to IoU (Intersection over Union) prediction. On the FDDB benchmark however, prominent algorithms like DSFD (J. Li et al., 2018), Face R-FCN (Y. Wang et al., 2017) and SRN (Chi et al., 2018) currently lead the way. DSFD (Dual Shot Face Detector) is the best performing algorithm in this dataset. It introduces, Feature Enhance Module (FEM), enhancing original feature maps, enabling the transition from a single shot detector to a dual shot detector, Progressive Anchor Loss (PAL), computed using two distinct sets of anchors, to effectively guide the features. Finally, it makes use of Improved Anchor Matching (IAM) by integrating a novel anchor assignment strategy into data augmentation, enhancing initialization for the regressor. All these advanced algorithms excel in precise and robust face detection across diverse poses and scales. However, their computational demands necessitate GPU support for real-time operation, especially for images with VGA resolution. While substantial progress has been made in unconstrained face detection, future research should prioritize enhancing algorithm speed and efficiency to further advance the field (Pinto, 2022). 2.1.2 Feature extraction and recognition After successfully detecting and aligning faces in the input, face-based recognition systems proceed to extract suitable features essential for accurate identity determination. Over the years the field of face biometrics has shifted from conventional machine learning approaches in favor of the more complex and robust deep learning approaches (see Figure 2.2) as highlighted in a study on deep learning for face recognition by (M. Wang & Deng, 2021). This progression saw significant improvements when specialized objective functions were introduced (see Figure 2.3). The approaches were categorized into holistic learning, local handcrafted, shallow learning, and deep learning methods (M. Wang & Deng, 2021). Holistic learning involves using the entire face image to derive representations facilitating face recognition. The Eigenface (Sirovich & Kirby, 1987b) and Fisherface (Belhumeur et al., 1997) methods are examples, although they are simple and fast, they lack robustness to numerous variability factors. Researchers then explored region-based feature extraction using methods employing Gabor filters (Liu & Wechsler, 2002), Local Binary Patterns (Ahonen et al., 2006), and the Elastic Bunch Graph Matching (Wiskott et al., 1997), enhancing recognition accuracy but not reaching practical usability. To enhance both accuracy and robustness in handling pose variations, researchers introduced learning-based methods that utilized existing data to learn optimal features. Shallow learning methods emerged, utilizing gradient filtering (Z. Cao et al., 2010), after facial 10 Figure 2.2: Recent history of face recognition, from deep learning to tailored objective functions, adapted from (M. Wang & Deng, 2021). Figure 2.3: Evolution of face recognition approaches, adapted from (M. Wang & Deng, 2021) 17 Grid-based Methods: In this, the space is divided into a finite number of cells creating a grid structure. After that, all the operations for clustering are done in each cell. The key advantage of this approach is its quick processing time, which is often independent of the amount of data objects and only reliant on the number of cells in each dimension of the quantized space. Some of the algorithms used in this technique are STING (Statistical Information Grid), WaveCluster, and CLIQUE (CLustering In QUEst) (Halkidi et al., 2001; Han et al., 2012). Model-based Clustering Methods: These strategies aim to improve the fit between the given data and mathematical models. Model-based clustering algorithms, as opposed to traditional clustering, find distinctive descriptors for each group, where each group represents a notion or class. Decision trees and neural networks are the most commonly utilised methods (Rokach & Maimon, 2005). 2.3.4 Spatial / Spatiotemporal Data Clustering The spatial clustering process shares the fundamental objective of the "classical" clustering, aiming to group objects based on similarity. However, in spatial clustering, an additional element comes into play— the position or location of the object. Unlike traditional clustering that relies solely on similarity aggregation, spatial clustering considers the spatial proximity of objects. For instance, even if two objects are highly similar, they may not be grouped together if they are far apart, as determined by the distance function incorporating geographical position as a similarity measure (Leite et al., 2013). This characteristic allows spatial clustering to combine both spatial and non-spatial attributes of the objects. This technique finds practical application in various domains, including crime prevention. Law enforcement agencies utilize spatial clustering technology to identify crime hotspots, enabling them to implement preventive strategies such as intensive patrolling in the identified problematic areas (Maimon & Rokach, 2010). Moreover, for the stop location extraction some authors consider the temporal feature of the data when available, turning this into a spatiotemporal problem. This increases the complexity of the clustering algorithms since they must evaluate both the spatial and temporal features of the items in the research to discover meaningful knowledge. Nonetheless, the primary idea behind clustering remains the same: to examine the features of the items and determine which are similar and which are not (Leite et al., 2013). Various authors have already studied this type of problem by resorting to different methods. Some generic approaches to either spatial or spatiotemporal clustering and others that are directed to stop location extraction, which is the goal of this work, will be presented below. 18 For instance, in (Yuan et al., 2012) the classical K-Means clustering algorithm to identify locations of interest was used. Density-based algorithms such as the DBSCAN (density-based spatial clustering of applications with noise) or other various DBSCAN derivative algorithms have found popularity in detecting stop locations (Andrade et al., 2019; Hamid & Croock, 2020; Q. Huang, 2017; Luo et al., 2017). DBSCAN (Ester et al., 1996) is a common density-based clustering method in which the density of a point is measured by the number of points within a given distance from it. DBSCAN is extensively used for clustering and noise reduction by specifying two parameters: the maximum distance between two points (eps) and the minimum size of points (minPts) that a given cluster may contain. A cluster is defined as a set of points with a dimension higher or equal to minPts and within the epsneighbourhood. Non-clustered points are classified as noise. The reason that makes destiny-based approaches popular in this type of application is that they offer several advantages over the classic methods such as K-Means such as the ability to recognise clusters of various forms (Q. Huang, 2017). The authors in (Pölitz et al., 2010) used the DBSCAN method to perform spatial clustering of the data first, followed by temporal clustering of the resultant spatial clusters. This strategy was followed in another work (McArdle et al., 2012) to cluster trajectories. They used both strategies (spatial and temporal) in a similar manner. The authors first utilised spatial clustering to extract spatially comparable trajectories and then applied temporal clustering to those clusters (Leite et al., 2013). Hierarchical clustering algorithms also have been used to identify different visited locations, one example being agglomerative hierarchical clustering (Montini et al., 2014). Hierarchical clustering methods can provide a more intuitive interpretation of clusters when compared to the popular DBSCAN. To combine the best of both methods a hierarchical clustering algorithm named HDBSCAN has been recently applied to identify regions of interest (Chen et al., 2019; Fernandes et al., 2020b). By performing DBSCAN over varying the maximum distance between two points (eps) values and integrating the results, this method finds a clustering that provides the best stability over eps . As a result, HDBSCAN can identify clusters with varying densities, which is a major advantage over DBSCAN. In HDBSCAN, a minimal spanning tree is constructed based on the mutual reachability distance between points to obtain clusters with varying densities. This tree is then used to construct a condensed cluster hierarchy where the width of the branch represents the number of cluster points. In this algorithm, the minimum cluster size (minPts) is the input parameter required. The algorithm prunes the tree by increasing the minimum weight of connections λ based on this parameter. If the remaining components are larger than minPts they are kept for consideration as a cluster otherwise they are declared as noise. HDBSCAN considers clusters to be the regions of the tree that are the most resistant to changes in λ (McInnes et al., 2017). 19 In Section 1.1, it was outlined that a recently developed DNF (Dynamic Neural Field) model has been extended to incorporate spatial clustering for similar locations. This extension involves employing two coupled two-dimensional field equations of Amari type (equation 3.2.3.2), with 𝒙 ∈ 𝛀 ⊂ ℝ2. Notably, this model supports the continuous integration of inputs over time, as referenced in (Ferreira, Wojtak, Fernandes, et al., 2021; Wojtak et al., 2023). The spatial range of the excitatory connections within the model controls the spread of self-sustained peak activity across the GPS map in response to a single input data point. When a series of inputs falls within this excitatory range, the field dynamics create an extensive, connected pattern of persistent activity. In practical terms, this translates to the grouping of data points within the same excited region for all travel destinations. Consequently, multiple activity clusters, representing stop locations, emerge on the topographic map (as depicted in Figure 2.6). The choice of the kernel parameter 𝜎 governs the cluster size, thus influencing the spatial resolution for identifying distinct travel destinations. For a more comprehensive understanding of the algorithm, readers are referred to (Ferreira, et al., 2021). Figure 2.6: Clustering module: The DNF-based neural integrator model, employing 2D fields, serves to accumulate input at specific geographical locations. As inputs aggregate within an excited region, distinct activity clusters, denoting stop locations, are formed. Adapted from (Guimarães et al., 2023) . In summary, we covered multiple existent clustering methods in literature, some used for generic clustering others specifically applied in spatial /spatiotemporal data. As modifying the online DNF clustering approach in (Ferreira, et al., 2021) will add unnecessary complexity to the framework, this approach will be discarded for this study attempt. The choice falls between the simpler and faster clustering algorithms like K-Means and more intricate density-based algorithms such as DBSCAN. K- Means, known for its speed and simplicity, is often favoured when modifications to clusters are 20 anticipated, or when the system requires swift execution, despite its limitations. Mainly the two unavoidable problems of the K-Means algorithm: (i) assignment of centroids and number of clusters and (ii) ability to handle different types of data. On the other hand, density-based algorithms like DBSCAN and its variants tend to yield superior results by forming clusters of arbitrary shapes, unlike K-Means which assumes spherical clusters. Moreover, these algorithms can adapt to varying densities, exemplified by HDBSCAN. However, this advantage comes at the expense of increased computational time and the need to fine-tune additional hyperparameters, making them more resource-intensive and potentially challenging to optimize, especially with diverse datasets. The choice ultimately hinges on striking a balance between computational efficiency and the quality of clustering results based on the specific characteristics of the data and the objectives of the analysis. 2.4 Human-Machine Interaction (HMI) The concept of Human-Machine Interaction (HMI), also known as Human-Robot Interaction (HRI) when the machine can be considered a robotic agent, refers to the field dedicated to the study of “ the communication and interaction between a human and machine via user interface ” (Ke et al., 2018). HMI emerged with the introduction of the first robotic devices in the mid-20th century. However, the concept of robot-like behaviour has been around for a much longer time. Additional knowledge on the history of robotics can be consulted, e.g., in the first chapter of (Kurfess, 2005). This human-machine/robot contact has progressed throughout time, from the usage of simple interfaces such as joysticks, and teleoperation, to vocal commands and other types of natural user interfaces, such as gestures, which are gaining popularity because they enable humans to operate technology through natural and intuitive behaviours (Ke et al., 2018; Sheridan, 1997). An example of more elaborate interfaces appeared in the late 20th century, when a new technique known as behaviour-based robotics emerged, allowing robots to develop more complicated behavioural patterns (Arkin & R. C., 2000). Soon after, hybrid architectures emerged, allowing for the combination of complex reactive responses with high-level cognitive thinking, hence enhancing interactions with humans (Egerstedt, 2000; Guo et al., 2017). Recently, artificial intelligence researchers have been working hard to create completely autonomous robots (Dautenhahn, 1995; Kurrek et al., 2020). The Dynamic Neural Fields framework has been utilised in the field of HRI to provide autonomous robots with human-like cognitive skills fundamental for natural and efficient interaction in cooperative activities (Bicho et al., 2010; Erlhagen & Bicho, 2014). Creating a Human-Machine Integration system requires inputs from a variety of disciplines, including psychology, mathematics, and 21 computer science, to mention a few. These systems can also fall under various sets of taxonomy categories of interaction between humans and robots (Yanco & Drury, 2004). However, only proximate interactions with ties to Human Vehicle Interaction Systems are addressed in this dissertation. Proximate interactions are the ones in which both agents are present (in time and space). 2.4.1 Human-Vehicle Interaction (HVI) Human-Vehicle Interaction shares the same definition with HMI, but now the vehicle is the machine, meaning it targets the interaction between humans and vehicles. The main goal of this study area is to endow vehicles with cognitive abilities to assist a user in different tasks. Intelligent Vehicles (IVs) are the result of vehicles imbued with assistive capabilities to bring several advantages, including efficiency, safety, and enjoyment in the driving task (X. Sun et al., 2018). Even though automobiles play a major role in today’s society, in the way they brought convenience and flexibility to individual human transportation, the research field regarding intelligent vehicles is very recent. It dedicates its efforts to the development of advanced driver assistance systems (ADAS) and autonomous vehicles (AVs). ADAS systems were initially introduced by the automotive industry to provide safety features using a combination of an array of sensory technologies. These can produce safety warnings or even aid the vehicle user in executing tasks such as braking, steering, or parking. In cases of imminent danger, some systems can actuate without any user input to avoid dangerous outcomes for all of those involved. Collision avoidance, Pedestrian detection, Parking assistance, and Adaptive Cruise Control (ACC), are examples of the most known ADAS systems present in today’s automobiles. Autonomous driving, on the other hand, as the term indicates, refers to the technologies that allow cars to drive without any human intervention. To automate the driving procedure, autonomous vehicles employ complicated algorithms. They benefit from the fully digitalized car by automatically controlling all automotive systems. One of the first autonomous drive attempts, employed computer vision techniques and occurred in the mid to late 1990s. According to a case study conducted by Bundeswehr Universität München (UBM), a car could drive autonomously for 95% of the trip between Munich, Germany, and Copenhagen, Denmark. The Argo Project quickly followed as a low-cost method for building an autonomous car. The car, developed at the University of Parma, was capable of following the lane, detecting obstructions, and changing lanes with 95% autonomy when commanded (Bertozzi et al., 1998).In addition, Deep Learning algorithms have lately been used to develop autonomous vehicles (Huval et al., 2015; Sallab et al., 2017). 22 According to the Society of Automotive Engineers (SAE), there are six levels of autonomous driving going from 0 to 5 (SAE International, 2018). In the first three SAE levels, it is mandatory that the user remains in the driver’s seat and pays attention to the road. These are considered support levels that operate while the user controls the vehicle. In the remaining levels, the vehicle is endowed with autonomous driving capabilities. However, at the earliest levels, these capabilities are limited to certain conditions and parameters and still require the user to be in the driver’s seat, ready to take control of the vehicle if the need arises. If a car is completely autonomous under any situation, it is considered level 5. Even though some prototypes already exist, the concept of a completely driverless car is not feasible for the time being. This is due to challenges related to impractical sensing, issues with reliability, latency, cyber security, privacy concerns, as well as legal and ethical considerations. However, some emerging technologies might bring the automotive industry on the brink of a paradigm shift. With IoT variants specially developed for vehicle IoV and IoAV. Edge intelligence, merging AI with edge computing, is set to enable intelligent decision-making in vehicles, particularly during urgent situations. The integration of Explainable AI will bolster the trustworthiness of AI reasoning behind these decisions. Additionally, the advancement to 5G and 6G mobile communication will optimize the transfer of large volumes of critical data necessary for the operation and control of Autonomous Vehicles (AVs). Lastly, blockchain and associated technologies play a pivotal role in safeguarding AVs against potential security and privacy risks. Facilitating the Advancement and Maturation of Intelligent Autonomous Vehicles (Biswas & Wang, 2023). It is also worth noting that HVI principles have been widely utilised by car manufactures in car cockpits (Z. Huang et al., 2020; X. Sun et al., 2018). In the 2024 E-class, Mercedes is integrating artificial intelligence to analyse the driver's usage patterns of comfort features based on various situations and times. Subsequently, the AI system will autonomously activate these comfort settings, ranging from navigation to preferred addresses, climate control preferences, and even personal reminders like birthdays. It is predicted that the new iterations of this is system will encompass autonomous learning of the user’s routines. 2.5 Driver Routine Prediction Another focus of this work is learning the ordinal and temporal components of a driver's routine. Thus, learning about driving routine prediction is quite important in this scenario. Driving is a mundane chore for the majority of individuals. As mentioned previously, people frequently visit the same sites at the same time of day or on the same day of the week (Eagle & Pentland, 2009). As a result, various distinct approaches, most of which are statistical in nature, to predicting driving routines have proliferated. This 23 section overviews the most commonly used ones. Due to the very nature of driving, however, none will be 100% accurate. No matter how strictly a person sticks to his/her regimen, he/she will eventually break it. As a result, the majority of models developed to address this issue are probabilistic. 2.5.1 Artificial Neural Networks In (Fernandes et al., 2020a) researchers suggested a framework for spatial-temporal prediction of driver routines based on hierarchical density-based clustering followed by a Deep Neural Network (DNN) (for further explanation of the findings consult (Fernandes et al., 2020a). In Figure 2.7 a scheme of the created model's scheme is shown. To begin, the model uses a clustering method, in this case, HDBSCAN, to extract points of interest. Then, a DNN with a Long Short-Term Memory (LSTM) layer and two dense layers is used. When it comes to analysing temporal dynamics and sequentially structured data, LSTMs have shown to be quite beneficial. Figure 2.7: Deep Learning Model, adapted from (Fernandes et al., 2020a). 2.5.2 Hidden Markov Models Another option to address the issue of predicting routines is to employ Hidden Markov Models (HMM). A Hidden Markov Model is a statistical model for tracking processes that have a hidden state. These structures can be thought of as a probability transition graph (Figure 2.8). HMMs are based on two essential concepts. The first is that transitioning from one state to another is entirely dependent on the current condition. The other is that prior states are still unknown. See, e.g., (Eddy, 2004) for further information about HMMs. This mathematical structure was used by (Simmons et al., 2006) to forecast driving routes and destination intents. In most cases, 98% accuracy was obtained using the process as a sequence of driver actions and the hidden state as the planned destination and route. However, according to the author, much of this accuracy is due to the fact that there tend to be very few places where choices have to be made and as a result, most of the predictions are forced. Another limiting factor is that destinations must be predetermined. 24 Figure 2.8: Example of left-to-right Hidden Markov Model, adapted from (Barbosa P, 2021) . A left-to-right HMM has a left-to-right transition to the next state ( 𝑠𝑖 ) as well as a self-transition. The self-transition is used to model contiguous features in the same state. It is popularly used to model speech as a time sequence of distinct events that start at an initial state, which is usually labelled Begin, and end at a final state, which is usually labelled End. Where, 𝜙𝑖 ( 𝑂𝑘 ) are the output probabilities and 𝑂𝑘 , the observation. 2.5.3 Dynamic Field Theory Dynamic Neural Fields (DNFs) are a mathematical framework for studying the dynamics of pattern creation in neuronal populations (Amari, 1977). They have been utilised in autonomous robots to implement brain-inspired processing mechanisms such as working memory, decision-making, and prediction (Bicho et al., 2010; Erlhagen & Bicho, 2014; Sandamirskaya et al., 2013; Schöner, 2008). Furthermore, DNFs have been shown to be capable of encoding the ordinal and temporal aspects of sensory events. DNFs have been used to learn sequential tasks by combining these properties (Ferreira et al., 2014; Ferreira, Wojtak, Fernandes, et al., 2021; Sandamirskaya et al., 2013; Sousa et al., 2015). DNF models were effective in identifying stop locations/points of interest from GPS data in the context of driver routine applications. Ferreira et al. (2019) and Ferreira, Wojtak, Fernandes, et al. (2021) developed a DNF model (see Figure 2.9) for learning driver habits - when to travel, where to go, and how long to stay there - based on the idea that driving is primarily a routine and that one can anticipate future journeys by analysing prior sequences. As input, GPS coordinates (latitude and longitude) and a signal indicating whether the car was turned on or off were used, the latter provided information about whether the trip was a departure or arrival. Event memory is represented by consistent neuronal activity patterns or bumps in the encoding field. The activation intensity of each bump evolves over time. It so encodes the amount of time that has passed since the process began. Sequential information can be retrieved from memory and used to forecast future events (Barbosa P, 2021). 25 Figure 2.9: Schematic representation of the model suggested in (Ferreira et al., 2019) with multiple interrelated neuralfields. 2.6 Final Notes A comprehensive literature review was conducted, covering all significant topics related to this dissertation. For the face biometrics of the system, the adoption of the HOG (Histogram of Oriented Gradients) + Linear SVM (Support Vector Machine) approach for face detection was favoured over deep learning approaches. This choice was driven by hardware limitations, as the HOG + Linear SVM method strikes a balance between accuracy and computational efficiency. Deep learning approaches, while highly accurate and robust, often demand high computational complexity and need GPU resources for real-time operation, making them less feasible in this context. As for face recognition Dlib-ml face recognition module built with deep learning was adopted. The model has achieved an accuracy of 99.38% on the Labelled Faces in the Wild (LFW) benchmark. Despite the availability of algorithms in the literature that potentially surpass its accuracy, Dlib-ml face recognition module aims to strike a balance between 26 accuracy and computational efficiency, providing a high level of accuracy while remaining computationally efficient. This balance ensures that the face recognition system can be effectively utilized in various applications, including those where real-time performance and efficient use of resources are essential considerations. As previously discussed in this chapter, the clustering of geographical locations will be explored using two primary methods: K-Means and HDBSCAN. The objective is to assess whether the performance achieved with the density-based algorithm (HDBSCAN) justifies its added complexity when compared to the more straightforward K-Means approach. This comparative analysis will shed light on the efficiency and effectiveness of each method in clustering geographical locations, aiding in the selection of an appropriate approach for the study's objectives. In the final selection process, the DNF (Dynamic Neural Field) framework, particularly its last iteration, was chosen for its proven capability in learning and accurately reproducing complex timeconstrained sequences. This framework will serve as the foundation for learning, adaptation, prediction/anticipation, and decision-making centred around users' routines. Its established effectiveness and ability to handle intricate temporal aspects make it a suitable choice for the study's objectives, empowering the model to effectively understand and respond to users' routine-based behaviours. 33 Latitude Longitude Power Time Local Day Driver Pass. (4) Objects 41,41547 ˚ -8,3039 ˚ 1 515 Home Tue Sofia Pedro Bp2, Gb2 41,42489 ˚ -8,29608 ˚ 0 530 Kid sch. Tue Sofia Pedro Bp2, Gb2 41,42489 ˚ -8,29608 ˚ 1 533 Kid sch. Tue Sofia - Bp1, Gb2 41,4516 ˚ -8,29287 ˚ 0 545 Work Tue Sofia - Bp1, Gb2 41,4516 ˚ -8,29287 ˚ 1 1032 Work Tue Sofia - Bp1, Gb2 41,45212 ˚ -8,2945 ˚ 0 1034 Friend House Tue Sofia - Bp1, Gb2 41,45212 ˚ -8,2945 ˚ 1 1038 Friend House Tue Sofia Ana Bp1, Gb3 41,42479 ˚ -8,29621 ˚ 0 1051 Kid sch. Tue Sofia Ana Bp1, Gb3 41,42479 ˚ -8,29621 ˚ 1 1055 Kid sch. Tue Sofia Pedro, Ana Bp2, Gb3 41,42951 ˚ -8,31876 ˚ 0 1071 Gym Tue Sofia Pedro, Ana Bp2, Gb3 41,42951 ˚ -8,31876 ˚ 1 1146 Gym Tue Sofia Pedro, Ana Bp2, Gb3 41,45289 ˚ -8,29478 ˚ 0 1154 Friend House Tue Sofia Pedro, Ana Bp2, Gb3 41,45289 ˚ -8,29478 ˚ 1 1156 Friend House Tue Sofia Pedro Bp2, Gb2 41,41545 ˚ -8,30388 ˚ 0 1169 Home Tue Sofia Pedro Bp2, Gb2 Table 3.1: Sample of a Tuesday Travelling routine from one of the vehicles. Departures events labelled with 1 and arrivals with 0. Time (in minutes) of day when event occurred. Passengers and objects get in on departures and may leave on arrivals. Finally, Bp and Gb are abbreviation to backpack and gym bag respectably. Figure 3.2: Average vehicle usage time (in minutes) per day and driver (Sofia and Zé). 34 In Figure 3.2 the average vehicle usage time minutes per user is presented, categorized by various days. The vehicle was utilized by two individuals, Sofia and Zé. On average, Sofia tends to use the vehicle more daily compared to Zé. Additionally, it's evident that Sofia does not drive on Sundays, while Zé refrains from driving during weekdays. Figure 3.3: Average number of trips per day for Sofia and Zé (Mornings, Afternoons , and Evenings). Figure 3.3 display the average number of trips per day split into different periods - morning, afternoon, evening - for Sofia and Zé, respectively. One can see that Sofia drives almost with the varying but relative high frequency in the morning and the afternoon but rarely in the evening. Zé, on the other hand, all the trips occur during the weekend as we had previously examined. During Saturday, the day both use the car, Sofia trips occur mainly during the morning, and for Zé is during the afternoon, which makes sense since the vehicle is shared by the users. In the graph depicted by Figure 3.4, we can observe the distribution of visits to various stop locations. What immediately catches the eye is the high frequency of visits to a limited number of destinations. This is not surprising, as routine activities like commuting to and from the user’s residence, taking the children to school, going to work, and grocery shopping occur much more frequently than occasional events such as a doctor's appointment. However, this is a prime example of dataset imbalance, that means that disproportionate number of instances for each class exists. This can lead the model to be biased towards the majority class, impacting the overall performance of the model. Therefore, 35 methods to address this issue will be discussed in greater detail the following section, together with the remaining necessary machine methods, tools, and concepts. Figure 3.4: Visit frequency of the stop locations. 3.2.2 Machine Learning Methods The subsequent segment introduces the essential machine learning concepts utilized throughout this dissertation. It begins with a broad overview of the topic, encompassing its learning paradigms within Machine Learning. Follows a presentation of the clustering algorithms and respective evaluation metrics that will be tested. Finally, an introduction to artificial neural networks with more focus on Feed-Forward neural networks. 3.2.2.1 General Introduction Machine Learning (ML) is a field within computer science dedicated to exploring algorithms and methodologies for automating solutions to intricate problems which are difficult to tackle through conventional programming approaches. Traditional software development involves explicit programming using languages such as C, C++, Python and Java where programmers define each instruction to accomplish specific tasks for a given program specifications (Sarkar et al., 2018). Conversely, in the realm of ML, software "learns" from vast amounts of data and experiences, essentially training itself to make informed decisions and predictions. Instead of being explicitly programmed for every task, ML models generalize patterns from the data they process. This enables the software to adapt and evolve, 36 handling a broader spectrum of tasks with agility and intelligence. The power of ML lies in its ability to continuously improve and optimize its performance as it gathers more data and experiences (Rebala et al., 2019). The concept of machine learning is summarized in the formal definition, proposed by (Mitchell, 1997):” A computer program is said to learn from experience E with respect to some class of tasks T and performance measure P if its performance at tasks in T, as measured by P, improves with experience E.” . Since its establishment in the latter half of the twentieth century, the field of Machine Learning (ML) has experienced phases of reduced attention, often referred to as the AI winter, as well as phases of significant interest from the research community. In recent times, driven by the abundance of data and enhanced computational capabilities, supported by expansive memory and storage capacities, ML has witnessed a surge in application across diverse domains to address a multitude of challenges. Noteworthy applications include the development of autonomous vehicles (Rao & Frtunikj, 2018) , advancements in natural language processing, such as ChatGPT (OpenAI, 2021), recommendation systems, image, and object recognition, among several others. Machine learning algorithms can be categorized in the following ways: • Supervised Learning: Algorithms are provided with a training dataset that includes labelled data as input, coupled with their correct output, enabling the model to learn iteratively. An error rate is obtained by comparing the predicted label and the expected values. The primary goal is to minimize this error. Classification and regression are the two major types of supervised learning. • Unsupervised Learning: In contrast to supervised learning, labels are not provided in unsupervised learning. The algorithm operates by finding statistical patterns, structures, and relationships in the data. One approach involves grouping similar elements together—this technique is called clustering. • Semi-Supervised Learning: Semi-supervised learning integrates aspects of both aforementioned methods, where some elements have labels while others do not. This approach is often used in scenarios where acquiring label values is expensive. 37 • Reinforcement Learning: Reinforcement learning algorithms operate within an interactive loop with the environment. The specific desired output is not initially provided; instead, it's revealed by maximizing a reward function. The core concept is that higher values within this function serve as rewards, encouraging the system, while lower values act as punishments, discouraging undesired behaviours. 3.2.2.2 Clustering Algorithms As stated previously, identifying stop locations in the user GPS data is a necessary first step in getting trip information. The clusters provide the spatial information for DNF models in the Cognitive module to learn mobility routines. This section explores into the operational details of the clustering algorithms that will be experimented. K-Means Clustering K-Means algorithm, initially proposed by (MacQueen, 1967) is a popular and easy to use clustering method, it demonstrates efficient scaling for handling substantial amounts of data and finds application across diverse fields and a wide array of use cases. Variants of this algorithm are being used in conjunction with deep learning for tasks such as image segmentation and handwriting recognition (Taigman et al., 2014). The K-Means algorithm partitions a set of 𝑁 samples 𝑋 into 𝐾 distinct clusters, denoted as 𝐶, with each cluster characterized by the mean 𝜇𝑗 calculated from the samples within the respective cluster. These means are commonly referred to as cluster "centroids," although it's essential to note that they may not be points from 𝑋. The primary objective of the K-Means algorithm is to select centroids that minimize the inertia, also known as the within-cluster sum-of-squares criterion given by the equation bellow (Pedregosa et al., 2011): ∑min 𝜇𝑗∈𝐶(‖𝑥𝑖−𝜇𝑗‖2) 𝑛 𝑖=0 (3.1) Inertia serves as a measure of internal cluster cohesion, aiming to assess how cohesive clusters are within themselves. However, it presents several limitations (Figure 3.5). To begin, it's important to note that inertia operates under the assumption that clusters exhibit both convexity and isotropy (uniformity in all directions). However, this implies that clusters are often envisioned to possess a spherical or near- 38 spherical shape, a representation that may not accurately mirror the diverse shapes present in real-world scenarios. Particularly for elongated clusters or manifolds with irregular shapes. Additionally, inertia lacks normalization; although lower values are preferable and zero is considered optimal, there's no standardized scale. Mainly in high-dimensional spaces, which could be relevant in the future if we consider it in the context of a larger dataset or when dealing with sequences or collections of GPS data, Euclidean distances can be exaggerated due to the "curse of dimensionality." Addressing this issue, a helpful strategy involves running a dimensionality reduction technique like Principal Component Analysis (PCA) before employing K-Means clustering. This approach can mitigate the problem and accelerate computational speed (Pedregosa et al., 2011). Figure 3.5: Short-Comings of K-Means Clustering, adapted from (Pedregosa et al., 2011) K-Means, often known as Lloyd’s algorithm, operates through a series of three fundamental steps. Initially, centroids are chosen, equal to the parameter 𝐾 and typically by selecting samples from the dataset. Following this initialization, the algorithm iterates between the remaining two steps. The first step involves 39 assigning each sample to its nearest centroid, the Euclidian distance between the samples (𝑥𝑖) and centroids (𝑦𝑖) is given by the following equation: 𝐷𝑖𝑠𝑡𝑎𝑛𝑐𝑒=√∑(𝑥𝑖−𝑦𝑖)2 𝑛 𝑖=1 (3.2) In the second step, new centroids are computed by calculating the mean value of all samples assigned to each previous centroid. The algorithm continues to repeat these last two steps until the difference between the mean value of the old and new centroids falls below a defined threshold, essentially ensuring that the centroids stabilize and no longer undergo significant movement. With sufficient time, K-Means will inevitably converge, although it may converge to a local minimum, heavily contingent on the initial centroid placements. Therefore, computations in K-Means often involve multiple iterations, each with varying centroid initializations. To mitigate this, the k-means++ initialization scheme has been introduced (Arthur & Vassilvitskii, 2007), significantly improving convergence. This approach, implemented in tools like scikit-learn, strategically places centroids to be relatively distant from one another. This initialization technique tends to yield more favourable results compared to random initialization. The time complexity of K-Means algorithm is 𝑂(𝑁𝑇𝐾𝐷), where 𝑁 is the total number of data sets, 𝐾 is the total number of partitions, 𝑇 is the number of iterations, and 𝐷 the number of features in the data in the clustering process (Zhao & Zhou, 2021). Silhouette Coefficient Cluster evaluation is crucial as it allows us to measure the quality and usefulness of the outcomes generated by clustering algorithms. It serves as a widely employed assessment metric to analyse clustering performance, particularly in algorithms like K-Means. The silhouette coefficient (or Silhouette score) quantifies how well each data instance fits into its own cluster compared to the nearest neighbouring clusters. It combines the concept of separation between clusters with the internal cohesion of each cluster, offering a comprehensive view of clustering quality. There are two essential concepts for calculating this method, first intercluster which refers to the dissimilarity or differences between groups in a clustering algorithm. In other words, it measures how distinct or separate the groups are from each other. Secondly, intracluster , which refers to the similarity or cohesion within a group. It measures how related the data points are within a specific group. The calculation is performed for each value using the following formula: 40 𝑆𝑖=𝑏𝑖−𝑎𝑖 max (𝑎𝑖,𝑏𝑖) (3.3) Where 𝑏𝑖 is the intercluster distance defined as the average distance to the nearest cluster from data point 𝑖, and 𝑎𝑖 is the intracluster distance defined as the average distance to all other points within the same cluster. In other words, it measures the average distances between data point 𝑖 and all other points belonging to the same cluster. The resulting value from the calculation falls within the range of -1 to 1. A value closer to 1 implies that the clusters are dense and well-separated, a value near 0 suggests overlapping clusters, and finally, negative values indicate incorrect clustering. This method can then be used to determine the optimal number of clusters, 𝑘, for K-Means, surpassing the shortcoming of having to define the number of clusters beforehand, in an unknow dataset. HDBSCAN Clustering The HDBSCAN (Hierarchical Density-Based Spatial Clustering of Applications with Noise) (Campello Ricardo J. G. B.and Moulavi, 2013) algorithm can be viewed as an extension of both DBSCAN and OPTICS. Unlike DBSCAN, which assumes a globally homogeneous clustering criterion (density requirement), HDBSCAN addresses the limitation where DBSCAN may struggle to effectively capture clusters with varying densities. HDBSCAN overcomes this constraint by exploring diverse density scales and building an alternative representation of the clustering problem, allowing it to detect clusters more accurately and robustly across various density levels (Pedregosa et al., 2011). To estimate density this algorithm calculates the distance to the 𝑘𝑡ℎ nearest neighbours. This is called the core distance, for a defined parameter 𝑘 (the minimum number of neighbours to a core point) and a sample 𝑥𝑝, and can be denoted as 𝑐𝑜𝑟𝑒𝑘(𝑥𝑝) (see Figure 3.6) (McInnes et al., 2017). Figure 3.6: HDBSCAN - Core Distance for a given sample when k (the minimum number of neighbours to a core point)=5, adapted from (McInnes et al., 2017). 41 To address the challenge of spreading apart points with low density, characterized by high core distances, a new distance metric called the mutual reachability distance is introduced (McInnes et al., 2017). This metric is crucial for determining the reachability between points and is defined in the following manner: 𝑑𝑚(𝑥𝑝,𝑥𝑞)=𝑚𝑎𝑥{𝑐𝑜𝑟𝑒𝑘(𝑥𝑝),𝑐𝑜𝑟𝑒𝑘(𝑥𝑞),𝑑(𝑥𝑝,𝑥𝑞)} (3.4) where 𝑑(𝑥𝑝,𝑥𝑞) is the original metric distance between 𝑥𝑝 and 𝑥𝑞. For dense points with low core distance, their distances from each other remain unchanged. However, for sparser points, the distance is adjusted to be at least their core distance away from any other point. This adjustment effectively pushes sparser points farther apart, ensuring they are at least as distant as their core distance from other points, as pictured in Figure 3.7, in this case the maximum distance value is the core distance of the green circle, meaning 𝑑𝑚(𝑏𝑙𝑢𝑒,𝑔𝑟𝑒𝑒𝑛)=𝑐𝑜𝑟𝑒5(𝑔𝑟𝑒𝑒𝑛). Figure 3.7: HDBSCAN - Mutual reachability distance between blue and green – equal to the radius of the green circle, adapted from (McInnes et al., 2017). These concepts enable the construction of a weighted graph (minimum spanning tree) (see Figure 3.8), where data points represent vertices and edges are created between points with weights equal to their mutual reachability distances (McInnes et al., 2017). Initially, a high threshold value is set, and edges above this threshold are removed. This iterative process of lowering the threshold causes the graph to fragment into connected components. Over the progression of thresholds, a hierarchy of connected components emerges, ranging from fully connected to completely disconnected, reflecting varying levels of connectivity and density within the data. 42 Figure 3.8: HDBSCAN - Minimum Spanning Tree example, adapted from (McInnes et al., 2017). The next step involves transforming the minimal spanning tree into a hierarchy of connected components (McInnes et al., 2017). To achieve this, the edges of the tree are sorted by distance in increasing order. Then, by iterating through the edges, a new merged cluster is created for each edge. Identifying the clusters to merge for each edge is facilitated through a union-find data structure, simplifying this otherwise complex task. This progression results in a dendrogram, providing a visualization of the cluster hierarchy, see Figure 3.9. Figure 3.9: HDBSCAN - Cluster hierarchy example, adapted from (McInnes et al., 2017). Now, the objective is to obtain a set of flat clusters. To achieve this, the complex cluster hierarchy is condensed into a more manageable representation—a smaller tree where additional data is associated 49 Figure 3.16: Multiple-layer network. Neural Network Training In supervised learning for ANNs, the primary objective is to create a mapping between inputs and outputs using the available data, as described by (Haykin, 2009). This mapping forms a complex function that correlates the independent variables of the problem with the dependent ones. This function is constructed through the ANN learning process, often referred to as training. During training, the algorithm iteratively adjusts the synaptic weights of the ANN, gradually learning the features present in the dataset (Haykin, 2009). The training process involves a repetitive cycle of forward propagation and backward propagation. Each of these cycles is known as a training epoch. The training continues until a predetermined number of training epochs is completed, or another stopping criterion is met. Once training is completed, the ANN is prepared to accept inputs from new, unseen situations and generate predictions based on the knowledge acquired during the training phase. In the training process of an artificial neural network (ANN), understanding the distinct phases is crucial. Here's an outline of these phases: • Initialization Phase: o Initialization of the parameters. o Separation of the dataset into training, validation, and test sets. • Training Phase: o Forward propagation. o Backward propagation. o Iteration until parameters are optimized. 50 In the initial step of the training process, the parameters of the connection’s weights are initialized. A common approach involves random initialization of these parameters within a range of values close to, but not equal to zero. While this approach has been successful, Glorot and Bengio in (Glorot & Bengio, 2010), introduced an alternative method aimed at enhancing accuracy and expediting convergence in ANNs. This method is called Glorot Uniform Initialization (also known as Xavier Initialization) entails selecting ANN weights randomly from a normal distribution. Regarding the parameters of this distribution, it's crucial to set the variance in a manner that maintains uniformity of the variance of the back-propagated gradients across all layers (Gonzalez, 2020). The following expression serves this purpose: 𝑉𝑎𝑟[𝑊𝑖]= 2 𝑛𝑖+𝑛𝑖+1 (3.11) Expression (3.11) calculates the variance 𝑉𝑎𝑟 for a set of weights 𝑊𝑖 connecting two distinct layers, where the 𝑖 denote a specific layer, and 𝑛 represents the number of neurons in that layer. This method was the one used to initialize the parameters of ANN implemented in this work. To obtain the best-fitting ANN for the available data and accurately estimate the error for new, unseen samples, the original dataset is divided into three sets: the training set, the validation set, and the test set. The training set comprises data samples used to train the network. The validation set, on the other hand, is crucial for providing an unbiased evaluation of the model and tuning the model's hyperparameters (e.g., number of hidden layers, features in the dataset) set before the network training phase. The information in the validation set indirectly influences the model. Lastly, the test set is essential for the final evaluation of the model. Samples in this set have not been used by the model during training, thus representing unseen situations. Therefore, the test set error is pivotal in selecting the best ANN after training multiple models (Gonzalez, 2020). During training, a significant tool necessitating dataset division is the validation curve. The network undergoes numerous iterations over the training set, progressively adjusting to this data with each epoch. However, a point is reached where the model ceases to generalize and starts to overfit (Bishop, 2006). The validation curve helps identify the optimal number of training epochs, establishing a stopping criterion. Stopping criteria are conditions for halting the training phase, and the validation curve's established criterion is designated as the validation stop. The point where the model stops generalizing aligns with the minimum average error obtained for the validation set, as depicted in Figure 3.17. Beyond this point, the validation error increases, indicating that the ANN is starting to perform worse on unseen 51 samples. In practice, the validation stop criterion is verified when the validation error has increased for a predetermined number of training epochs after reaching this point, this is called early stopping. Figure 3.17: Validation curve. Forward propagation is the process in which the Artificial Neural Network (ANN) takes known features from training samples, processes them sequentially, and computes an output. This is achieved by applying vectorized versions of the equations (3.5 & 3.6) described earlier in section. Starting from the initial layer of the ANN, the output of this layer serves as input for expression (3.5), which calculates the weighted summation of the received values. Subsequently, these calculated values are used as inputs for the subsequent layer. The final step of this iteration involves applying the activation function (expression 3.6) to these inputs, resulting in the computation of the second layer's outputs. This process iterates through the remaining layers until the ANN produces the final value, representing the network's prediction. Once the ANN's output is obtained, the cost function is employed to estimate the prediction error (Gonzalez, 2020). In this dissertation, the selected cost function is Categorical Cross entropy, commonly used in classification tasks. Categorical Cross entropy quantifies the dissimilarity between the true target values 𝑇 and the predicted probabilities or scores 𝑂 generated by the network for each class. Categorical Cross entropy is expressed as: 𝐶𝑎𝑡𝑒𝑔𝑜𝑟𝑖𝑐𝑎𝑙 𝐶𝑟𝑜𝑠𝑠𝑒𝑛𝑡𝑟𝑜𝑝𝑦= −∑𝑇𝑖.log (𝑆𝑜𝑓𝑡𝑚𝑎𝑥(𝑂𝑖)) 𝑛 𝑖=𝑖 (3.12) Here, 𝑇𝑖 represents the true probability distribution (one-hot encoded), and 𝑂𝑖 is the predicted probability for the 𝑖-th class. The summation is carried out over all classes. In the context of neural network training, the Categorical Cross entropy is computed for each training sample, and the average of these individual errors represents the overall error during the forward propagation phase. The goal is to minimize this 52 error through the training process to improve the accuracy of the network's predictions for multiclass classification tasks. The second phase of a training epoch is known as the backward propagation phase. In this phase, the final error is propagated backward through the neural network by considering the impact of each weight on this error. The objective is to distribute the error appropriately among the weights. Subsequently, the weights of the network are adjusted based on their contribution to the total error. To trace back the contribution of each weight to the obtained error, it is essential to calculate the derivatives of the total error with respect to each weight in the ANN. An optimization algorithm is then employed to adapt these parameters. The primary goal of this algorithm is to minimize the cost function, aiming to reduce the disparity between predictions made by the network and the actual values. For this dissertation, the chosen optimization algorithm was Adam. The fundamental concept of Adam (Adaptive Moment Estimation) optimization revolves around dynamically adapting the learning rate for each parameter within the model by considering the historical gradients associated with that parameter. This dynamic adjustment facilitates quicker and more precise convergence compared to fixed learning rate approaches such as stochastic gradient descent (SGD). It combines the advantages of two other popular optimization algorithms: AdaGrad and RMSProp. In practice, Adam optimization calculates a running average of the gradients and the squared gradients for each parameter in the model. It then uses these averages to calculate the update for each parameter during training. In the context of Adam, the network weights are iteratively adjusted using the following expression for a single weight update: 𝑤𝑛𝑒𝑤=𝑤𝑜𝑙𝑑− 𝛼× 𝑚𝑡 √𝑣𝑡+ 𝜀 (3.13) In this expression, 𝑤𝑜𝑙𝑑 represents the original weight, 𝛼 is the learning rate, 𝑚𝑡 is the first moment estimate (like the momentum term), 𝑣𝑡 is the second moment estimate (like the variance), and 𝜀 is a small constant to prevent division by zero. The learning rate 𝛼 influences the magnitude of the weight adjustments, similar to how it does in other optimization algorithms. It scales the update based on the calculated moments 𝑚𝑡 and 𝑣𝑡 . In the realm of classification tasks, evaluating the performance of a model is paramount to ensuring its effectiveness in making accurate predictions. Several key metrics come into play, each tackling on different aspects of the model's predictive abilities. • Accuracy: Accuracy is the measure of correct predictions made by the model, considering both true positives and true negatives. It's a commonly used metric to evaluate classification models. 53 It serves as a foundational metric for assessing the general correctness of the model across all classes. Formula: 𝐴𝑐𝑐𝑢𝑟𝑎𝑐𝑦= 𝑇𝑟𝑢𝑒 𝑃𝑜𝑠𝑖𝑡𝑖𝑣𝑒𝑠+ 𝑇𝑟𝑢𝑒 𝑁𝑒𝑔𝑎𝑡𝑖𝑣𝑒𝑠 𝑇𝑜𝑡𝑎𝑙 𝑂𝑏𝑠𝑒𝑟𝑣𝑎𝑡𝑖𝑜𝑛𝑠 (3.14) • Precision: Precision is the ratio of correctly predicted positive observations to the total predicted positives. It calculates how many of the predicted positives are actually positive. It is vital when false positives need to be minimized, ensuring that the predicted positive instances are indeed accurate. Formula: 𝑃𝑟𝑒𝑐𝑖𝑠𝑖𝑜𝑛= 𝑇𝑟𝑢𝑒 𝑃𝑜𝑠𝑖𝑡𝑖𝑣𝑒𝑠 𝑇𝑟𝑢𝑒 𝑃𝑜𝑠𝑖𝑡𝑖𝑣𝑒𝑠+ 𝐹𝑎𝑙𝑠𝑒 𝑃𝑜𝑠𝑖𝑡𝑖𝑣𝑒𝑠 (3.15) • Recall (Sensitivity): Recall is the ratio of correctly predicted positive observations to all observations in the actual class. It calculates how many of the actual positives our model captures through labelling them as positive. It focuses on minimizing false negatives, crucial in scenarios where missing positive cases is highly undesirable. Formula: 𝑅𝑒𝑐𝑎𝑙𝑙= 𝑇𝑟𝑢𝑒 𝑃𝑜𝑠𝑖𝑡𝑖𝑣𝑒𝑠 𝑇𝑟𝑢𝑒 𝑃𝑜𝑠𝑖𝑡𝑖𝑣𝑒𝑠+ 𝐹𝑎𝑙𝑠𝑒 𝑁𝑒𝑔𝑎𝑡𝑖𝑣𝑒𝑠 (3.16) • F1 Score: The F1 Score is a metric that combines both precision and recall (sensitivity) providing a balance between them. It encapsulates the precision-recall trade-off, making it a valuable metric when false positives and false negatives need to be considered with equal importance. Formula: 𝐹1 𝑆𝑐𝑜𝑟𝑒= 2 × 𝑃𝑟𝑒𝑐𝑖𝑠𝑖𝑜𝑛 × 𝑅𝑒𝑐𝑎𝑙𝑙 𝑃𝑟𝑒𝑐𝑖𝑠𝑖𝑜𝑛+𝑅𝑒𝑐𝑎𝑙𝑙 (3.17) In the machine learning field, two prevalent challenges are often encountered: overfitting and underfitting. Overfitting occurs when the model adjusts too closely to the data and captures the noise present in it, resulting in a failure to generalize the more important patterns of the data set (Haykin, 2009), impacting 54 the performance of the model on new data. This issue arises when the model's complexity exceeds what is necessary for effectively solving the problem (Gupta, 2017). Conversely, underfitting arises when a model inadequately captures the fundamental relationship between inputs and outputs (Koehrsen, 2018). This shortfall is a result of the model's complexity being insufficient for the given problem. The distinction between these problems can be visualized Figure 3.18, where the model's predictions are denoted by the dashed line, and the data samples are marked as green dots. Figure 3.18: Underfitting and overfitting. In dealing with the challenge of overfitting, several key strategies are instrumental in mitigating its effects. Firstly, reducing the model's complexity by decreasing the number of hidden layers and neurons per layer is a crucial step (GeeksforGeeks, 2023). Secondly, employing the validation stop (Early Stopping) criterion during training is an effective measure. This criterion ensures that the ANN stops weight adjustments before the model begins to overfit to the training set. Regularization proves to be another significant approach in addressing overfitting. Lastly, Dropout is a regularization technique used to combat overfitting in neural networks. During training, dropout randomly deactivates a fraction of neurons, meaning they do not contribute to the forward or backward passes. This encourages the network to learn more robust features and prevents heavy reliance on specific neurons. Dropout essentially simulates training several subnetworks, leading to a more generalized model that generalizes better to unseen data. To address underfitting, it's crucial to enhance the model's complexity. This can be achieved by increasing the number of hidden layers and neurons per layer in the neural network (GeeksforGeeks, 2023). Additionally, incorporating higher degree polynomial terms of the input variables can provide the model with the necessary complexity to capture intricate relationships in the data. Moreover, removing noise from the training data and increasing the number of epochs can lead to better results. 55 3.2.3 Dynamic Neural Fields The computational models implemented to achieve online learning and prediction of the mobility routines for the vehicle, covering those of the driver, passengers, and objects, are based on the Dynamic Neural Field theory. The key mathematical equations required to formalize the models are covered in the following subsection, along with an explanation of the ideas and theoretical foundation supporting DNFs. 3.2.3.1 General Introduction Dynamic Neural Fields represent a theoretical framework for modelling cognitive functions inspired by cortical processing mechanisms. It provides means to implement memory, decision-making, planning, adaptation and learning in autonomous robots (Erlhagen & Bicho, 2006; Sandamirskaya et al., 2013; Sousa et al., 2015). In the field of robotics, Dynamical Neural Fields were first utilized by (Schöner et al., 1995) to showcase their benefits in navigation and obstacle avoidance tasks within a behaviour-based vehicle. Following their work, a growing community of researchers has extended the uses of this structure. DNFs have proven effective in a variety of applications ranging from Cognitive Science, widely used in the past to model human cognitive behaviour, to the control of Autonomous Robots (for a more complete overview refer to (Schöner et al., 2015)). DNF models implement the dynamics of recurrently connected neural populations, which are tuned to continuous input features such for instance object features like colour or orientation, and movement parameters such as the direction of heading during navigation, or, as in the present application, spatial coordinates. The recurrent network dynamics may switch due to the presence of external inputs from a homogeneous baseline state to a self-sustained activation peak, that remains in the field in the absence of external input due to strong recurrent excitatory and inhibitory interactions within the population. After cessation of the external input, a localized activation bump represents a memory of a specific value of the encoded dimension. This feature allows models to incorporate cognitive skills that are essential for robot learning to be more intuitive and human-like. These skills include working memory, decision-making, and the ability to learn associations between separate events (Curtis & Lee, 2010). 3.2.3.2 The Amari Equation In 1977, Amari in (Amari, 1977) proposed equation (3.18) to formally represent pattern creation and interaction dynamics within the cortical surface. This equation has found application among robotic researchers aiming to model various cognitive processes like memory, forgetting, detection, and decision- 56 making. Its analytical tractability allows for a reduction in computational complexity, as pointed out by (Bicho et al., 2010). The fundamental premise of this approach, outlined in the General Introduction, underscores the dynamic behaviour within neural aggregations attributed to robust recurrent excitatory and inhibitory interactions in local neural populations. These interactions form a fundamental mechanism for processing and managing information within the cortex. The integro-differential equation below formalizes the dynamics of a one-dimensional field, where 𝑥 and 𝑦 represent positions in parametric space, for 𝑥 ∈ 𝑅 and 𝑦 ∈ 𝑅. Neuronal activity is encapsulated in an activation function, 𝑢(𝑥,𝑡), where 𝑢 denotes the activation of a neuron located at position 𝑥 at time 𝑡. Additionally, a constant parameter 𝜏 > 0 governs the time scale of the field. 𝜏𝜕𝑢(𝑥,𝑡) 𝜕𝑡 = −𝑢(𝑥,𝑡)+ℎ+𝑆(𝑥,𝑡)+𝑐𝑢𝜁(𝑥,𝑡)+∫𝑤(|𝑥−𝑦|)𝑓0(𝑢(𝑦,𝑡))𝑑𝑦 (3.18) The equation can be broken down into a linear component (3.19) and a non-linear component (3.20). To enhance understanding, one can start by examining the linear part. Where, 𝑢(𝑥,𝑡) stands for the neural activation at feature value 𝑥 and time 𝑡. The parameter ℎ < 0 establishes the homogeneous resting level to which neuronal activity subsides in the absence of external input. The external input at parametric position 𝑥 and time 𝑡 is denoted by 𝑆(𝑥,𝑡). 𝑆(𝑥,𝑡) > 0 occurs when information related to the encoded variable within a specific sub-neuronal population is active, indicating excitatory activity triggered by external input. Conversely, 𝑆(𝑥,𝑡) ≤ 0 indicates the absence of the same activity or exhibits inhibitory behaviour. Finally, 𝑐𝑢𝜁(𝑥,𝑡) denotes white Gaussian noise with a strength of 𝑐𝑢. For further insights into the significance of noise in a dynamic system, refer to the Neural Dynamics chapter in (Curtis & Lee, 2010). 𝜏𝜕𝑢(𝑥,𝑡) 𝜕𝑡 = −𝑢(𝑥,𝑡)+ℎ+𝑆(𝑥,𝑡)+𝑐𝑢𝜁(𝑥,𝑡) (3.19) Furthermore, the ability of Amari's equation to model cognitive behaviour stems from its non-linear term, which describes interactions (excitatory and inhibitory interconnections) among sub-neuronal populations within the same field (Erlhagen & Bicho, 2014). ∫𝑤(|𝑥−𝑦|)𝑓0(𝑢(𝑦,𝑡))𝑑𝑦 (3.20) In general, interactions are presumed to be homogeneous, meaning that the strength of the interaction solely depends on the Euclidean distance between any pair of neurons 𝑥 and 𝑦 within the field, expressed 57 as 𝑤(𝑥,𝑦)=𝑤(|𝑥−𝑦|) . These sub-populations of neurons can either stimulate or suppress each other based on the distance between them, Figure 3.19. Figure 3.19: Relations between neurons of the same layer. Populations of neurons closer to the ones at location x are stimulated while others at longer distances are suppressed. Moreover, only neurons with a sufficiently high activation level contribute to the recurrent interactions. The non-linear function 𝑓0(𝑢) is used as a gating function to ensure that only neurons with activity above a specific threshold contribute to the interaction ( 𝑓0(𝑢(𝑦,𝑡))>0 ). It can be taken as the sigmoidal function with steepness parameter 𝜎 > 0 (Equation 3.21) or as the Heaviside step function (threshold value = 0) (Equation 3.22). 𝑓0(𝑢)=1 1+𝑒−𝜎𝑢 (3.21) 𝑓0(𝑢)={1 𝑖𝑓 𝑢>0 0 𝑖𝑓 𝑢≤0 (3.22) 3.2.3.3 Types of Interaction Kernels The kernel term function 𝑤(𝑥 − 𝑦) describes the strength of each interaction, as was previously mentioned. According to the desired type of lateral connection between neurons, the three types of coupling kernel functions (relevant for this dissertation) are described in the following paragraphs (Ferreira et al., 2016). Gaussian kernel with global inhibition In cases where a neural field should only support a single evolving memory bump at a time, in response to multiple external inputs, it requires a specific type of interaction kernel known as 'lateral inhibition'. This type of kernel promotes excitation at closer distances between neurons, while inhibiting each other at greater distances (Figure 3.20) (Amari, 1977). An example of a lateral inhibition kernel is given by the following equation: 58 𝑤𝑙𝑎𝑡(∆𝑥)= 𝑤𝑒𝑥𝑐𝑒𝑒−∆𝑥2 2𝜎𝑒𝑥𝑐𝑒 2−𝑤𝑖𝑛ℎ (3.23) where 𝑤𝑒𝑥𝑐𝑒> 0 and σ𝑒𝑥𝑐𝑒> 0 control, respectively, the amplitude and standard deviation of the gaussian curve, and 𝑤𝑖𝑛ℎ> 0 the constant inhibition strength for distant neurons (Erlhagen & Bicho, 2006). Figure 3.20: Demonstrates that a neuron will trigger excitation in nearby neurons when their distance is less than 𝑥𝑠 . In contrast, inhibition takes precedence with an increasing strength that levels off to a constant intensity at distance 𝑥𝑑 , adapted from (Cunha et al., 2020). As a result, when two subpopulations receive supra-threshold inputs of varying strengths, may engage in competitive dynamics. If the lateral inhibition is strong enough, in general the subpopulation receiving the stronger input will be the one to stabilize a bump pattern (Figure 3.21), which is not always the as we will explain later in this subsection. This forms the core mechanism that enables the skill decision making as will be elaborated in further detail later in this chapter. Figure 3.21: Lateral Inhibition kernel. Cooperation and competition in a neural field. Neurons within the sub-populations that receive external input, denoted as 𝑆 1(𝑥) and 𝑆 2(𝑥) , respectively, mutually stimulate each other. Simultaneously, the interaction between the two subpopulations is mutually inhibitory, adapted from (Cunha et al., 2020). 65 Figure 3.29: Competition in the case of a homogeneous resting state. The decision leans towards the neural population that received the higher excitatory input (indicated by the dotted line), adapted from (Cunha et al., 2020). Figure 3.30: Competition in a field with preshape. Despite the localized input being stronger at site B, due to the prior 'preshaping', it's the neural population at site A that becomes activated, adapted from (Cunha et al., 2020). 3.3 Libraries and Frameworks In this section the open-source libraries and frameworks utilized in this work are presented, providing valuable insights into the technological tools employed. 3.3.1 Front-end development: React Numerous libraries and frameworks are available for front-end development, serving as essential tools for creating web applications. These frameworks are a collection of components designed to streamline the web development process by simplifying common tasks like routing, API interactions, and session management. They are particularly valuable for building dynamic web applications. The most prominent web frameworks for initiating new projects today include React, Angular, and VueJS (Cardoso, 2020). These frameworks offer a comprehensive set of features and functionalities to support developers in 66 creating sophisticated web applications. Presently, ReactJS stands out as the most popular choice for web development projects. It is actively maintained by Meta and a community of skilled developers and companies. Its versatility and widespread adoption have led to a thriving ecosystem of solutions and resources, making it a top choice for many developers. Figure 3.31: npm download stats, (Npm Trends. @angular/Core vs Angular vs React vs Vue, 2023). React's popularity and effectiveness originates from its efficient rendering with the Virtual DOM (Document Object Model), its component-based architecture for code organization and reusability, one-way data binding for better control and debugging, and its compatibility with libraries like Redux, which enhance state management and predictability in JavaScript applications. 3.3.2 Back-end development: Django The Django web development framework (Django Software Foundation, 2019) is designed for creating dynamic web applications using Python. As a full-stack framework, it aims to support most aspects involved in web application development, assisting in the construction of each software layer, including the data layer, business logic layer, and presentation layer that constitute an application. Similar to most full-stack frameworks, Django adopts the Model-View-Controller (MVC) architectural pattern for its applications, although it uses slightly different nomenclature referred to as Model-Template-View (MTV), where the Template and View correspond respectively to the View and Controller in the more widely known MVC pattern (Teixeira, 2018). Django implements the MTV architectural pattern as follows: models.py: This file defines the system's entities (models), consisting of Python classes that represent database tables. These classes enable manipulation and operations such as creation, access, updating, and removal of records using only the Python language. Thus, this file corresponds to a database abstraction layer, allowing its use without leaving the Python programming environment, eliminating the need for the programmer to use SQL. This task is delegated to the Object-Relational Mapping (ORM) 67 technology, which forms the basis of this abstraction layer, mapping Python classes to their respective tables in the database. views.py: This file corresponds to the business logic layer of the application. Views of the system are defined in this file, simply being Python functions that handle one or more http requests arriving at the application, often interacting with models to access the database. urls.py: This file corresponds to the routing functionality of the framework, specifying which view is invoked to handle a request sent to a given URL. Its structure is similar to that of a Map object, establishing the mapping between each URL and the view/function responsible for processing the requests sent to them. Templates: HTML files, or templates, correspond to the presentation layer, representing the visual representation of the application's data and collectively constituting the application's interface. The interface uses a templating engine, allowing the definition of a common model or structure for the entire system interface, which can be dynamically altered. In other words, views can be programmed by including Python code in the HTML, enabling them to adapt to the context in which they are presented. For example, the same page can be used to display bank account movements for different users, or a page can show or hide a specific section depending on whether it is presented to an administrator or a regular user. This is how the Templating Engine contributes to the creation of dynamic web applications. In addition to the MVC architectural pattern, Django also adheres to the "Don't Repeat Yourself" (DRY) principle, encouraging the reuse of software components and rapid development (Teixeira, 2018). To assist in these tasks, there are over 2500 third-party software components easily integrable with Django, allowing for extending the original behavior of the framework. 3.3.3 Facial Biometrics: OpenCV & Face Recognition OpenCV, short for "open-source computer vision," is a versatile library with a primary focus on supporting applications related to computer vision and machine learning. It caters to both academic and commercial applications, offering a wide array of low-level image processing capabilities and high-level algorithms. These algorithms encompass tasks such as face detection, feature matching, and object tracking (Bradski, 2000). Originating from Intel Research Lab, OpenCV was conceived to streamline machine perception and facilitate CPU-intensive processing. It serves as a universal platform for computer vision, boasting a collection of over 2500 optimized algorithms, including the latest developments in the field. In 2010, OpenCV introduced a new module that is continuously evolving. This module enables users to 68 harness the Graphics Processing Unit (GPU) without the need for intricate GPU-level programming. This allows for the concurrent utilization of GPU processing and CPU calculations, resulting in reduced data transfer overhead and improved overall performance. OpenCV is compatible with multiple programming languages, including C/C++, Python, MATLAB, and Java, making it a flexible choice for developing computer vision applications across various operating systems. Whether it's for desktop or mobile platforms, OpenCV supports Windows, Linux, macOS, Android, and iOS. To enhance the capabilities of OpenCV in the realm of face recognition, the python library Face Recognition (face_recognition) was chosen. Face Recognition is built using dlib’s state-of-the-art face recognition built with deep learning, mentioned in the state-of art section 2.6. In addition, this library also has an implementation of the face detection algorithm HOG (Histogram of Oriented Gradients) + Linear SVM (Support Vector Machine). 3.3.4 Data Handling and Visualization: NumPy, pandas & Matplotlib NumPy (Harris et al., 2020) is a specialized matrix processing library primarily used for storing and transmitting data between different algorithms. It offers a wide array of advanced numerical programming tools, including vectorized processing and complex arithmetic operations, making it a highly efficient solution for data manipulation compared to other Python data structures. “pandas” (pandas development team, 2020), on the other hand, is a powerful library known for its high-performance data structures and advanced tools. It is designed to make working with structured data fast, straightforward, and expressive. It simplifies tasks related to data restructuring and allows for seamless aggregation operations. Matplotlib (Hunter, 2007), is a comprehensive library that enables the creation of static, animated, or interactive visualizations and plots in Python. It equips users with a wide range of tools to craft various types of charts, graphs, and figures. These libraries are indispensable for tasks like data manipulation during the preprocessing phase and for extracting and visualizing results effectively. 3.3.5 Scikit Learn Scikit-learn (also known as Sklearn) (Pedregosa et al., 2011) is a machine learning library that utilizes the Python programming language. This library allows the use of various classification, regression, and clustering methods, such as Support Vector Machine, Random Forest, and K-Means, and it offers various 69 preprocessing methods like dimensionality reduction, text transformations, and more. It is designed to interact with numerical Python libraries, such as NumPy and SciPy. Regarding its origin, this library started with the name scikits.learn as a Google Summer of Code project founded by David Cournapeau. Scikit-learn has been adopted by numerous successful brands such as Spotify , Evernote , and Booking.com . It is a robust library that primarily focuses on ease of use, enabling faster machine learning. 3.3.6 TensorFlow & Keras This is a library for numerical computation developed by Google, primarily for "Machine Learning" applications across a wide range of tasks. TensorFlow (Abadi et al., 2015) provides a system for creating and training neural networks to detect, predict, and analyse events. A TensorFlow program consists of two parts: constructing the computational graph and executing the computational graph. A computational graph is a sequence of TensorFlow operations arranged in a graph of nodes. Executing the graph typically involves a training loop (Hao Huang, 2019). Algorithms in TensorFlow are represented as a data flow graph while maintaining state. The data's structure in TensorFlow is represented by tensors. In terms of linear algebra, tensors are generalizations of matrices that consist of a set of primitive values configured in an N-dimensional array. For example, a vector is a tensor with one dimension, a matrix is a tensor with two dimensions, and a stack of matrices is a tensor with three dimensions. TensorFlow can be executed on a CPU (Central Processing Unit), GPU (Graphics Processing Unit), and TPU (Tensor Processing Unit). The TPU was developed by Google and is tailored for TensorFlow. Its goal is to serve as a programmable artificial intelligence accelerator to provide high throughput for inference rather than training. TensorFlow programs tend to run significantly faster on GPUs compared to CPUs, and using a GPU for training is more efficient. Additionally, TensorFlow is now available for Linux, MacOS, Windows, and mobile computing platforms, including Android and iOS. TensorFlow supports distributed computing, allowing parts of the graph to be computed in different processes, which can run on entirely different servers. It can also be used to distribute computation to servers with powerful GPUs and run other algorithms on servers with more memory. Some of the advantages that make TensorFlow stand out compared to other Machine Learning libraries include: • Support for utilizing GPUs for enhanced parallel processing. • Ability to train colossal neural networks with billions of data points. • Providing a high-level API that simplifies the implementation of Machine Learning training. 70 • Support for various optimization functions with automatic differentiation, making it user-friendly. • Support for distributed computing. • An excellent visualization tool called "TensorBoard." Keras (Chollet, 2015) is a high-level neural networks API written in Python. It is designed to be userfriendly, modular, and extensible, allowing developers to build and experiment with neural networks quickly and efficiently. Keras was developed with a focus on enabling easy and fast prototyping of deep learning models. Keras is closely related to TensorFlow in that it can be thought of as an interface or frontend for TensorFlow. This means that Keras can utilize the computational power and scalability of TensorFlow as its backend, while providing a simplified and intuitive API for defining and training neural networks. 3.3.7 ROS - Robot Operating System The Robot Operating System (ROS) (Stanford Artificial Intelligence Laboratory et al., 2018), often abbreviated as ROS, is an open-source robotic middleware. While ROS is not a traditional operating system (OS), it comprises a set of software frameworks designed for robotic software development. It offers services tailored for heterogeneous computer clusters, including hardware abstraction, low-level device control, shared functionality implementation, inter-process message passing, and package management. In ROS-based systems, processes are organized and represented in a graphical architecture. Processing occurs within nodes that can receive, publish, and multiplex data related to sensors, actuators, control, state, planning, and other messages. Despite the crucial need for responsiveness and low latency in robot control, ROS is not a realtime operating system (RTOS) by itself. However, it is possible to integrate ROS with real-time code to meet such requirements (ROSWiki, 2023). ROS provides a flexible and versatile framework for developing robotic software, facilitating communication between various components in a robotic system and enabling the creation of complex robot applications. 71 4 Implementation 4.1 Implementation: Frontend - Backend Interaction To be clear, the goal of this “web application” is just to offer a user interface and allow visualization for the resulting stop locations to provide a better understanding how they were attributed. The authentication part is just to showcase a possible example of interaction between the user and the system. The UML sequence diagram (Figure 4.1) below shows the implemented interactions between user, frontend, backend and database for the registration and login process. After the login process the user can interact with the stop locations displayed in the frontend, as depicted in Figure 4.2. Figure 4.1:Registration and Login Process. 72 Figure 4.2: Interaction with Stop Locations / Clustering results. To achieve this, a specific architectural approach is employed, where React is utilized for frontend management, while Django handles the backend data processing, encompassing the authentication and Stop Location extraction process. To facilitate the connection between these components, a RESTful API is implemented. In this architectural shift, the traditional Django template approach is eliminated, and the Django View component is replaced with the Django REST Framework View to serve the RESTful API. In this context, the architecture follows the Model-View-Serializer (MVS) pattern, where the serializers allow complex data such as query sets and model instances to be converted to native Python datatypes that 73 can then be easily rendered into JSON, XML or other content types. Serializers also provide deserialization, allowing parsed data to be converted back into complex types, after first validating the incoming data. These formats are easily accessible and usable by the frontend, enhancing communication between React and Django. The architecture of the integration of both frameworks, React and Django is depicted in Figure 4.3. Django exports REST APIs using Django REST Framework and interacts with the Database using Django Model. The React Client sends HTTP Requests and retrieves HTTP Responses using Axios, updating the components with the received data. React Router is used for navigating between pages. Figure 4.3: Integration of Django(Backend) with React(Frontend), application architecture. Both frameworks possess commands for project creation, facilitating the initial setup. In a Django project the command “django-admin startproject backend” , will auto-generate some code establishing a collection of settings for an instance of Django, including database configuration, Django-specific options and application-specific settings. For React the command is “npx create-react-app frontend” . Django’s command generates the directory “ backend” and its contents as depicted in Figure 4.4 - Left. The next step is to create an “ app” . In Django, an "app ” refers to a self-contained module that encapsulates a specific functionality or a set of related functionalities within a larger Django project. A Django project is the entire web application, while apps are individual components that contribute to the project's overall functionality. 74 Figure 4.4: Django base project directories created. In this case the "app ” is mainly an authentication app and it will be responsible for user registration, login, and authentication, and in addition it will be responsible for handling the GPS data produced by the user. The command used for this is “ python manage.py startapp api” , generating the “api” directory and respective files Figure 4.4 - Right. Similarly, the React command also creates a directory with different files for configuration (see Figure 4.5). Figure 4.5: React base project directories created. These are the skeleton or base projects with no immediate functionality, changes to existing files and creation of new ones are needed. In the Django side, the key changes are located inside the api directory. In the “models.py” file, a custom User database table is defined to include the fields regarding the face biometrics and trip information (see Figure 4.2 User Attributes Table). In the “ views.py” file, a set of API views and endpoints were implemented to register and login a user and allow him to manage and interact with a geographic clustering algorithm. 81 ALGORITHM 2: KMEANS +SILHOUETTE CLUSTERING Input: data_scaled (scaled data), clustering_params (parameters for KMeans) Output: Dataset with stop location labels, centroids of destinations Step 1: Determine the optimal number of clusters using the Silhouette Method 1 Initialize best_score to -1 //Silhouette Method Minimum Score 2 Initialize best_k to 0 //For tracking best number of clusters 3 For k in range(2 to 20): // 20 is an arbitrary limit for number of clusters 4 Create a KMeans model with k clusters 5 Fit the model to the scaled data 6 Calculate the Silhouette score for the clustering 7 If the score is worse than best_score for 2 consecutive iterations: 8 Break For cycle 9 end 10 If the score is better than best_score: 11 Update best_score with the current score 12 Update best_k with the current k 13 end 14 end Step 2: Perform KMeans clustering with the best number of clusters (best_k) 15 Create a KMeans model with best_k clusters 16 Fit the model to the scaled data Step 3: Set clustering information 17 Save the corresponding stop location labels for each individual stop point in the dataset 18 Create a dictionary with the centroids (centre points) of each cluster 19 Create a dictionary to store the names of destinations (initialized as empty strings) 20 Set the centroids of destinations 21 end Preliminary Results of Initial Clustering The K-Means algorithm requires only the parameter 𝑘 to be defined, which is dynamically attributed by the silhouette method. On the other hand, HDBSCAN requires multiple parameters, such as, the minimum size of clusters ( min_cluster_size ). Clusters resulting from single linkage splits that contain 82 fewer points than this specified size are considered as points "falling out" of a cluster, rather than a cluster splitting into two new clusters. Another crucial parameter is the distance threshold ( cluster_selection_epsilon ), where clusters below this value will be merged. After multiple trials the best performing parameters were min_cluster_size : 8 and cluster_selection_epsilon : 0.05. Bellow the results for the dataset, illustrated in Figure 3.4, are presented (Figure 4.11). In an ideal scenario, where the algorithms could achieve perfect performance, we would expect them to discover 17 distinct stop locations in this vehicle’s dataset. Note that in the illustrations the tear drop markers represent stop locations while the circle markers represent stop points. Figure 4.11: Clustering Results: HDBSCAN – Left and K-Means – Right. HDBSCAN identified 15 out of the 17 possible stop locations, considering the remaining data as outliers and noise. This is an impressive result at first glance. However, only 6 are correct, mainly due to two distinct stop locations that the algorithm erroneously interpreted as eight separate destinations (Figure 4.12). This is not surprising, as it can be extremely challenging for both an algorithm and a person with no prior knowledge of the dataset to correctly associate these eight centroids. This situation exemplifies what was mentioned in section 1.1, where a user may park in multiple locations before heading to a single destination. Additionally, many stop locations were considered noise (indicated by the question marks in Figure 4.11 - Left). This is reasonable as these less frequently visited locations do not achieve the necessary density to form a cluster. One can argue that reducing min_cluster_size value or increasing the cluster_selection_epsilon value would solve the issue, but this might lead to excessively fragmented clusters (where every pair of points can be considered a cluster, see Figure 4.13 -Right) or the grouping of multiple compact clusters into larger ones (Figure 4.13 - Left). However, while the algorithm only 83 correctly identified six locations, it's important to note that it could potentially benefit from a larger dataset to achieve better results. On a different note, although it wasn't the primary goal of this work, we can leverage the outlier and noise detection capabilities of the algorithm to remove the more sporadic stop locations from a user's routine (e.g., dentist appointments, visiting a friend), as these are typically not considered part of their regular routine visits. Figure 4.12: HDBSCAN clustering: Left - Incorrectly assigned Stop Locations; Right - Correct attribution of clusters. Figure 4.13: HDBSCAN clustering: Left - Exaggerated high parameter cluster_selection_epsilon; Right- Exaggerated low parameter min_cluster_size. In this case, compared to HDBSCAN, the combination of K-Means with the Silhouette method achieves slightly better results than HDBSCAN. It successfully identifies 8 correct stop locations out of the 12 that were uncovered. However, it still falls short of the correct 17 locations. The remaining clusters generally group two or more stop locations into one, as illustrated in Figure 4.14. This happens because K-Means tends to form spherical clusters, and the nature of the data might not conform perfectly to these shapes. Additionally, less populated stop locations tend to be grouped with a vastly populated destinations, as shown in Figure 4.14 as well. In terms of runtime, both algorithms are similar due to the fact that K-Means needs to run several times to determine the best 𝑘 parameter. However, when it comes to parameter selection, HDBSCAN is more challenging and less intuitive, making it harder to optimize on the fly and dynamically. Considering that we intend to use all the samples in the dataset, including even the sporadic visits, we won't need the 84 outlier detection feature of HDBSCAN. Moreover, given K-Means’ relatively good performance and simplicity, we have adopted it as the clustering algorithm for this specific case. Figure 4.14: K-Means with Silhouette: Points located in Supermarket (bottom left) and Doctor (upper right) are attributed to the same cluster as School (bottom right) due to the proximity and difference in number of visits favouring the school. 4.3.1.3 Cluster Rearranging with User Feedback The tests conducted reveal that it's extremely challenging to find a set of parameters for these algorithms that would flawlessly identify all locations correctly without additional contextual information. Therefore, to address this issue, a practical solution was implemented. This solution involves allowing minimal user interaction through split and merge commands while keeping the user experience as smooth as possible. The concept is to execute instances of the clustering algorithm solely on the data that was initially assigned incorrectly. This process aims to either correct the stop locations or merge them if they were wrongly separated during the initial inference. To facilitate this user interaction, fields, as shown in Figure 4.15, were incorporated into the user's dashboard in the frontend. These fields enable the user to input the ID(s) of the location(s) that require adjustments, such as splitting or merging. This way, the user can actively participate in enhancing the accuracy of the stop location extraction. In addition, the user can name the stop locations. Figure 4.15: Dashboard fields to allow user interaction. 85 This straightforward solution has proven to be quite effective in many cases. For instance, the scenario presented in Figure 4.14 is easily solved with a single use of the split command (Figure 4.16). However, situations like the one in Figure 4.12 may require additional merging commands to achieve correct clusters (Figure 4.17). The latter scenario might be a bit more demanding for the user in terms of corrections. The user’s feedback allows for gradual and continuous refinement of the stop location extraction process. This approach ensures that the system becomes more accurate and tailored to the user's habits and preferences. Figure 4.16: K-Means with Silhouette: Results after a single split command. Figure 4.17: K-Means with Silhouette: Results after splitting command followed by merging. 4.3.2 Online Phase In the online phase, after each adjustment made to the identified stop locations, a new ANN is trained and subsequently deployed within the ROS node. This regular update enables the system to perform realtime inference on incoming travel events, providing essential support to the cognitive module's learning and recall processes. Similar to the offline phase, there will be a data processing step where the dataset generated during the offline phase (comprising GPS data and corresponding labels) will be subjected to manipulation. Following this, the process will involve model selection, fine-tuning, training, and eventual deployment. 86 4.3.2.1 Data Processing In the online phase, first we extract the unique labels (destinations) from the dataset. The number of unique labels is equal to the number of output neurons in the neural network. Then the raw features (Latitude and Longitude) are extracted from the dataset, processed and then and used as input for the ANN (see Figure 4.18). Figure 4.18: Stop Location Extraction Online Phase - Data processing pipeline. Random oversampling is then applied to combat class imbalance. The random oversampling step is crucial in handling class imbalance. When a dataset is imbalanced, the model might be biased toward the majority class, leading to poor performance on minority classes. Random oversampling increases the representation of underrepresented classes in the dataset by creating additional copies of the minority class samples, thus improving the model's ability to learn from all classes effectively. Subsequently, the resampled data is split into training (used as training and as validation with k-fold cross validation) and test sets, which are further used for model training and evaluation. Finally, the data is scaled to ensure that the features are on the same scale, which aids in the convergence of machine learning algorithms and prevents features with larger scales from dominating the training process. When applying the scaler, it is crucial to fit it only on the training data (using the Fit method form scikit-learn). This ensures that the scaler learns the scaling parameters (e.g., min and max values for Min-Max scaling) based on the training data distribution. The scaling is then applied to the training data and the test data using the fitted scaler. This transformation ensures that the scaling applied to the test data is consistent with the scaling used on the training data, preventing data leakage. Data leakage can occur when information from the test set unintentionally influences the preprocessing or model training, leading to overly optimistic evaluation results. To prevent this, the scaler should only be fitted on the training data, and the same scaler should be applied to both the training and test data to maintain consistency. The parameters of the scaler (e.g., minimum, and maximum values for Min-Max 87 scaling or mean and standard deviation for Standardization) are used later for scaling new, unseen data during the model deployment phase. 4.3.2.2 ANN Model Development The feed-forward ANN is built using TensorFlow and Keras and designed to accommodate hyperparameter tuning for optimal model performance, making use of Sequential() method that is available. With this method the model is constructed as a sequential neural network, which means that it consists of a linear stack of layers. Data flows sequentially through these layers, explained bellow. Input Layer: The model commences with an input layer configured to accept data with two features, Latitude and Longitude. This layer serves as the entry point for the input data. Hyperparameter Tuning (Hyperband): The neural network model is amenable to hyperparameter tuning, a crucial aspect of optimizing its performance. Hyperband is employed as the hyperparameter tuning method. It is a state-of-the-art optimization technique that efficiently explores the hyperparameter space. By leveraging bracketed competitions and adaptive resource allocation, Hyperband intelligently selects and evaluates a variety of hyperparameter configurations, accelerating the discovery of optimal model settings. The following hyperparameters can be tuned: • Number of Dense Layers (Hidden Layers): The specified range for the number of hidden layers is between 1 and 5. • Number of Units in Dense Layers: The specified range for the number of units(neurons) in layers is between 32 and 512 with a step of 32. • Dropout Rate: The specified range for the dropout rate for each dense layer is between 0.1 and 0.5 with a step of 0.1. • Dense Layers with ReLU Activation: For each hidden dense layer, Rectified Linear Unit (ReLU) activation is used. Dropout Layers: Dropout layers are added after each dense layer to prevent overfitting. Output Layer: The output layer is a dense layer with a softmax activation function. This is suitable for multi-class classification tasks, as it outputs probabilities for each class. 88 The model is compiled with the optimizer (Adam) and has ('sparse_categorical_crossentropy') as the loss function, which is appropriate for multi-class classification. The accuracy metric is used to evaluate model performance during training. Model Training, Validation and Evaluation: The model is trained and validated using k-fold cross-validation (Figure 4.19), a robust technique that partitions the dataset into '𝑘' subsets or folds. This approach ensures comprehensive model validation by iteratively training the model on '𝑘−1' folds and validating it on the remaining fold. This process is repeated '𝑘' times, with each fold serving as the validation set exactly once. The results of each model created are then averaged to provide a more reliable estimate of the model's performance, reducing the impact of variations in the training and validation data splits. K-fold cross-validation aids in producing a more generalizable model and helps detect overfitting or underfitting issues. This validation method is used to run different sets of hyperparameters and consequently extract the best performing hyperparameters at the end. The best performing model will be then submitted to a final evaluation on the test data. The performance metrics used were, accuracy, recall, precision, and f1-score as previously discussed, along with confusion matrixes to provided visualization of the model performance. On a final note, in the training of every model “stop_early” method was used as an additional tool to prevent overfitting. Figure 4.19: K-Folds Workflow, adapted from scikit-learn. 89 Figure 4.20: ROS communication between the Stop Location Extraction module and Cognitive module. Finally, the best performing model parameters and relevant information, such as the data scaling parameters are saved, and loaded to a ROS node acting as a service server (“/clustering_dl_service”) communicating with the cognitive module node (service client named - “/engine”) through a custom service “/get_stop_location” as depicted in Figure 4.20. 4.4 Integration: User Routine Learning Cognitive Module In this subsection, we explain the general functioning of the DNF model. A complete overview of this the framework and respective mathematical formulation and parameter values used can be found in (Guimarães et al., 2023). It also provides an illustrative example considering the trajectory of a vehicle during a certain weekday. The same processing principles apply to all associated entities (drivers, passengers, and objects). 4.4.1 DNF Model description In Figure 4.21 the cognitive model architecture is depicted. It consists of two main parts covering the learning and the recall of routines. The distinct functional role of each of the seven neural fields is determined by the excitatory and inhibitory connections they establish with other fields. These connections are denoted with Roman numerals. The one-dimensional fields are segmented into discrete, nonoverlapping intervals or slots, each representing different stop locations (illustrated using various colours in Figure 4.21). As the clustering algorithm identifies new stop locations, the number of intervals increases accordingly. The length of each interval is deliberately chosen to accommodate scenarios where multiple peaks emerge within a single slot due to repeated visits to a particular stop location throughout the day. The learning process begins with the first departure event, which triggers the formation of a selfsustained activation peak in the Spatial Encoding field 𝒖𝒔𝒆. Driven by excitatory connections (i) this leads to the development of a corresponding peak in the Spatio-Temporal Encoding field 𝒖𝒔𝒕𝒆. Over the course 90 of the day, the peak's amplitude continually increases due to linear resting state dynamics 𝒉𝒔𝒕𝒆for field sites with suprathreshold activity. As a result, multiple peaks form in 𝒖𝒔𝒕𝒆, each representing different event memories, with their amplitudes encoding relative timing information. The Consolidation field 𝒖𝒄 controls the transfer of spatio-temporal information from 𝒖𝒔𝒕𝒆 to the Memory field 𝒖𝒎 through excitatory connections (ii). Memory traces of traveling events accumulate in 𝒖𝒄 via localized excitatory input (iii) when corresponding suprathreshold patterns exist in 𝒖𝒔𝒆. When the accumulated activity of the memory traces reaches level 𝟎, the combined input from 𝒖𝒔𝒕𝒆 and 𝒖𝒄 drives the neural representation in 𝒖𝒎. If the memory trace weakens below 𝟎, the peak in 𝒖𝒎 destabilizes, leading to decay in both fields (forgetting process). In a second role, activity above 𝟎 in 𝒖𝒄 inhibits corresponding sites in 𝒖𝒔𝒆 through connections (iv). This feedback inhibition prevents interference with previously learned memories when new inputs represent repeated visits to the same location, resulting in the formation of peaks at different positions. Figure 4.21: Architecture of the cognitive model, adapted from (Guimarães et al., 2023). 97 features of stop locations for clustering. This complexity also poses a significant challenge for the classification module in distinguishing between them. This also happens for vehicle 4. Table 5.1: Vehicle Models and Results for the ground truth data. 98 Figure 5.5: Vehicle 2 model’s confusion matrix, obtained from the ground truth data. Figure 5.6: "Hospital", "Supermarket" and "Shopping1" Locations. From the vehicle's perspective, we can argue that it is sufficient to know where to pick up and drop off the user. In this regard, the results from the developed Stop Extraction module are quite satisfactory. However, when considering user assistance, the system may fall short. For instance, if a user goes to the same shopping mall for grocery shopping and for the gym, the items they carry will vary (for example, they might take a gym bag when going to the gym and reusable shopping bags when visiting the 99 supermarket). The feature responsible for reminding the user of missing items on specific days and trips to different destinations will struggle to accurately learn the associations between visits and the items carried. That being said, addressing this aspect will be a priority for future iterations of the project. Another aspect that is important to note is that for the learning rate a fixed value of 0.0001 was chosen. The reason for this was that the model “converges” better (see Figure 5.7), which means that it has reached a state where it has learned the underlying patterns in the training data and no longer significantly improves its performance on the training dataset, which is visualized in the resulting learning/training curves, which are smother with a lower learning rate value. A higher value, such as 0.01 (see Figure 5.8) translates into a worse convergency leading to curves with multiple peaks, making it harder to understand if the model correctly converged. A downside to a lower learning rate is the need for increased number of epochs. In addition, we can evaluate if the model is starting to overfit the data, as the case seen in Figure 5.8 where the validation loss is starting to increase from epoch 15 to 16 right before the training process ends, which is a clear sign of overfitting. Figure 5.7: Learning/Training Curves for vehicle 1 ANN model for a learning rate of 0.0001. 100 Figure 5.8: Learning/Training Curves for vehicle 1 ANN model for a learning rate of 0.01. 5.2 Cognitive Module Performance Considering that each day of the week follows a distinct sequence of traveling events, we assess the cognitive model's performance for each day of the week based on two criteria: (1) The vehicle model's ability to predict departure and arrival events (where and when). (2) The performance of associated models in predicting the status of the driver, passengers, and objects on accurately predicted events. The evaluation begins from the third week onwards, using a threshold of 𝑛 = 2, where 𝑛 is the minimum number of consecutive repetitions required for an event to define routine behavior. To assess (1), we calculate the precision, recall, and F1-scores for each day of the week. To determine the correctness of a prediction, we employ a set of criteria that must be met: • The actual event's location must correspond to the predicted stop location (cluster). • The actual event's timestamp should fall within the predicted event's time window (45 minutes, in this case a 30-minute temporal anticipation and a 15-minute tolerance). • Both the actual and predicted events must take place on the same day. • The predicted event type (departure or arrival locations) should match the actual event type. 101 For the assessment of (2), the focus shifts to the accurate predictions determined in (1). We then scrutinize whether the predicted passenger status, driver status, and object status align with their real counterparts. This examination is repeated for each day ( D ), and it entails calculating the ratio of correctly predicted statuses to the total number of correctly predicted events. Results for (P1): Predicting the Travelling Event of Vehicle 2 Days Precision Recall F1-Score MON 83 84.9 83.9 TUE 91.3 92.7 92 WED 84.8 75 80 THU 86 81 83.3 FRI 88.9 94.9 91.8 SAT 0 0 0 SUN 44.4 44.4 44.4 Table 5.2: Results for (P1): Predicting the Travelling Event of Vehicle 2. Results for (P2): Predicting the status of driver, passengers and objects of Vehicle 2 Days Driver Passengers Objects MON 100 86,3 87,7 TUE 100 100 100 WED 100 87,2 87,2 THU 100 92,4 93,5 FRI 100 98.2 96.4 SAT ---- ---- ---- SUN 100 100 87,5 Table 5.3: Results for (P2): Predicting the status of driver, passengers and objects of Vehicle 2. 102 Figure 5.9: Predicted and real arrival events. Three consecutive Wednesdays from vehicle 2 are shown. The model predictions track a routine change for an event that usually occurs around 5:50 PM, where the arrival location changes from stop location Shopping 2 to Shopping 1. 103 Table 5.2 and Table 5.3 depict the performance results for (1) and (2), respectively. The comparison of the different scores in Table 5.2 reveals that the DNF cognitive model detects different levels of regularity in the traveling behavior depending on the day. In vehicle 2 the recurrence of traveling patterns on weekdays is generally high, resulting in F1-scores in the range of 80% to 92%. In Figure 5.9, we can observe the primary causes of prediction errors, specifically related to arrival events, in the context of significant alterations in the routine of vehicle 2. The figure demonstrates that, beginning on day 24, there was a change in the arrival event around 5:50 PM, transitioning from stop location Shopping 2 to Shopping 1. The model continues to predict the previous location on days 24 and 31 but effectively adjusts to the new behavior, as evidenced by the accurate prediction on day 38. We can also note in day 31 that some sporadic behaviour occurred during the morning. As this behaviour was not repeated two consecutive weeks it will not be learned, but still contributed negatively to the performance of the cognitive system in this weekday, although this behaviour is expected from the cognitive module. As expected, the recorded data reveal that vehicle trajectories on weekends display more variability in destinations when compared to weekdays. This increased variability is likely attributed to the reduced temporal constraints and more relaxed routines typically associated with weekends. Notably, the Saturday trajectories of vehicle 2 represent an extreme case where no alignment in space and time of traveling events was observed over two consecutive weeks. This absence of alignment resulted in an F1- score of 0%. The results presented in Table 5.3 demonstrate the DNF model's ability to effectively anticipate the status of the driver, passengers, and objects, for events correctly predicted in (1). The driver prediction exhibits the highest level of accuracy, suggesting a strong association between regular events and specific drivers. Driver changes within a single day are relatively infrequent. Predictions for passengers and objects, while slightly less precise, still achieve a high success rate. Occasional inaccuracies arise in scenarios such as when a scheduled passenger with associated objects is absent due to unforeseen circumstances or when a new passenger unexpectedly joins a trip. 104 6 Conclusion and Future Work This dissertation proposes a module to extract stop locations from stop points, which was tested in data collected from 5 vehicles routines. The module entails an offline phase where the user is able to provide feedback to correct stop locations that are incorrectly attributed and an online phase that classifies the incoming traveling events into stop locations. This stop location extraction module was integrated in a cognitive module for learning and predict user’s routines. The cognitive module uses a framework which had been previously developed by Guimarães in (Guimarães et al., 2023). The framework is based on the DNF approach. The model is capable of learning and memorizing both the ordinal (sequence order of the visits) and temporal properties of a vehicle, including all its different driver, passenger, and object routines. The learning is continuous for the cognitive module, happens implicitly, which means that it adapts to changing driver habits including regularly transported passengers and objects without driver feedback, and is adaptable to different time scales (e.g., hours, days, or weeks). The results obtained during the testing of the stop location extraction module are overall satisfactory with the one of drawbacks being the varying number of rectifying actions needed to obtain the correct stop locations. The occasional struggle in the classification model to discriminate location that are physically close, was also a limitation. This was later solved by expanding the range of number of neurons and layers for the hyperparameter tuner, always considering the overfitting problem by analysing the training curves to verify its existence. One limitation in this module was its inability of the cluster algorithm to discriminate the case of one vehicle being parked in same spot while the user visit’s multiple locations. Nevertheless, it is imperative to note that without extra information the resolution of this predicament remains elusive. The cognitive module was an already tested framework and the integration of both modules produced very good results. The performance evaluation summarized in Table 5.2, with F1-scores in the range of 80% to 92% for the weekdays for vehicle 2, which was the dataset that posed a bigger challenge. In the context of vehicle trips, prediction errors occur primarily when there is an unusual, isolated deviation from the usual routine. The learning mechanism based on neural activations within the DNFs models allows for quick adaptation in cases where prediction failures are recurrent or when an established routine needs to incorporate a new destination. This means that the advantage of correcting the stop location offered by the newly developed module for stop location extraction does not translate into improved prediction accuracy by the cognitive module when compared to the already developed DNF clustering approach, obtaining virtually similar 105 results. The reason for this is that the majority of incorrectly attributed stop locations are rarely visited or sporadic events and are merged into stop locations frequently visited. The learning module is able to forget this rare and sporadic events, removing them from the routine, so it doesn’t constitute an error for the final cognitive module predictions in the long run. However, the new stop location extraction module is able to obtain much more accurate final stop locations by allowing the user in the learning loop and lets the user to visualize in what stop locations the algorithm’s predictions are based resulting in enhanced interpretability of predictions generated by the cognitive module, which constitute advantages over the prior implementation. 6.1 Future Work Despite having achieved the proposed objectives for this dissertation and obtaining good results, there is still room for more work to be carried out. Mainly regarding the problem of a user parking in the same spot to visit multiple locations, an extension of the vehicle in the form of a mobile app can be created to endow the vehicle with additional context of the visit to solve the issue. This also implies more effort would be needed towards user data protection in the scope of this project. In addition, a module in the vehicle or a mobile app can be developed, using the information (Outputs) provided by the cognitive module and provide actual assistance to the user, such as notifying the user about upcoming events, making use of Generative AI to accomplish this. 106 7 References Abadi, M., Agarwal, A., Barham, P., Brevdo, E., Chen, Z., Citro, C., Corrado, G. S., Davis, A., Dean, J., Devin, M., Ghemawat, S., Goodfellow, I., Harp, A., Irving, G., Isard, M., Jia, Y., Jozefowicz, R., Kaiser, L., Kudlur, M., … Zheng, X. (2015). TensorFlow: Large- Scale Machine Learning on Heterogeneous Systems . http://tensorflow.org/ Ahonen, T., Hadid, A., & Pietikainen, M. (2006). Face Description with Local Binary Patterns: Application to Face Recognition. IEEE Transactions on Pattern Analysis and Machine Intelligence , 28 (12), 2037–2041. https://doi.org/10.1109/TPAMI.2006.244 Amari, S. (1977). Dynamics of pattern formation in lateral-inhibition type neural fields. Biological Cybernetics , 27 (2), 77–87. https://doi.org/10.1007/BF00337259 Andrade, T., Cancela, B., & Gama, J. (2019). Discovering Common Pathways Across Users’ Habits in Mobility Data. Progress in Artificial Intelligence: 19th EPIA Conference on Artificial Intelligence, EPIA 2019, Vila Real, Portugal, September 3–6, 2019, Proceedings, Part II , 410–421. https://doi.org/10.1007/978-3-030-30244- 3_34 Arkin, & R. C. (2000). Behavior-Based Robotics (Intelligent Robotics and Autonomous Agents). A Bradford Book. Arraz C. (2021). Algoritmos de Clustering para Identificação de Subtipos de Cancro do Estômago, Tiroide e Pele . Universidade do Minho Escola de Ciências. Arthur, D., & Vassilvitskii, S. (2007). K-Means++: The Advantages of Careful Seeding. Proceedings of the Eighteenth Annual ACM-SIAM Symposium on Discrete Algorithms , 1027–1035. Babiloni, F., Marras, I., Kokkinos, F., Deng, J., Chrysos, G., & Zafeiriou, S. (2021). Poly- NL: Linear Complexity Non-local Layers with Polynomials. CoRR , abs/2107.02859 . https://arxiv.org/abs/2107.02859 Bao, J., Zheng, Y., Wilkie, D., & Mokbel, M. (2015). Recommendations in location-based social networks: a survey. GeoInformatica , 19 (3), 525–565. https://doi.org/10.1007/s10707-014-0220-8 Barbosa P. (2021). Dynamic neural system for endowing intelligent cars with the ability to learn their occupants’ routines . Universidade do Minho Escola de Ciências. 113 (2015). An Empirical Evaluation of Deep Learning on Highway Driving. CoRR , abs/1504.01716 . Jain, A. K., Murty, M. N., & Flynn, P. J. (1999). Data Clustering: A Review . Jain, V., & Learned-Miller, E. (2010). FDDB: A Benchmark for Face Detection in Unconstrained Settings (Issue UM-CS-2010-009). Jin, D., Peng, J., & Li, B. (2011). A New Clustering Approach on the Basis of Dynamical Neural Field. Neural Computation , 23 (8), 2032–2057. https://doi.org/10.1162/NECO_a_00153 Johnson, J. S., Spencer, J. P., Luck, S. J., & Schöner, G. (2009). A Dynamic Neural Field Model of Visual Working Memory and Change Detection. Psychological Science , 20 , 568–577. https://api.semanticscholar.org/CorpusID:15505696 Ke, Q., Liu, J., Bennamoun, M., An, S., Sohel, F., & Boussaid, F. (2018). Chapter 5 - Computer Vision for Human–Machine Interaction. In M. Leo & G. M. Farinella (Eds.), Computer Vision for Assistive Healthcare (pp. 127–145). Academic Press. https://doi.org/https://doi.org/10.1016/B978-0-12-813445-0.00005-8 Kjeldsen, R., & Kender, J. (1996). Finding skin in color images. Proceedings of the Second International Conference on Automatic Face and Gesture Recognition , 312–317. https://doi.org/10.1109/AFGR.1996.557283 Koehrsen, W. (2018). Overfitting vs. underfitting: A conceptual explanation . https://towardsdatascience.com/overfitting-vs-underfitting-a-conceptual- explanation-d94ee20ca7f9 Kumar, A., Kaur, A., & Kumar, M. (2018). Face detection techniques: a review. Artificial Intelligence Review , 52 , 927–948. https://api.semanticscholar.org/CorpusID:254236157 Kun, A. L. (2018). Human-machine interaction for vehicles: Review and outlook. In Foundations and Trends in Human-Computer Interaction (Vol. 11, Issue 4, pp. 201– 293). Now Publishers Inc. https://doi.org/10.1561/1100000069 Kurfess, T. R. (2005). Robotics and automation handbook . CRC Press. Kurrek, P., Zoghlami, F., Jocas, M., Stoelen, M., & Salehi, V. (2020). Q-Model: An Artificial Intelligence Based Methodology for the Development of Autonomous Robots. Journal of Computing and Information Science in Engineering , 20 (6). https://doi.org/10.1115/1.4046992 114 Laing, C. R., Troy, W. C., Gutkin, B., & Ermentrout, G. B. (2002). Multiple Bumps in a Neuronal Model of Working Memory. SIAM Journal on Applied Mathematics , 63 (1), 62–97. https://doi.org/10.1137/S0036139901389495 Leite, J. R., Oliveira, M., João, U., & Leite, R. (2013). Spatio-temporal SNN: Integrating Time and Space in the Clustering Process [Master Thesis]. Universidade do Minho Escola de Engenharia. Li, J., Wang, Y., Wang, C., Tai, Y., Qian, J., Yang, J., Wang, C., Li, J.-L., & Huang, F. (2018). DSFD: Dual Shot Face Detector. CoRR , abs/1810.10220 . http://arxiv.org/abs/1810.10220 Li, S. Z., & Jain, A. K. (Eds.). (2011). Handbook of Face Recognition, 2nd Edition . Springer. https://doi.org/10.1007/978-0-85729-932-1 Liu, C., & Wechsler, H. (2002). Gabor feature based classification using the enhanced fisher linear discriminant model for face recognition. IEEE Transactions on Image Processing , 11 (4), 467–476. https://doi.org/10.1109/TIP.2002.999679 Luo, T., Zheng, X., Xu, G., Fu, K., & Ren, W. (2017). An improved DBSCAN algorithm to detect stops in individual trajectories. ISPRS International Journal of Geo-Information , 6 (3). https://doi.org/10.3390/ijgi6030063 MacQueen, J. (1967). Some methods for classification and analysis of multivariate observations . https://api.semanticscholar.org/CorpusID:6278891 Maimon, O., & Rokach, L. (2010). Data Mining and Knowledge Discovery Handbook, 2nd ed . McArdle, G., Tahir, A., & Bertolotto, M. (2012). SPATIO-TEMPORAL CLUSTERING OF MOVEMENT DATA: AN APPLICATION TO TRAJECTORIES GENERATED BY HUMANCOMPUTER INTERACTION. ISPRS Annals of the Photogrammetry, Remote Sensing and Spatial Information Sciences , I–2 , 147–152. https://doi.org/10.5194/isprsannals-I-2-147-2012 McCulloch, W. S., & Pitts, W. (1943). A logical calculus of the ideas immanent in nervous activity. The Bulletin of Mathematical Biophysics , 5 (4), 115–133. https://doi.org/10.1007/BF02478259 McInnes, L., Healy, J., & Astels, S. (2017). hdbscan: Hierarchical density based clustering. The Journal of Open Source Software , 2 (11), 205. https://doi.org/10.21105/joss.00205 115 Minsky, M., & Papert, S. (1969). Perceptrons: An Introduction to Computational Geometry . MIT Press. Mitchell, T. M. (1997). Machine learning (Vol. 1, Issue 9). McGraw-hill New York. Montini, L., Rieser-Schüssler, N., Horni, A., & Axhausen, K. W. (2014). Trip Purpose Identification from GPS Tracks. Transportation Research Record , 2405 , 16–23. npm trends. @angular/core vs angular vs react vs vue . (2023). https://www.npmtrends.com/@angular/core-vs-angular-vs-react-vs-vue OpenAI. (2021). ChatGPT: OpenAI’s GPT-3.5 Powered Language Model . pandas development team, T. (2020). pandas-dev/pandas: Pandas . Zenodo. https://doi.org/10.5281/zenodo.3509134 Parkhi, O. M., Vedaldi, A., & Zisserman, A. (2015). Deep Face Recognition. British Machine Vision Conference . https://api.semanticscholar.org/CorpusID:4637184 Patel, A. R., Ferreira, F., Monteiro, S., Silva, A. C., Erlhagen, W., & Bicho, E. (2021). Prediction of attitudes towards human-centred cognitive vehicles aware of their users’ routines and preferences. 6th International Forum on Research and Technology for Society and Industry, RTSI 2021 - Proceedings , 194–199. https://doi.org/10.1109/RTSI50628.2021.9597265 Pedregosa, F., Varoquaux, G., Gramfort, A., Michel V. and Thirion, B., Grisel, O., Blondel, M., Prettenhofer P. and Weiss, R., Dubourg, V., Vanderplas, J., Passos, A., Cournapeau, D., Brucher, M., Perrot, M., & Duchesnay, E. (2011). Scikit-learn: Machine Learning in Python. Journal of Machine Learning Research , 12 , 2825– 2830. Pinto, J. R. (2022). Seamless Multimodal Biometrics for Continuous Personalised Wellbeing Monitoring. In Doctoral thesis presented and approved on the 21st of December 2022 to the University of Porto . https://doi.org/https://doi.org/10.48550/arXiv.2301.03045 Pirim, H., Ekşioglu, B., Perkins, A. D., & Yüceer, Ç. (2012). Clustering of high throughput gene expression data. In Computers and Operations Research (Vol. 39, Issue 12, pp. 3046–3061). https://doi.org/10.1016/j.cor.2012.03.008 Pölitz, C., Andrienko, G., & Andrienko, N. (2010). Finding Arbitrary Shaped Clusters with Related Extents in Space and Time. In Joern Kohlhammer & Daniel Keim (Eds.), 116 EuroVAST 2010: International Symposium on Visual Analytics Science and Technology . The Eurographics Association. Ramos, É. M. S., Bergstad, C. J., & Nässén, J. (2020). Understanding daily car use: Driving habits, motives, attitudes, and norms across trip purposes. Transportation Research Part F: Traffic Psychology and Behaviour , 68 , 306–315. https://doi.org/10.1016/j.trf.2019.11.013 Ranjan, R., Castillo, C. D., & Chellappa, R. (2017). L2-constrained Softmax Loss for Discriminative Face Verification. CoRR , abs/1703.09507 . http://arxiv.org/abs/1703.09507 Rao, Q., & Frtunikj, J. (2018). Deep Learning for Self-Driving Cars: Chances and Challenges. 2018 IEEE/ACM 1st International Workshop on Software Engineering for AI in Autonomous Systems (SEFAIAS) , 35–38. https://api.semanticscholar.org/CorpusID:49868952 Rebala, G., Ravi, A., & Churiwala, S. (2019). An Introduction to Machine Learning (1st ed.). Springer Publishing Company, Incorporated. Rinzivillo, S., Gabrielli, L., Nanni, M., Pappalardo, L., Pedreschi, D., & Giannotti, F. (2014). The purpose of motion: Learning activities from Individual Mobility Networks. 2014 International Conference on Data Science and Advanced Analytics (DSAA) , 312–318. https://doi.org/10.1109/DSAA.2014.7058090 Rokach, L., & Maimon, O. (2005). Clustering Methods. In O. Maimon & L. Rokach (Eds.), Data Mining and Knowledge Discovery Handbook (pp. 321–352). Springer US. https://doi.org/10.1007/0-387-25465-X_15 ROSWiki. (2023). Introduction to ROS . http://wiki.ros.org/Documentation Rumelhart, D. E., Hinton, G. E., & Williams, R. J. (1986). Learning internal representations by error propagation . https://api.semanticscholar.org/CorpusID:62245742 S. Choi, F. Thalmayr, D. Wee, & F. Weig. (2016). Advanced driver-assistance systems: Challenges and opportunities ahead. McKinsey & Company , 11. S. Gospodinova, & F. Miccoli. (2022, July). New rules to improve road safety and enable fully driverless vehicles in the EU . https://ec.europa.eu/commission/presscorner/detail/en/ip_22_4312 117 SAE International. (2018). Taxonomy and Definitions for Terms Related to Driving Automation Systems for on-Road Motor Vehicles J3016 SAE International: Warrendale, PA, USA, 2018; Volume J3016, p. 35. Sallab, A. el, Abdou, M., Perot, E., & Yogamani, S. (2017). Deep Reinforcement Learning framework for Autonomous Driving . https://doi.org/10.2352/ISSN.2470- 1173.2017.19.AVM-023 Sammut, C., & Webb, G. I. (2017). Encyclopedia of Machine Learning and Data Mining . Springer. https://doi.org/10.1007/978-1-4899-7687-1 Sandamirskaya, Y., Zibner, S. K. U., Schneegans, S., & Schöner, G. (2013). Using Dynamic Field Theory to extend the embodiment stance toward higher cognition. New Ideas in Psychology , 31 (3), 322–339. https://doi.org/10.1016/j.newideapsych.2013.01.002 Sarkar, D., Bali, R., & Ghosh, T. (2018). Hands-On Transfer Learning with Python: Implement Advanced Deep Learning and Neural Network Models Using TensorFlow and Keras . Packt Publishing. Schöner, G. (2008). Dynamical Systems Approaches to Cognition. In R. Sun (Ed.), The Cambridge Handbook of Computational Psychology (pp. 101–126). Cambridge University Press. https://doi.org/DOI: 10.1017/CBO9780511816772.007 Schöner, G., Dose, M., & Engels, C. (1995). Dynamics of behavior: Theory and applications for autonomous robot architectures. Robotics and Autonomous Systems , 16 (2), 213–245. https://doi.org/https://doi.org/10.1016/0921-8890(95)00049-6 Schöner, G., Spencer, J., & Group, D. F. T. (2015). Dynamic Thinking: A Primer on Dynamic Field Theory . https://doi.org/10.1093/acprof:oso/9780199300563.001.0001 Sheridan, T. B. (1997). EIGHT ULTIMATE CHALLENGES F HUMAN-ROBOT COMMUNICATION . Simmons, R., Browning, B., Zhang, Y., & Sadekar, V. (2006). Learning to Predict Driver Route and Destination Intent. 2006 IEEE Intelligent Transportation Systems Conference , 127–132. https://doi.org/10.1109/ITSC.2006.1706730 Sirovich, L., & Kirby, M. (1987a). Low-dimensional procedure for the characterization of human faces. J. Opt. Soc. Am. A , 4 (3), 519–524. https://doi.org/10.1364/JOSAA.4.000519 118 Sirovich, L., & Kirby, M. (1987b). Low-dimensional procedure for the characterization of human faces. J. Opt. Soc. Am. A , 4 (3), 519–524. https://doi.org/10.1364/JOSAA.4.000519 Song, C., Koren, T., Wang, P., & Barabási, A.-L. (2010). Modelling the scaling properties of human mobility. Nature Physics , 6 (10), 818–823. https://doi.org/10.1038/nphys1760 Song, C., Qu, Z., Blumm, N., & Barabási, A.-L. (2010). Limits of Predictability in Human Mobility. Science , 327 (5968), 1018–1021. https://doi.org/10.1126/science.1177170 Sousa, E., Erlhagen, W., Ferreira, F., & Bicho, E. (2015). Off-line simulation inspires insight: A neurodynamics approach to efficient robot task learning. Neural Networks , 72 , 123–139. https://doi.org/https://doi.org/10.1016/j.neunet.2015.09.002 Stanford Artificial Intelligence Laboratory et al. (2018). Robotic Operating System . https://www.ros.org Sun, X., Chen, H., Shi, J., Guo, W., & Li, J. (2018). From HMI to HRI: Human-Vehicle Interaction Design for Smart Cockpit. Human-Computer Interaction. Interaction in Context: 20th International Conference, HCI International 2018, Las Vegas, NV, USA, July 15–20, 2018, Proceedings, Part II , 440–454. https://doi.org/10.1007/978-3- 319-91244-8_35 Sun, Y., Wang, X., & Tang, X. (2014). Deep Learning Face Representation from Predicting 10,000 Classes. 2014 IEEE Conference on Computer Vision and Pattern Recognition , 1891–1898. https://doi.org/10.1109/CVPR.2014.244 Taigman, Y., Yang, M., Ranzato, M., & Wolf, L. (2014). DeepFace: Closing the Gap to Human-Level Performance in Face Verification. 2014 IEEE Conference on Computer Vision and Pattern Recognition , 1701–1708. https://doi.org/10.1109/CVPR.2014.220 Teixeira, A. D. (2018). Aplicações Web Seguras em Django [Master Thesis]. Universidade do Minho, Escola de Engenharia, Departamento de Informática. Viola, P., & Jones, M. (2001). Rapid object detection using a boosted cascade of simple features. Proceedings of the 2001 IEEE Computer Society Conference on Computer Vision and Pattern Recognition. CVPR 2001 , 1 , I–I. https://doi.org/10.1109/CVPR.2001.990517 119 Vitello, G., Alongi, A., Conti, V., & Vitabile, S. (2017). A Bio-Inspired Cognitive Agent for Autonomous Urban Vehicles Routing Optimization. IEEE Transactions on Cognitive and Developmental Systems , 9 (1), 5–15. https://doi.org/10.1109/TCDS.2016.2608500 Wang, M., & Deng, W. (2021). Deep face recognition: A survey. Neurocomputing , 429 , 215–244. https://doi.org/https://doi.org/10.1016/j.neucom.2020.10.081 Wang, Y., Ji, X., Zhou, Z., Wang, H., & Li, Z. (2017). Detecting Faces Using Region-based Fully Convolutional Networks . https://api.semanticscholar.org/CorpusID:5668282 Widrow, B., & Hoff, M. E. (1960). Adaptive Switching Circuits . https://doi.org/10.21236/ad0241531 Wiskott, L., Fellous, J.-M., Kruger, N., & von der Malsburg, C. (1997). Face recognition by elastic bunch graph matching. Proceedings of International Conference on Image Processing , 1 , 129–132 vol.1. https://doi.org/10.1109/ICIP.1997.647401 Wojtak, W., Coombes, S., Avitabile, D., Bicho, E., & Erlhagen, W. (2023). Robust working memory in a two-dimensional continuous attractor network. Cognitive Neurodynamics . https://doi.org/10.1007/s11571-023-09979-3 Wojtak, W., Ferreira, F., Guimarães, P., Barbosa, P., Monteiro, S., Erlhagen, W., & Bicho, E. (2021). Towards Endowing Intelligent Cars with the Ability to Learn the Routines of Multiple Drivers: A Dynamic Neural Field Model (pp. 337–349). https://doi.org/10.1007/978-3-030-86973-1_24 Xu, J., Zhao, J., Zhou, R., Liu, C., Zhao, P., & Zhao, L. (2021). Predicting Destinations by a Deep Learning based Approach. IEEE Transactions on Knowledge and Data Engineering , 33 (2), 651–666. https://doi.org/10.1109/TKDE.2019.2932984 Yanco, H. A., & Drury, J. (2004). Classifying human-robot interaction: An updated taxonomy. Conference Proceedings - IEEE International Conference on Systems, Man and Cybernetics , 3 , 2841–2846. https://doi.org/10.1109/ICSMC.2004.1400763 Yang, S., Luo, P., Loy, C. C., & Tang, X. (2016). WIDER FACE: A Face Detection Benchmark. 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR) , 5525–5533. https://doi.org/10.1109/CVPR.2016.596 Yi, D., Su, J., Hu, L., Liu, C., Quddus, M., Dianati, M., & Chen, W.-H. (2020a). Implicit Personalization in Driving Assistance: State-of-the-Art and Open Issues. IEEE 120 Transactions on Intelligent Vehicles , 5 (3), 397–413. https://doi.org/10.1109/TIV.2019.2960935 Yi, D., Su, J., Hu, L., Liu, C., Quddus, M., Dianati, M., & Chen, W.-H. (2020b). Implicit Personalization in Driving Assistance: State-of-the-Art and Open Issues. IEEE Transactions on Intelligent Vehicles , 5 (3), 397–413. https://doi.org/10.1109/TIV.2019.2960935 Yuan, J., Zheng, Y., & Xie, X. (2012). Discovering Regions of Different Functions in a City Using Human Mobility and POIs. Proceedings of the 18th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining , 186–194. https://doi.org/10.1145/2339530.2339561 Zafeiriou, S., Zhang, C., & Zhang, Z. (2015). A survey on face detection in the wild: Past, present and future. Computer Vision and Image Understanding , 138 , 1–24. https://doi.org/https://doi.org/10.1016/j.cviu.2015.03.015 Zhang, B., Li, J., Wang, Y., Tai, Y., Wang, C., Li, J., Huang, F., Xia, Y., Pei, W., & Ji, R. (2020). ASFD: Automatic and Scalable Face Detector. CoRR , abs/2003.11228 . https://arxiv.org/abs/2003.11228 Zhao, Y., & Zhou, X. (2021). K-means clustering algorithm and its improvement research. Journal of Physics: Conference Series , 1873 (1), 12074. Zhu, Y., Cai, H., Zhang, S., Wang, C., & Xiong, Y. (2020). TinaFace: Strong but Simple Baseline for Face Detection. CoRR , abs/2011.13183 . https://arxiv.org/abs/2011.13183 Zibner, S. K., Faubel, C., Iossifidis, I., & Schoner, G. (2011). Dynamic neural fields as building blocks of a cortex-inspired architecture for robotic scene representation. IEEE Transactions on Autonomous Mental Development , 3 (1), 74–91. 121 122