Full text
Universidade do Minho Escola de Engenharia Ana Filipa Rodrigues Pereira Optimizing the location of electric vehicle charging points using Machine Learning October, 2023
Universidade do Minho Escola de Engenharia Ana Filipa Rodrigues Pereira Optimizing the location of electric vehicle charging points using Machine Learning Master’s Dissertation Master’s in Informatics Engineering Work supervised by César Analide de Freitas e Silva da Costa Rodrigues Bruno Filipe Martins Fernandes October, 2023
ii COPYRIGHT AND TERMS OF USE OF THIS WORK BY A THIRD PARTY This is academic work that can be used by third parties as long as internationally accepted rules and good practices regarding copyright and related rights are respected. Accordingly, this work may be used under the license provided below. If the user needs permission to make use of the work under conditions not provided for in the indicated licensing, they should contact the author through the RepositóriUM of Universidade do Minho. License granted to the users of this work Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/deed.en
iii STATEMENT OF INTEGRITY I hereby declare having conducted this academic work with integrity. I confirm that I have not used plagiarism or any form of undue use of information or falsification of results along the process leading to its elaboration. I further declare that I have fully acknowledged the Code of Ethical Conduct of the Universidade do Minho. , (Location) (Date) (Ana Filipa Rodrigues Pereira)
Acknowledgements During this past year which was dedicated to my dissertation, I had the support of people for whom I would like to express my heartfelt gratitude. First and foremost, I am deeply thankful to my supervisors, César Analide and Bruno Fernandes who made this work possible with their unwavering support and mentorship. Moreover, to Bernhard Lutz, faculty member at the University of Freiburg, who kindly accepted to be my mentor throughout my semester abroad in Germany. His guidance and insightful feedback where invaluable and crucial to the completion of this work. Furthermore, I am immensely grateful to my family, specially to my parents and my sister for their encouragement and belief in my abilities. Lastly, I would like to express my deep gratitude to my friends Luísa Carneiro, Rita Peixoto, Carolina Santejo, Luís Pinto, and Raquel Costa for their unconditional friendship and support throughout this past five years of university. iv
Abstract Optimizing the location of electric vehicle charging stations using Machine Learning One of the major challenges that today’s society deals with the assurance of a sustainable future for present and coming generations. Therefore, Large cities and urban areas are becoming more committed to adopting new sustainability paradigms and are doing so by employing technological solutions. The increasing advancement of technology has made it possible to implement a number of innovative approaches that have a highly beneficial impact on both the environment and the administration of cities. This aspect enables the transition from conventional metropolises to smart cities . Electric vehicles are among the most relevant and popular examples of technological innovations in recent years. The transition to a new electric transportation paradigm offers a viable approach to reducing humanity’s ecological footprint due to the low emissions of polluting gases and the substitution of fossil fuels with rechargeable lithium batteries. In light of this, this dissertation aims to optimize the placement of new charging stations in Portuguese cities using various Machine Learning techniques. To do this, We Can Charge data was used to implement and evaluate multiple Machine Learning models in order to discover which one would determine more accurately the daily hours of usage of a potential charging station. Overall, the Random Forest was the model with the best performance. Additionally, Artificial Intelligence explainability techniques were implemented to identify the key factors influencing the charging stations usage. For the districts of Portugal analysed, the number of times a charging station changes states daily, from being occupied by a vehicle to being free and vice-versa, was the most significant factor affecting the daily hours of usage of charging stations. Keywords: Electric Vehicles, network of charging stations, smart cities, sustainability v
Resumo Otimização da colocação de pontos de carregamento de veículos elétricos usando Machine Learning Um dos principais desafios que a sociedade enfrenta hoje é assegurar um futuro sustentável para as gerações presentes e vindouras. As grandes cidades e áreas urbanas estão cada vez mais comprometidas em adotar novos paradigmas de sustentabilidade , utilizando, para isso, soluções tecnológicas. O avanço da tecnologia tornou possível implementar diversas soluções inovadoras que têm um impacto altamente benéfico a nível ecológico e no planeamento e administração das cidades. Este aspecto permite a transição das típicas metrópoles para cidades inteligentes . Os veículos elétricos estão entre os exemplos mais relevantes e populares de inovações tecnológicas nos últimos anos. A transição para um novo paradigma de transporte elétrico são uma abordagem viável para reduzir a pegada ecológica da humanidade devido às baixas emissões de gases poluentes e à troca dos combustíveis fósseis por baterias de lítio recarregáveis. O objetivo desta dissertação é otimizar a instalação de novos pontos de carregamento em cidades portuguesas usando diversas técnicas de Machine Learning. Para tal, os dados fornecidos pela We Can Charge foram usados para implementar e avaliar diversos modelos de Machine Learning de forma a determinar qual deles prevê mais corretamente as horas diárias de uso de um potencial ponto de carregamento. No geral, a Random Forest foi o modelo que obteve a melhor performance. Técnicas de explicabilidade de Inteligência Artificial foram também implementadas para identificar os fatores chave que mais impactam o uso dos pontos de carregamento. Para os distritos analisados, o número de vezes que ponto de carregamento muda de estado num dado dia, passando do estado de ocupado para livre e vice-versa, é o fator que mais influencia as horas diárias de uso dos pontos de carga. Palavras-chave: Cidades inteligentes, rede de pontos de carregamentos, Sustentabilidade, veículos elétricos vi
Contents List of Figures ix List of Tables xii Acronyms xiii 1 Introduction 1 1.1 Context and Motivation ............................... 1 1.2 Methodology .................................... 3 1.3 Goals and Research Questions ........................... 5 1.4 Document Outline ................................. 5 2 State of the Art 7 2.1 Sustainability and Electric Mobility .......................... 7 2.1.1 Smart cities ................................ 8 2.1.2 Electric Mobility .............................. 12 2.2 Machine and Deep Learning ............................. 18 2.2.1 Artificial Intelligence ............................ 19 2.2.2 Machine Learning ............................. 19 2.2.3 Deep Learning ............................... 20 2.2.4 Learning Paradigms ............................ 21 2.3 Explainable and Interpretable AI ........................... 26 2.4 Analysis of the State of the Art ............................ 27 2.5 Summary ...................................... 30 3 Experimental Setup 34 vii
CONTENTS 3.1 Methods and Materials ............................... 34 3.1.1 Technologies ................................ 35 3.1.2 Methods .................................. 35 3.1.3 Material .................................. 36 3.2 Data Understanding and Exploration ......................... 38 3.3 Data preprocessing ................................. 47 3.4 Modeling ...................................... 54 3.4.1 Decision Tree ............................... 56 3.4.2 Random Forest ............................... 57 3.4.3 XGBoost .................................. 59 3.4.4 LSTM ................................... 60 4 Results and Discussion 63 4.1 Predicting dailyHours ................................ 64 4.2 Attractiveness of Charging Stations ......................... 72 4.3 Predicting dailySessions ............................... 74 4.4 Employment of the Model .............................. 80 5 Conclusion 82 5.1 Conclusions .................................... 82 5.2 Future Work .................................... 83 5.3 Final Thoughts ................................... 84 Bibliography 85 Appendices 91 A Appendix 1 91 viii
Chapter 1 Introduction This first chapter consists of an introduction to the dissertation. Firstly, it will be provided a context and motivation to the problem, followed by the goals and expected results. In the end, a brief summary of the document’s main contents will also be provided. 1.1 Context and Motivation In recent years, the expansion of polluting businesses, the rapid growth of urban population and consequent unrestrained usage of natural resources has led to an increasing pressure to mitigate GHG emissions in order to reduce the effects of climate change [1]. This all translates to not only environmental challenges but also social and economic, that governments and other regulatory institutions have been dealing with for the past decades. Numerous plans of action are being discussed and approved, not only in Europe but throughout the rest of the world, to tackle the consequences of humanity’s ecological footprint. The European Commission, by approving the European Green Deal [2], aims to make Europe the first carbon-neutral continent by the year 2050. The European Commission, still within the European Green Deal, has also launched the European Environmental Pact [3] in order to implement a strategy that allows the transition to a circular and greener economic model, based on the efficient use of natural resources. Moreover, and with particular attention to Portugal, the National Energy and Climate Plan 2021/2030 was approved in 2020, expecting to achieve by 2030, among other goals, the reduction of GHG emissions of between 45% and 55%, an increase in 1
CHAPTER 1. INTRODUCTION the use renewable energy up to 47% and an improvement up to 35% in energy efficiency [4]. According to the European Environment Agency, in 2017, nearly one-third of the CO2 emissions in the European Union were attributed to the transportation sector [5]. Hence, one of the key solutions to addressing climate change and its consequences is the transition to a new mobility environment based on greener alternatives with a focus on the electrification of vehicles. Although EVs used to be a rare sight not too many years ago, they are becoming increasingly common nowadays. This transformation can be attributed to improvements in three major areas: regulation, consumer behavior and technology. The implementation of incentives and new laws that benefit those who favor EVs, the change in awareness as more people adopt sustainable mobility habits and the increasing innovation and investments in automotive technology, have turned electric mobility into the paradigm of the future [6]. An evidence of this is that, in 2012, 120 000 electric cars were sold worldwide. In 2021 the same amount was sold in just a week [7]. However, the transformation of the electric vehicle market must be accompanied by a significant change in the whole mobility ecosystem. With a forecast that by 2030, more than 75% of new cars sold will be electric, it becomes crucial to improve and expand current public charging infrastructures. With the growing popularity of electric transportation, the lack of investment in upgrading charging networks might become a bottleneck and consequently limiting the EVs mass adoption, since this represents a main concern to future consumers. It is expected that in the near future, more than 50% of Europeans will be living in multifamily homes without private charger access. This corroborates that fact that while the first-generation of EVs buyers relied mainly on private charging the next generation will certainly depend on public charging. In order to achieve the expected GHG emission reduction by 2030, it would be necessary to install 14 000 charging points weekly, in the European Union. Nonetheless, currently only 2000 charging points are being installed each week [8]. The current charging infrastructures across Europe are expanding in a disorganized manner and are facing problems with costs and regulations. One of the most apparent implications of this is that a substantial portion of the charging network will not repay the initial investment. In Portugal, 22% of the current charging network will not be profitable. Taking this into account, it becomes necessary to find a way of installing charging stations on locations that can return the investment made. A possible approach to the challenge would be using AI to automate and facilitate the process of networks management. With ML models it is possible to predict the best new locations based on traffic patterns, local grid status, proximity to crowded areas, and other relevant factors. 2
CHAPTER 1. INTRODUCTION We Can Charge is a portuguese startup that develops electric mobility solutions based on the improvement of charging networks’ efficiency, and whose primary goal is the decentralization of the electric vehicles market. This way, with the help of We Can Charge software, any client can invest and create their own private and autonomous charging infrastructure, having the ability to monitor the charging points, stipulate prices, launch promotions and define opening hours. These businesses also have access to predictions about the best locations for future charging stations and the potential profit they can earn from them. Taking this into account, this dissertation, with the contribution of we Can Charge data and previous studies, pretends to present an approach to the problem of charging infrastructures management, by introducing various ML techniques to optimize the locations of future charging points with focus on portuguese cities. 1.2 Methodology In order to approach the problem raised in this dissertation, it was developed a methodology with five steps, which is schematized in Figure 1. First, the data that will be used throughout the research work must be uploaded into the environment where the project is being executed. This data is provided by We Can Charge and consists of a CSV file. This file offers multiple information regarding the locations of existing EVs charging stations in various portuguese cities. In subsection 3.1.3, the columns that make up the dataset are described in more detail. The second step of the proposed architecture, is Data Analysis . Once the dataset is imported, it is essential to make sense of the data being dealt with, not only to better interpret it, but also obtain pertinent insights that will enable making future informed decisions, as for example, which ML algorithms are more adequate or which preprocessing techniques should be utilized. Moreover, by exploring the structure and distribution of the observed variables, it becomes possible to detect trends, patterns, outliers, correlations between variables or even missing and inconsistent information. Hence, the procedure offers helpful insights and statistics about the datasets, which can be obtained with visualization and statistical tools. Taking this into account, and once the datasets have been properly analysed, the third step of the methodology takes place. Data collected from the real world is often inconsistent, noisy and incomplete. Therefore, submitting the data to preprocessing methods , attenuates these issues, making data betterformatted to be processed by ML algorithms. It is also noteworthy that ML algorithms can only operate on numerical data, which is not how raw datasets are normally structured. Hence, preprocessing can be 3
CHAPTER 1. INTRODUCTION defined as the transformation of raw features into data that a ML algorithm can understand and learn from. In addition, data preprocessing techniques can be divided into two main parts, Data Cleaning and Data Transformation. Usually, the first step of data cleaning consists in handling missing and null values , being the most common approaches: removing those tuples, fill them manually or fill them with computed values which can be obtained using strategies like calculating the mode in case of categorical features or calculating the mean and median in case of numerical features. In order to maintain accuracy and to avoid misleading statistics, duplicated observations should also be detected and eliminated. Furthermore, during data cleaning, it is crucial to detect and handle outliers since these may have a great impact on the ML models behavior. Once data clearing has been done, it is necessary to go through data transformation strategies. As already stated, algorithms can only interpret numbers, making it necessary to use techniques to handle categorical data . Different approaches can be utilized depending on the categorical data type, particularly whether the features are ordinal or nominal. Furthermore, numeric features frequently have different scales in real-world data collection. For instance, it is possible to have a feature xthat ranges from 0 to 100 and a feature ythat ranges from 0 to 20 000 and higher. Features with varying scales may therefore be incorrectly interpreted, since to some ML algorithms features with a wider range possess a bigger influence. Taking this into account, feature scaling is often applied and it ensures that the values within continuous features are all on the same scale. The two ways to scale data are Standardization and Normalization. Lastly, in order to come up with a solution to the problem raised in this study, the various ML models that were implemented need to be evaluated. Is it during this phase that the results are examined to determine which of the designed models is the most appropriate and to ensure if the obtained results make sense in the context of the problem. This is achieved by feeding the different ML models, the same input dataset, and evaluate their behavior according to evaluation metrics and also through the visualization of results. It is relevant to emphasize that once models are evaluated, two possibilities emerge, as seen in Figure 1. If the model’s performance is acceptable, we can conclude that they accurately and successfully address the problem of optimizing the locations of future charging stations. However, returning to a prior stage of the approach may be necessary if the model’s performance is unsatisfactory. For instance, in step 4, the models’ hyperparameters might need to be adjusted, a different preprocessing method might need to be used in step 3, or even a completely new analysis of the data would be required. 4
CHAPTER 1. INTRODUCTION Figure 1: Proposed Methodology. 1.3 Goals and Research Questions The major goal of this dissertation consists in conceiving a methodology to successfully optimize the placement of new charging stations for EVs, in multiple portuguese cities. This way, and throughout the dissertation we expect to answer the following research questions: 1. What are the main characteristics that impact a location’s level of attractiveness? 2. Can we successfully predict, using ML, which locations in portuguese cities are the most attractive to install EVs charging stations? 3. If we can use ML to predict new charging stations for EVs, can we do it with validation metrics that surpass the current state of the art? 1.4 Document Outline The current document is divided into five main chapters which will be described in this topic. Firstly, in chapter 1, it is presented an introduction the theme of the dissertation along with its context and motivation. Following this, all the steps of the developed methodology that will be used during the work’s development phase are provided and thoroughly explained. Furthermore, the purpose of this investigation is stated, in addition to the research questions we intend to address. In this section, it is also given an overview of the document’s structure. In chapter 2, denominated state of the art, we explore in further detail the theme of the dissertation by first connecting the concepts of electric mobility and sustainability in order to understand the correlation between the two. Moreover, in section 2.2 it is introduced all the relevant concepts to the present document, including the concepts of AI,ML and DL. In addition, it is also provided a detailed description of the three main learning paradigms. Still in this chapter it is presented an analysis of the state of the art, where it is 5
CHAPTER 1. INTRODUCTION referred past approaches to the problem addressed in this dissertation. Finally, the section ends with a summary in order to give an overview of the main points of the chapter. Afterwards, in chapter 3it is given description of the technologies, data, and methods involved in this study, followed by the execution of the first steps of the methodology, Data Understanding and Exploration and Data preprocessing. Moreover, an overview of the models which were implemented to solve the problem was also presented. Chapter 4focus on describing, with detail, all the analyses done during this study and the following conclusions that came from them. Finally, in chapter 5, highlights the main results from the experiments, discusses the work that will be done in the future, and provides a few final thoughts. 6
Chapter 2 State of the Art Throughout this chapter, it will be established all the theoretical concepts pertinent to the scope of this dissertation. Firstly, the thematic of sustainability is introduced by defining and analysing in further detail the topics of smart cities, its six fundamental pillars and the electric mobility paradigm in order to better understand how the latter is a changing element in the current environmental crisis. Since EVs are inextricably linked to electric mobility, a description of the main types of EVs circulating is also provided, along with the advantages and challenges this mobility paradigm faces in the present days. Still in this section, it is also presented an explanation of the architecture of a simplified charging infrastructure. Furthermore, it is given a background to the technical component of the dissertation by describing and comparing the relevant concepts of AI,ML and DL, the three main learning paradigms and the types of problems associated. In addition, an analysis of the state of the art is delineated, in order to better clarify the context of this research problem. To do this, we look over previous articles and studies, related to the scope of the current work, which present alternative solutions to the challenge of successfully expanding charging networks with AI. Finally, the chapter concludes with a summary that highlights the most relevant aspects and observations of the state of the art. 2.1 Sustainability and Electric Mobility In the present days, cities accommodate around 55% of the world’s population. However, it is anticipated that this percentage may increase up to 66% by 2050, which translates into 2.4 billion people moving to 7
CHAPTER 2. STATE OF THE ART cities and other urban settings [9]. The rapid growth of global urban population increases the demand for natural resources, energy, water, education, healthcare and other public services, which consequently increases the necessity to monetarily invest in cities infrastructures. According to the United Nations Environment Programme, the material consumption in cities will grow to an estimate 90 billion tons by 2050, which is an increase of 50 million tons compared to 2010 [9]. The United Nations Environment Programme also concluded that even though cities occupy less than 2% of the earth surface, they consume more than 75% of the available natural resources [10]. This growing mobility to urban areas has multiple causes, however the most significant one is the fact that large cities offer great opportunities for economic development since 80% of the world’s GDP is generated in urban areas [11]. Taking this into account, it is possible to understand that the growth of cities creates unprecedented sustainability challenges. In 1987, the WCED published a report entitled ”Our common future”where sustainability was defined as ”meeting the needs of the present without compromising the ability of future generations to meet their own needs” [12]. The concept of sustainability assumes the finitude of resources, not only natural but also social and economic, that should be used wisely with a view to long-term priorities and consequences of the ways these resources are used [13]. Hence, in the past decades, it became urgent to bring forward means to respond to the challenges created by rapid urbanization. One of the most widespread and discussed solutions to approach this problem is the transition of typical metropolises to smart cities. 2.1.1 Smart cities Even though smart cities are a popular subject in today’s society, there is some debate about how to define them. This disagreement ranges from what elements a city needs include in order to be considered ”smart”, the resources it needs to employ, what characteristics it needs to present and what are a smart city’s goals and purpose [14]. The most generally accepted definition, however, asserts that a smart city is an urban area that makes use of digital tools and technology-based infrastructure, such as ICT, to gather data and insights in real time for the benefit of its citizens and businesses. According to the European Commission, a smart city goes beyond the use of technology to tackle growing urbanization and the scarcity of resources. It means smarter methods to make people’s daily life easier with, for example, smarter urban transport networks, upgraded water supply and waste disposal facilities and more efficient and technological ways to light and heat buildings. In a smart city, it is also contemplated a more transparent and interactive city administration, safer public spaces, widespread home connectivity, open data, and 8
CHAPTER 2. STATE OF THE ART meeting the necessities of an ageing population [15]. In light of this, and as demonstrated in Figure 2, a smart city has six main dimensions. Figure 2: The six main domains of a smart city. Adapted from [16] and [17]. Smart Environment The concepts of smart city and sustainability are frequently used interchangeably. However, a smart city’s technologies are not sustainable on their own and this depends on how they are applied. According to the United Nations Economic Commission for Europe, a smart city to be considered environment-friendly, or in other words to be a SSC, must use technological solutions to improve citizens’ quality of life, efficiency of urban operation and services, and competitiveness while guaranteeing the economic, social, environmental and cultural needs of both present and future generations [18]. Taking this into account, a smart environment aims to utilize digital and computational devices in order to control and monitor multiple environmental factors as for example energy and water waste, GHG emissions, pollution or even resource management. This way, and as it is possible to see in Figure 3a smart city following a smart environment approach uses innovative digital solutions to implement new urban planning standards in order to reduce society’s environmental impact [19]. 9
CHAPTER 2. STATE OF THE ART Figure 3: The three elements that compose a SSC. Adapted from [11]. Smart Mobility Smart mobility focuses on using digital innovation to increase the effectiveness and service quality of urban transportation. The main goal consists on encouraging the adoption of new mobility solutions to solve current issues of public transport like traffic congestion, transit capacity in the city or the high levels of pollution. However in order to build transport systems that are able to meet the needs of all citizens, it is fundamental to rethink the transportation infrastructure currently prevailing and to invest in their expansion and technological upgrade [19]. The pillar of smart mobility also assumes implementation of a multi-modal transportation network, which includes private cars, public transports or bicycles. Nonetheless, in a smart mobility environment, there will be more incentives for people to choose greener alternatives as for example opting for EVs [20]. Taking this into account, the smart mobility paradigm aims to use technology to optimize the transportation systems of cities in order to make them safer, more efficient and environmental-friendly. Smart Society A smart society is one in which technological advancements are made to improve the well-being of citizens, the strength of the economy, and the effectiveness of institutions [21]. More specifically, smart societies maximize the use of innovative technologies to connect nations, cities, and communities leading to informed, engaged and empowered citizens. This smart city approach also promotes different forms of education to facilitate career choices, job opportunities and to commit citizens to lifelong learning regardless of age of demographic background. In light of this, a smart society aspires to employ digital 10
CHAPTER 2. STATE OF THE ART this component is responsible for 30% and 40% of the total cost [31]. However, this task is becoming increasingly easier due to continuous digital innovation. Another solution to address this problem would be governments implementing financial incentives such as purchase subsidies and tax benefits for electric mobility, or even non-financial incentives like road access privilege and dedicated parking spaces. Recharge Time In order for EVs to dominate the transportation sector, it is important that the process of recharging EVs is as convenient and easy as recharging traditional fuel-powered vehicles. Nevertheless, this is still not a reality since recharging an electric vehicle takes significantly longer than recharging a conventional one. While a non-electric vehicle’s petrol tank can be filled in a few minutes, the time it takes an electric vehicle to charge is determined on the charging station’s speed. Level-1 charging is the slowest, making it the best option for home charging, and it takes more than 20 hours to completely charge the electric battery. On the other hand, Level-2 charging is a faster method, taking 5 to 6 hours to charge the vehicle. Furthermore, Direct Current Fast Charging , is the most efficient option and consequently the ideal solution for public infrastructures, taking between 15 to 45 minutes to fully charge an electric vehicle’s battery. Taking all of this into account, even though there are different charging options, and with technological advancements they are becoming faster and more efficient, the process of charging EVs still takes a significant amount of time, which is a disadvantage compared to fuel-powered vehicles. Battery Life One of the main drawbacks for consumers regarding lithium ion batteries is that these batteries suffer from ageing. Often batteries will only be able to withstand from 500 to 1000 charge discharge cycles before their capacity starts to deteriorate. With the the growing technological innovations, the capacity of electric batteries constantly increasing, but after a while batteries may need to be replaced. This need to replace electric batteries is also associated to their high cost which represents a concern for EVs potential owners. Limited infrastructure for public charging Another flagrant barrier regarding electric mobility is the combination of EVs short-range capacity and the lack of an appropriate charging infrastructure. As a result of continuous technological advancements, EVs get significantly better every year. In 2021, on a single charge, the average battery-powered electric 17
CHAPTER 2. STATE OF THE ART vehicle could travel around 349 km, which represents a 44% increase from 243 km in 2017 and a 152% increase relative to 2011 [7]. However, EVs still fall short when compared to gas-powered vehicles. For instance, in 2021, the median gas vehicle range (on one full tank) in the United States of America was approximately 664 km, which is roughly twice as far as the average capacity of a regular all-electric [32]. Therefore, in order to tackle driving range as a barrier for EVs adoption, it is crucial to expand and upgrade public charging infrastructures not only because they facilitate longer journeys but also encourage consumers that lack access to private charging to purchase an electric vehicle. Despite the growing number of EVs circulating on the roads, charging networks are developing at a different speed. According to a study led by the European Automobile Manufacturers’ Association half of all charging points for electric cars in the European Union are concentrated in only two countries, the Netherlands with 90 000 stations and Germany with 60 000 stations. However these two countries together make up less than 10% of the entire European Union surface area [33]. This demonstrates that, currently, in the European Union there is a clear under-development of charging networks, in spite of the growing popularity of EVs and the climate goals pretended to achieve in the next decades. Studies led by Mckinsey & Company confirm that the European Union would need to scale up from its current 340 000 charging stations to the estimated 3.4 million public chargers by 2030 in order to meet the needs of the future electric vehicle fleet [34]. It is important to emphasize that nowadays, the majority of EVs owners, charge their vehicles either at home or at their workplaces. This occurs because people tend to follow a charging hierarchy which starts at home, since electric cars remain parked for eight to twelve hours at night, and home charging can be easy and often cheaper than charging elsewhere. However, in the European Union it is anticipated that EVs charging will likely shift toward public options and away from the home over time, with the share of home charging declining from approximately 75% in 2020 to about 40% by 2030 [35]. Taking all of this into account, the current investment and growth of European charging networks is not occurring at a rate that is sufficient to meet the challenges that the ongoing popularity of electric mobility is predicted to bring in the next decade. « 2.2 Machine and Deep Learning Given the information above, it is possible to comprehend that one of the biggest obstacles to electric mobility is public charging networks. Not only are current charging infrastructures not developing as rapidly 18
CHAPTER 2. STATE OF THE ART as they should, but also many charging stations are not being installed in the best places, which reduces the profitability of these infrastructures. AI systems are becoming more prevalent in a wide range of real life applications, and their viability in particular sectors is crucial for market effectiveness. Considering this, the goal of this dissertation is to use ML to optimize the locations for future charging stations, which can help with managing and growing charging infrastructures. However, in order to approach this topic, it is pertinent to first introduce relevant theoretical concepts followed by possible approaches to the problem. 2.2.1 Artificial Intelligence Since ML,DL and AI are closely related concepts, it is essential to define AI before discussing ML and DL in further depth. Even though the term Artificial Intelligence was first officially coined back in 1956 by computer scientist John McCarthy, six years before, Alan Turing was already questioning in his seminal paper, Computing Machinery and Intelligence if machines could have the ability to think [36]. In consideration of this, it is possible to characterize AI as a computer system’s ability to simulate human cognitive processes, by using logic and statistical methods to make decisions and solve problems [37]. AI is then based on the idea that human intelligence can be described in a way that machines can mimic, and then carry out all sorts of tasks, from the most simple to the most complex. In Figure 6it its possible to verify that AI includes two sub-fields, ML and DL, both with their own characteristics, but strongly connected. Undoubtedly, AI is one of the most studied and discussed topics nowadays. It is a quickly growing technological phenomenon that many businesses want to take advantage of in order to gain efficiency and reduce costs [38]. Moreover, AI has a major positive impact on the world’s economy. According to a PwC report, AI will contribute as much as 15.7 trillion dollars to the world economy by 2030 which consists of a 14% increase of global GDP [39]. However, and even though these statistics may lead to think that AI can replace the human mind and overcome its limitations, the truth is that humans and machines can cooperate together and enhance each other’s strengths through collaborative intelligence. 2.2.2 Machine Learning ML, consists of a sub-field of AI, as it can be seen in Figure 6, being defined in 1950 by one of AI’s pioneers, Arthur Samuel, as ”the field of study that gives computers the ability to learn without explicitly being programmed”. Basically, the core concept of all kinds of ML algorithms is that it is possible represent 19
CHAPTER 2. STATE OF THE ART Figure 6: Artificial Intelligence, Machine Learning & Deep Learning. Adapted from [40]. reality using a mathematical function that the algorithm doesn’t know in advance but can guess after having seen some data [41]. In ML, the process initiates with computer systems being fed large volumes of raw data, which can be acquired through multiple collection methods, as for example, observation or experiments. The data points that constitute the dataset are also knows as observed variables. All things considered, during the training process, the ML algorithms will learn through experience and improve their prediction ability by verifying previous errors and misses, reducing them in each iteration. ML algorithms also possess what is commonly known as hyperparameters , these consisting of external configurations that cannot be directly estimated from data. These hyperparameters may need to be tuned, manually or through a subset of the training data (validation set), since they affect how the algorithms behave [42]. Given all of the above, it is possible to comprehend that ML is advantageous to human intelligence in its ability to analyse vast volumes of data and to successfully identify patterns in it. . As already stated before, the objective in this dissertation is to develop multiple ML models, using previous collected data, in order to predict the best future locations for EVs’ charging stations in portuguese cities. However ML algorithms aren’t always predictive like in this particular use case, but can also be descriptive, if the goal is to use historical data to explain past phenomenons, or prescriptive if collected data is used to make suggestions about the best courses of action for specific situations in order to take advantage of future opportunities or mitigate future risks. 2.2.3 Deep Learning As it can be seen in Figure 6,DL is a subset of ML, and consequently a subset of AI, that proposes a new way of representing the problems we are trying to solve. In DL, large volumes of data are handled using deep algorithms , whose structure aims to replicate the behavior of the human brain [43]. Essentially, a deep algorithm consists of a NN with three or more processing layers of interconnected nodes, such as 20
CHAPTER 2. STATE OF THE ART the one in Figure 7, and whose task it to progressively extract higher-level features from the raw input even if in the presence of noise. This flow of information through the network is called forward propagation . Moreover, as a problem becomes more complex, so does the complexity of these networks. Common examples of deep algorithms are Multilayer Perceptrons , Generative Adversarial Networks or LSTM networks. One of the most noticeable differences between DL and ML is the type of data that is being processed. ML algorithms often make predictions based on labeled and structured data. Even if the original dataset is unstructured, it generally goes through some preprocessing to organize it into a structured format. On the opposite, DL, overcomes some of this need to preprocess data, since deep algorithms are capable of ingesting and processing raw datasets, as for example plain text or images. Besides, these algorithms automate the feature extraction process, reducing the need of human intervention [43]. DL’s increasing popularity is mostly due to technological advancement, particularly the evolution of GPUs and CPUs which significantly reduced the time required to train complex neural networks [41]. Nowadays, DL is present in multiple real-life applications as for example virtual assistants like Cortana or Siri, or even in the medical field with software programs that can analyse an individual’s genome and create personalised treatments. Figure 7: Deep Neural Network Architecture. 2.2.4 Learning Paradigms A learning paradigm can be described as a methodology or pattern on which something or someone learns. Similar to people, machines can learn something in a variety of ways depending on the circumstances. When solving a specific problem using ML, choosing the adequate paradigm is essential since it will have an impact on the entire learning process and consequently impacting the final results. This decision is 21
CHAPTER 2. STATE OF THE ART typically based on how data is presented to the computer, in terms of volume and type, and also on the purpose of the problem itself. In order to better understand the different learning paradigms, it is important to explain the concepts of labeled and unlabeled data, since these are both kind of data that can be passed as input toML algorithms. In a dataset, besides their features, data points might also be associated to a specific kind of attribute, known as label, which identifies their characteristic, property or classification of interest [44]. This way, unlabeled data describes a set of data points which have not been tagged with a label, while labeled data consists of a set of data points which possesses a clear characteristic of interest. However, it should be noted that labeled data is more time consuming and expensive to acquire, compared to unlabeled data since human interaction is generally required to accurately annotate (label) the data points [45]. In light of this, and as it can be seen in Figure 8, learning paradigms can be divided into three main categories, based on how the training data is used to discover a dependence, an inference, or a description for the general set of data in a particular problem [46]. Figure 8: The three main learning paradigms. Adapted from [47]. 2.2.4.1 Supervised Learning Supervised learning is a common approach for problems where the objective is to classify data or make predictions based on already known information, as we can see in Figure 8. An example of application would be classifying a certain image as being s certain animal or even predicting a house price considering house features like number of rooms or total square meters. So, in order to do this, the data points which will be passed as input to ML’s algorithms during the training phase, must be labeled , being this label 22
CHAPTER 2. STATE OF THE ART the feature intended to predict. The target feature can consist of numeric values or string labels, such as classes or tags. The algorithm will begin the learning process by receiving the training data as input, which contains a set of features and the correspondent label. It then calculates the error, using a loss function, in each iteration of the process by comparing the discrepancy between its predictions and the true labels of the data points in the training set, always adjusting the model accordingly [44] [48]. In the end, the algorithm finds a mapping function that maps an input variable(x) with an output variable(y). The goal is to approximate this mapping function so well that it can correctly predict or estimate the labels of new unseen data points based solely on their features. This way, supervised learning searches for a hypothesis that can imitate a human annotator and allows to predict a label taking into account a set of features of a data point [44]. Nowadays, this learning process is applied in numerous real life domains, including fraud detection, spam filtering or medical imaging to diagnose patients quickly and accurately. Moreover, supervised learning problems can also be grouped into two types of problems, classification and regression. Classification A classification problem occurs when the feature desired to predict is a discrete variable. In this case, the mapping function is mapping an input data point to an output label that indicates the category or class to which the observation belongs to. If each data point belongs to exactly one out of two different classes, then it is called a two-class or binary classification . Otherwise, if data points are associated to exactly one out of more than two categories it is called multi-class classification [44]. Conventionally, in this kind of problem, the algorithm calculates a continuous value which represents the probability of an observation belonging to each output class. These values can be interpreted as the likelihood of the data points belonging each output [49]. In the end, the mapping function associates an observation to the label with the highest probability. In order to evaluate the performance of a classification algorithm, multiple metrics can be used, however the most common is the model’s accuracy .This metric represents the percentage of correctly classified examples out of all predictions made. Regression A regression problem occurs when the target feature is a continuous variable as for example an integer or floating point value. The mapping function in this scenario is mapping an input data point to an numeric 23
CHAPTER 2. STATE OF THE ART value output. In a regression, the objective is to identify the best fit line that can more accurately predict the output. The example previously given of predicting the price of a house based on certain features such as number of rooms and total square meters, is a typical regression problem. To evaluate the performance of a regression algorithm, it is necessary to use metrics that calculate the magnitude of error between the predicted and observed values. 2.2.4.2 Unsupervised Learning The unsupervised learning approach is utilized when the intention is to analyze and process vast volumes of unlabeled observations. This way, the computer system is only given the input data and no corresponding output labels. As shown in Figure 8, in this paradigm, algorithms have to develop their own learning pattern relying exclusively on the intrinsic structure of data points passed as input. The objective of these algorithms is to identify hidden patterns or to group data point into subsets or clusters, without needing human intervention [50]. Unsupervised algorithms also tend to restructure the data into something else, such as new features that may represent a class or a new series of uncorrelated values. This characteristics make unsupervised learning very useful to generate and provide new input to supervised algorithms [41]. The learning process starts by training an unsupervised algorithm with the respective training dataset. The algorithm will try to identify in the dataset passed as input a hidden pattern or structure, also known as feature vector . With this information, the algorithm is capable of measuring the familiarity of new data points with the past observations by taking into account the previous identified patterns. A possible example of application would be passing as input a set of cat images without any kind of associated annotation (label). In this use case, the algorithm would have to learn to identify the distinct features of a cat, such as their whiskers, long tails or point ears. It is important to note that since unsupervised learning is not dependent of any labels to identify patterns or to group data, the obtained results tend to be less biased than other ML techniques. Taking this into account, unsupervised algorithms’ capacity to detect similarities and differences in information makes this learning paradigm very useful in domains such as customer segmentation, anomaly detection and recommendation systems. Besides, unsupervised learning approaches can also be grouped into three main categories: clustering, association rules and dimensionality reduction. Clustering is a technique which consists in grouping unlabeled data points in subsets or clusters based on their similarities or differences. Each of these clusters are represented by structures or patterns in the information.In this technique, data points in the same clusters have a higher degree of similarity than observations from 24
CHAPTER 2. STATE OF THE ART different groups. Association learning is a rule based technique which consists in discovering hidden relationships between variables or features in a dataset. These relations among observations are obtained by applying some measure of interest and are translated into a set of strong rules, that are crucial for applied in future searches [51]. Finally, Dimensionality Reduction consists in reducing the dimension of input data to a manageable size without losing the integrity of the original dataset [50] 2.2.4.3 Reinforcement Learning RL is a ML training method that is based on a reward system. In this approach, the goal is to train an agent in order to complete a task within an uncertain environment. An agent is defined as the entity responsible to decide which action is going to be taken next in the environment. As it is possible to verify in Figure 9, at each time interval, the agent perceives the current state, s, of the environment and chooses to take an action, a. The agent then receives a reward rfor its action and the environment transits to a new state s’. Is is important to note that a reward, in RL, consists in a measure of how successful a certain action was, in terms of achieving the final major task. This reward can be positive or negative (a penalty), depending if the action taken was or not the most adequate. This training process in RL is analogous to the human way of learning which is based on trial and error. Errors help people learn because they have a penalty added teaching them that a certain course of action is less likely to succeed than others [41]. Nowadays, RL is widely used across many fields as for example the automotive industry with selfdriving vehicles, in marketing with advertisement recommendation systems or even in the gaming industry with the development of computer programs like AlphaGo developed by Google. Figure 9: Reinforcement Learning. 25
CHAPTER 2. STATE OF THE ART 2.3 Explainable and Interpretable AI The demand for models interpretability and explainability have reached unprecedented levels, as the global landscape increasingly adopts ML and AI across various sectors. With ML models’ growing complexity and capabilities, gaining insights into their inner functioning and elucidating their predictions is becoming imperative. Decisions that were previously left to people must now be made by autonomous machines and ”black-box”algorithms and therefore interpretable and explainable ML techniques emerge from a need to design ML systems that can be comprehended by a human mind. The terms interpretability and explainability are usually used by researchers interchangeably; however, while these terms are very closely related, some works identify relevant differences and distinguish these two concepts. Interpretability is mostly connected with the intuition behind the outputs of a model [52]. The concept can be defined as ”the degree to which a human can understand the cause of a decision” [53]. The more interpretable a ML system is, the easier it is to identify cause-and-effect relationships within the system’s inputs and outputs, in other words, the easier it is for someone to comprehend why certain decisions or predictions have been made. On the other hand, explainability is associated with the internal logic and mechanics that are inside aML system. The more explainable a model, the deeper the understanding that humans achieve in terms of the internal procedures that take place while the model is training or making decisions [52]. It is important to highlight that a trade-off exists between the complexity of an AI system and its interpretability. As it is possible to see in Figure 10, as AI models become more complex and sophisticated, they often demonstrate superior performance, boasting enhanced predictive capabilities. However, this improvement comes at a cost of loss of transparency and comprehensibility. Simpler models like decision trees and linear regression offer more interpretability, allowing us to discern the reasoning behind their predictions. Yet, these models may struggle to capture intricate patterns in the data, potentially sacrificing performance. On the other hand, deep neural networks and other complex models are notorious for their ”black box”nature, making it challenging to decipher the process behind their decisions. While they excel in tackling complex and high-dimensional datasets, their enigmatic inner workings raise concerns about trust and accountability. 26
CHAPTER 2. STATE OF THE ART accomplished by using a trial-and-error approach in which the agent receives a reward or a punishment for each positive or negative behavior it adopts. Taking this into account, RL is about discovering the optimal behavior in an environment to obtain the maximum possible reward. When it comes to electric mobility, there are a wide range of papers and research studies on various themes, given the growing popularity of this transportation paradigm. A significant amount of literature is also focused on using AI techniques to address or at least lessen some of the difficulties associated with electric mobility, such as the durability of electric batteries or the optimal placement of charging stations according the a location’s level of attractiveness. 33
Chapter 3 Experimental Setup Before moving on to the implementation of strategies, this chapter starts by exploring a number of concepts whose understanding is important. It is introduced all the relevant technologies that will be employed, the dataset provided by We Can Charge and the specifications of the computer on which the implementation will execute. Furthermore, the strategies that will be used to tackle the problem of predicting the most adequate locations for EVs charging stations are outlined, while taking into account the theoretical foundations and technical background described in chapter 2. Considering this, it is worth to emphasize that when it comes to AI applications, there aren’t always universal, one-size-fits-all solutions, and the decisions taken depend highly on the specifications and scope of the project being discussed. The methodology described in chapter 1is then put into practice, with the first step being the exploration and understanding of the dataset, followed by the preprocessing of the data and lastly the development of several ML models. 3.1 Methods and Materials A thorough discussion of the materials, techniques, and technologies used in the dissertation will be given in this section. First, the technologies used are described, along with with the programming language selected to approach the problem and all pertinent libraries. It is also mentioned the specification of the machine which will be used to carry out the practical component of this research work. Furthermore, it is provided a thorough explanation of the dataset’s structure, and finally, it will be discussed all of the 34
CHAPTER 3. EXPERIMENTAL SETUP potential tactics that are going to be implemented later. 3.1.1 Technologies As previously stated, prior to implementing ML methods to forecast the new, ideal locations for EVs charging stations, it is essential to first determine which programming language would be most suitable. Since Python is a widely popular language for data science applications, it has been selected as the language that will be used for the purposes of this dissertation. Python is an open-source, high-level programming language, known for its readability, less complex syntax and availability for all the operating systems. Another major benefit of Python is, without a doubt, its library ecosystem. For data treatment, libraries like Pandas or Numpy offered multiple tools to process the data. To facilitate the development and implementation of algorithms, there are available libraries like Scikit-Learn , Keras and Tensorflow. This being said, The practical component of this dissertation, will be implemented on one local machine, whose characteristics are listed in Table 1. Characteristic Description Memory 8GB RAM Processor Intel Quad-Core i5-8250U CPU Speed 1.60GHz to 1.80 GHz Storage 128GB Operating System Windows 11 Home Graphics Intel Graphics UHD 620 Table 1: Specifications of the computer. 3.1.2 Methods As one might deduce from subsection 2.4, several strategies can be used to successfully optimize the locations for charging stations, such as employing RL algorithms or using ML algorithms to evaluate the level of attractiveness of future charging stations. However, in this study, the topic of expanding the public EVs charging infrastructures is approached in a slight different way. The dataset which will be used, and is explained further down, consists of historical data of already implemented charging stations and the observed daily hours of usage that each station, for a specific day registered. In addition, We Can Charge already possesses a list of potential locations for future charging stations. The goal of the study is then to predict the future daily hours of usage of a station placed on a certain location and from this it can be 35
CHAPTER 3. EXPERIMENTAL SETUP determined the attractiveness of that location. Taking this into account, it is also possible to conclude that the challenged in hands is a regression problem. Within the ML context, the goal is to explore and compare multiple supervised algorithms with the assistance of all the relevant Python libraries. Due to this RL strategies are not in the scope of the solution developed in this research work. 3.1.3 Material In Table 2, are listed all the attributes that are contained in the dataset provided by We Can Charge, their respective data types, and an explanation of what each one means. Attribute Data Type Description date Date Type The date the observation was made. locationId Categorical Identification code of the location where the charging station is placed. partyId Categorical Identification code of the company that owns the charging station. dailyHours Numerical Total amount of hours a charging station was used on a specific day. dailySessions Numerical Number of times a charging station changes states (from occupied to free and vice-versa) a specific day. city Categorical Name of the city where the charging station is located. latitude Numerical Latitude of the spot where the charging station is located. 36
CHAPTER 3. EXPERIMENTAL SETUP Attribute Data Type Description longitude Numerical Longitude of the spot where the charging station is located. parking_type Categorical Indicates the type of place where the charging station is located. number_of_connectors Numerical Number of connectors in the charging station. connectors_amperage Numerical (List of Floats) The length of the list is equivalent to the total number of connectors in the charging station. Each value denotes the maximum amperage that the corresponding connector supplies. Amperage is the amount of electrons that are flowing through a circuit. connectors_voltage Numerical (List of Floats) The length of the list is equivalent to the total number of connectors in the charging station. Each value denotes the maximum voltage that the corresponding connector supplies. Voltage is the speed at which electrons move through a circuit. connectors_electric_power Numerical (List of Floats) The length of the list is equivalent to the total number of connectors in the charging station. Each value represents the maximum electric output of the corresponding connector. Electric power is the rate, per unit time, at which electrical energy is transferred by an electric circuit. 37
CHAPTER 3. EXPERIMENTAL SETUP Attribute Data Type Description weather Categorical Indicates how the weather was when the observation was made. lodging Numerical Number of lodgings located near the charging station. store Numerical Number of stores located near the charging station. food Numerical Number of food stores located near the charging station. health Numerical Number of health institutions located near the charging station. restaurant Numerical Number of restaurants located near the charging station. school Numerical Number of schools located near the charging station. tourist_attraction Numerical Number of tourist attractions located near the charging station. district Categorical Name of the portuguese district where the charging station is located. Table 2: Data structure and meaning of each attribute. 3.2 Data Understanding and Exploration According to the suggested methodology, it is essential to use exploratory and visualization techniques once the data has been imported into the development environment in order to gain useful insights 38
CHAPTER 3. EXPERIMENTAL SETUP of the data being worked with. Typically, understanding the variables , identifying patterns and relationships between attributes and spotting outliers are the three main phases that make up data exploration and understanding. When the use case involves a supervised problem, the initial step in the phase of understanding the variables is to clearly identify the target and the predictor attributes. In the use case presented in this document, and taking into account the attributes presented in Table 2, the target feature is the attribute dailyHours. Since one of the main goals in this dissertation is to identify if a charging station should be placed in a particular location, it is conceivable that the dailyHours attribute, which records the number of hours a specific charging station was used on a given day, is an indicator of the potential popularity of a future charging post. Furthermore, it is also relevant to analyse the types and the distributions of the attributes of the dataset. As shown in table 2, the dataset contains both numerical, categorical and date type features and also with different formats such as single values or even lists of values. Overall, the original dataset contains 363149 rows and 23 attributes, taking into account a total of 2456 charging stations. These observations were recorded between the dates of May 5th of 2022 and September 9th of 2022. Additionally,the observations of the dataset cover a total of 306 distinct Portuguese cities that are dispersed throughout Portugal’s 18 districts as well as the two archipelagos of the Azores and Madeira. Figure 11 makes it possible to see how these cities are distributed geographically, and we can deduce that the density of installed charging points is larger in the northern and central cities of Portugal, particularly in places close to the coastline. Moreover, in Figure 12 it becomes apparent that Lisboa has the highest amount of charging posts installed. This is expected given that Lisboa is the fourth European capital city with the highest density of EVs charging stations (2.09 charge stations per 1000 kilometers) [59]. Lisboa is also Portugal’s region with the highest average salary and has the country’s highest population density. Figure 11: Geographical distribution of charging posts. 39
CHAPTER 3. EXPERIMENTAL SETUP The attributes city,district,parking_type and weather are nominal categorical features. This means that the values of the attributes are non-numerical and don’t have any inherent order. As depicted in Figure 13, there are six alternative potential locations for charging stations, namely PARKING_LOT, PARKING_GARAGE, ON_STREET, ALONG_MOTORWAY, UNDERGROUND_GARAGE and ON_DRIVEWAY. The most common location to place charging posts for EVs is in parking lots. Additionally, and according to Figure 14 there is seven potential values for the attribute weather, these being Clear, Clouds, Fog, Rain, Smoke, Drizzle and Mist. Cloudy is the most common type of weather registered in the observations. It is also crucial to emphasize that the value of the attribute weather is the one that is registered during the hour of busiest use of of the correspondent charging post. Considering this, it is reasonable to draw the conclusion that the categorical attributes under analysis exhibit a considerable class imbalance that results in an non-uniform distribution of the features. Furthermore, and in line with what was previously discussed in subsection 2.1.2, each charging post may be equipped with one or more connectors, which are the plugs on the power cord that link the supply device to the charging outlets on the electric vehicle. Based on the analysis of Figure 15, it is evident that the majority of charging posts are equipped with two connectors, although charging posts with one or three connectors are also prevalent. Although the highest number of connectors observed in a single charging post is twelve, the frequency of such instances is remarkably low. Figure 12: Number of charging posts per district. Figure 13: Parking Type Count. 40
CHAPTER 3. EXPERIMENTAL SETUP Figure 14: Weather Count. Figure 15: Number of Connectors. According to Figure 16 the shape of the distribution of the target variable is similar in all districts of the country. More specifically, and taking into account the general density plot in Figure 17, it is possible to verify that the attribute dailyHours does not present a normal distribution, but a right skewed distribution which means that the mean is greater than the median. As a result, the majority of the charging stations in the contemplated in the dataset display an approximate amount of 0 to 10 daily hours of usage. Figure 16: Distribution of the variable dailyHours per district. Figure 17: Distribution of the variable dailyHours. To gain a comprehensive understanding of a dataset, it is crucial to not only examine its individual attributes but also analyze their interrelationships and correlations. With the heat map plot shown in Figure 18 it is possible to visualize the correlation coefficients between all the numerical attributes. A correlation coefficient, which can range from -1 to 1, is a statistical indicator of the strength of the 41
CHAPTER 3. EXPERIMENTAL SETUP linear relationship between two variables. Values near -1 denote a high inverse correlation, those near 1 denote a strong positive correlation, and those near 0 denote a very week correlation. Is is important to highlight that the presence of highly correlated features in a dataset is generally discouraged, as it can lead to increased algorithmic complexity and a higher risk of errors. While a group of correlated features may not provide significant additional information, they can complicate the learning process and reduce the effectiveness of the algorithm. Usually, among two correlated attributes, it is removed the one that has the lowest correlation with the target feature. Taking this into account, and according to Figure 18 it is possible to visualize that there is a considerable strong linear relationship, with a correlation coefficient of 0.77, between the features restaurant and food. This occurrence is expected given that all restaurants are all establishments that serve food near a given area. Furthermore, as the attributes connectors_amperage,connectors_voltage and connectors_electric_power are in a list format, they cannot be directly incorporated into a correlation matrix, which only accepts numerical object types. Consequently, some preprocessing methods had to be used in the stage of data exploration of the methodology. The approach consisted in calculating the median of the each list and storing the results in four new numerical attributes denominated connectors_amperage_median,connectors_voltage_median and connectors_electric_power_median. The median was used since it is a statistical measure more robust than the mean being less affected by outliers and skewed data. Based on the information presented in Figure 18, it is evident that attributes connectors_amperage_median,connectors_voltage_median and connectors_electric_power_median exhibit a notably high correlation coefficient with each other, which is expected since the amount of energy that flows through a system is equal to voltage multiplied by the number of ampers. This way, the attributes connectors_amperage_median,connectors_voltage_median can be removed without compromising the overall amount of information of the dataset. 42
CHAPTER 3. EXPERIMENTAL SETUP Figure 23: Behaviour of the feature day. Figure 24: Behaviour of the feature day after cyclical transformations. It is important to emphasize that the features date,day,weekday and month were dropped and the correspondent sine and cosine values were added as attributes. In the use case presented in this dissertation, the preprocessing stage starts with feature selection which consists in selecting the significant features from a data set by removing the irrelevant and redundant features in order to improving the performance of the ML algorithms in terms of validation metrics and time to build the model. Firstly the highly correlated attributes analysed in Figure 18 were removed. When two or more variables are highly correlated, they carry almost the same information, making it redundant to include all of them in a model. This correlation is a problem because independent variables should remain independent. If this is not the case, a problem known as multicollinearity arises when the ML model has difficulty in estimating the impact that each independent variable has on the target variable independently because the independent variables tend to change in unison. For this reason, the attributes connectors_amperage,connectors_voltage were removed due to their high correlation coefficient with connectors_electric_power. The features partyId and LocationId are also irrelevant to the problem in hands, hence can be removed from the dataset. Even though a higher number of features may lead to an increase of complexity and a model’s run time, adding new relevant attributes also has advantages. First of all, it will improve the models predictive power since additional features may provide new information and insights that were not captured by the original set of attributes. Moreover, it will also enhance the model’s generalization capabilities due to the fact that by providing new information, the model may learn more robust and generalized patterns, reducing the risk of over-fitting and improving performance on new, unseen examples. Hence, it was added to the dataset a new attribute denominated density_2021 which, for each city in Portugal, indicates the average number of individuals per Km 2 registered in the year of 2021 [60]. With this information is will 49
CHAPTER 3. EXPERIMENTAL SETUP be possible for the model to understand the impact that the population density of areas have on the daily hours of usage of the charging points. An additional challenge emerged from the presence of attributes structured in a list format, namely and connectors_electric_power. Given the inherent inability of ML algorithms to process such information directly, the utilization of preprocessing techniques became imperative to successfully transform the data while preserving its integrity. The chosen approach consisted in simply converting all the elements in the list into new numeric attributes (columns) of the dataset. It is important to emphasize that n new attributes were created, being n the highest number of connectors registered on a charging station. This way, each new attribute will have a numeric value associated. However, if a certain charging station has a lower number of connectors then the maximum number, then all attributes that correspond to non-existent connectors will have a value of 0. Besides the attributes in a list format, it is also necessary to encode the categorical variables. For the attributes parking_type and weather is was employed the technique of one-hot encoding . Onehot encoding consists in representing categorical variables as binary vectors. This approach treats each category as independent, which is helpful when the categories do not have an inherent order. It ensures that no category is considered greater or lesser than another. This way, one-hot encoding transforms categorical data into numeric representations by partitioning a single column into multiple columns. A dummy (binary) variable just takes the value 0 or 1 to indicate the exclusion or inclusion of a category. Taking this into account, it is important to highlight that one of the drawbacks associated with the utilization of one-hot encoding is the fact that it increases the dimensionality of the dataset. Consequently, this technique is not the most suitable for the attribute city since it exhibit a large number of unique categories. Hence, in this particular scenario, the technique of Binary Encoding was employed as a viable alternative. With Binary Encoding, the distinct categories of the attribute are encoded as integers and then converted into the respective binary code. Lastly, the digits of the binary number form separate columns. It is noteworthy that the greatest advantage of Binary Encoding over One-Hot Encoding is undoubtedly the ability to reduce the dimensionality of the feature space. Unlike one-hot encoding, which creates a separate binary feature for each category, binary encoding represents each category with a binary code. As an example, if one-hot encoding was used the attribute city would create 306 new features (one for each city), however with Binary Encoding only 9 new features were created (9 bits are necessary to represent numbers from 1 to 306). The next step in the pre-processing stage of the methodology consisted in treating the outliers that 50
CHAPTER 3. EXPERIMENTAL SETUP were identified in Section 3.2. When it comes to deal with outliers in a dataset, there isn’t a one-size- fits-all technique as the choice of method depends on the specific characteristics of the data and the problem at hand. Despite the numerous existing methods to handle outliers, this study will focus on the following strategies: interquartile range, winsorization, and no elimination of outliers. Moreover, it is also important to highlight that the analysis and removal of outliers has to be done individually by each district, because each district has different scenarios when it comes to the daily hours of usage of charging posts. As for example, an outlier in the district of Braga might not be an outlier in the district of Lisboa. AS previously concluded, outliers may represent genuine and meaningful data points that reflect unusual or extreme events and provide valuable insights into rare occurrences. Since such outliers can contribute to a more comprehensive understanding of the data and leading to potentially valuable and actionable findings, removing these extreme values might lead to misleading interpretations, as a result of the overall distribution and characteristics of the data being altered. For this reason only outliers that represent measurement errors, data entry or processing errors, or poor sampling can be removed without compromising the final evaluation. A possible solution of dealing with outliers without having to remove those observation from the dataset is Winzorization. Winzorization is a data transformation technique whose goal is to minimize the influence of outliers in the data by either assigning the outlier a lower weight, or changing the value so that it is close to other values in the set. In other words, consists in setting extreme outliers to less extreme values. In this process, the highest values above a certain threshold are set to the threshold value, while the lowest values below a certain threshold are set to that threshold. Commonly used thresholds for Winsorization include the 1st and 99th percentiles, where values below the 1st percentile are replaced with the value at the 1st percentile, and values above the 99th percentile are replaced with the value at the 99th percentile. This technique helps maintain the overall shape and characteristics of the data while reducing the influence of extreme values. However, a relevant downside of Winsorization is information loss. By transforming the data, the original values are being discarded, which can potentially affect the representation and accuracy of the data. In Figure 25 boxplots are used to visualize the new distribution of the data points for each district, after applying this technique considering the 1st and 99th percentiles. In comparison to Figure 21, it is possible to conclude that there was an accentuated reduction in the dispersion of the values of the attribute daily_hours. While in 21 the values could reach close to 200 hours, after using winsorization, this value reduces to around 70 hours. 51
CHAPTER 3. EXPERIMENTAL SETUP Figure 25: dailyHours per district after Winsorization. Trimming is another technique for handling extreme values and it simply entails removing outlier observations from the dataset. There are various methods of trimming being Z-Score and Interquartile Range two extensively used methods.It is noteworthy that since the data, as seen in Section 3.2, exhibits an accentuated skewed distribution, the Interquartile Range method proves to be a better approach in comparison to other methods like Z-Score which assumes that the data follows a Gaussian distribution. This being said, this method was applied for each district, with the intention of removing outliers of the target attribute daily_hours and consequently obtaining a more representative and robust dataset. The Interquartile range method consists in determining: the first quartile (Q1) which is the median of the lower half of the data set, the third quartile (Q3) is the median of the upper half of the data set and calculating the Interquartile Range (IQR), which is equal to Q3-Q1. In addition, it is also necessary to define a normal data range with lower limit and upper limit, being these defined by the following equations: 𝐿𝑜𝑤𝑒𝑟𝐿𝑖𝑚𝑖𝑡 =𝑄1−1.5×𝑄3 𝑈𝑝𝑝𝑒𝑟𝐿𝑖𝑚𝑖𝑡 =𝑄1+1.5×𝑄3 This way, any data point outside this range is considered as outlier is removed for further analysis. In Figure 26 boxplots are used to visualize the new distribution of the data points for each district, after the removal of the outliers. In comparison to Figure 21, it is possible to conclude that there was an accentuated 52
CHAPTER 3. EXPERIMENTAL SETUP reduction in the dispersion of the values of the attribute daily_hours. After the removal of outliers using the interquartile method, the value of the attribute dailyHours reduces to around 50 hours. The number of total observations also reduces from 362705 to 343678 means the elimination of 19027 observations. Figure 26: dailyHours per district after Interquartile Range Method. Lastly, another important step in the preprocessing stage consists in normalizing and standardizing data points. As previously explained in Section 1.2, normalization consists in re-scaling data, so the values of the attributes fall between 0 and 1 while standardizing consisting in transforming the features to have zero mean and unit variance. Both of the approaches present bring multiple advantages. First of all, the discrepancy in the scales of features can create problems for many ML algorithms that are sensitive to the relative magnitudes of features. By normalizing or standardizing the data, we bring all features to a similar scale, ensuring fair comparisons and preventing one feature from dominating the learning process. In addition, by bringing the features to a similar scale, the coefficients or weights assigned to each feature become more interpretable and comparable, consequently improving the model performance and aiding in the interpretability of the results. It is important to emphasize that Standardization presupposes that the data has a normal distribution. Therefore, it won’t be the best technique for the dataset used in the use case of this dissertation, because the data points have a skewed distribution. For this reason, is it sufficient to only normalize the features. 53
CHAPTER 3. EXPERIMENTAL SETUP 3.4 Modeling The modeling phase is a crucial step in the development of intelligent systems, consisting in the design, implementation, training and evaluation of multiple algorithms capable of extracting valuable insights based on the available data. It serves as a bridge between raw data and actionable insights, enabling the transformation of complex information into meaningful patterns and predictions. This phase involves selecting the most appropriate algorithms for the use case, designing and fine-tuning model architectures, and training models using pre-precessed datasets. The goal in this obtain a working model that can then be validated, tested and deployed. Generally, the modeling phase involves five main steps which are contemplated in Figure 27. Firstly, it is a common practice to split the dataset in three main subsets: train, validation and test. The training subset is used to train the model, allowing it to learn the underlying patterns and relationships in the data. The training set should be as representative as possible of the population being modeled. Additionally, it is important to ensure that the training set is as unbiased as possible, as any bias introduced at this stage can propagate downstream during the training process. Furthermore, the validation set serves as an unbiased evaluation set during the model development process, allowing the tuning of hyperparameters and assessing the generalization ability of the model. Finally, the test set serves as a final checkpoint before deploying the model into real-world applications and it offers an unbiased assessment of model’s performance on unobserved data. A commonly used ratio in literature consists in 80% of data points for training, 10% for validation and 10% for testing. However, the structure of the dataset presents a particularity. Since there is a chronological order within the observations and the goal of this study is to use historical data to predict the expected future attractiveness of a potential charging station, splitting the dataset randomly might not be the best approach. Given that the model will be trained on historical data and used to test unknown future observations, splitting the dataset so that the train and validation data are observations that occurred before the test data is the most realistic approach. For this reason, it was necessary to sort the observations by date before applying data splitting. In order to split the data, firstly the last 10% of observations (10% most recent) were considered the test set and would be only used to do a final evaluation of the models. For the training set it was employed The Time Series Technique . In this strategy the data is divided into folds or ”windows”. The number of folds depends on the desired balance between training and validation, but in literature is commonly used 3 or 5 folds. In this dissertation 5 folds were used. Moreover, each window will have a training set and a validation set, the ML model will be train and its performance it’s evaluated and stored. Finally, the windows moves on 54
CHAPTER 3. EXPERIMENTAL SETUP to the next train and validation sets. It is important to highlight that in this approach a fixed-size rolling window slides through the data and this data the data is split into non-overlapping folds. Furthermore, another strategy important to refer is GridSearchCV which is an effective method for tuning hyperparameters and consequently finding the optimal combination for them is crucial as it can significantly impact the model’s performance and ability to generalize well to new, unseen data. A model’s hyperparameter is a configuration that is external to the model that control various aspects of a model’s behavior, as for example the learning rate, number of branches in a decision tree or the number of hidden layers in a neural network. GridSearchCV exhaustively searches through a predefined grid of possible values to find the optimal combination that maximizes model performance. For this reason, this technique was adapted into the time split process by being applied within each fold of the cross-validation. In ML, there is a vast range of algorithms that can be employed. However, choosing the algorithms which will result in models with a good performance is not a linear process since the selection of algorithms is highly dependent on the use case and on additional factors such as number of features in the data set, size of the training data, performance, computer resource requirements, and speed. However, once the ML models have been trained and fine-tuned using the training and validation datasets, they are tested on the separate, independent test dataset that has not been used during the training or hyperparameter tuning stages. Evaluating the performance of the models on unobserved data provides an unbiased measure of their effectiveness in real-world scenarios. As previously explored in 2.2.4 multiple evaluation metrics are available to assess the performance of the different models. Once the testing is completed, the overall most suitable model is the one have performed well (if not the best) in both training and testing phases. In light of this, the algorithms used in the current study will be introduced and analysed next. It is important to note that the selection of the algorithms was heavily influenced by the literature, and more specifically, the algorithms that are most frequently employed for problems of this nature. Furthermore, the algorithms will also be presented in a structured manner, progressing in complexity from the simplest to the most complex. 55
CHAPTER 3. EXPERIMENTAL SETUP Figure 27: Steps of the Modeling phase 3.4.1 Decision Tree Decision trees are supervised and graph-basedML algorithms that can be used for both classification and regression problems. Figure 28 shows the general structure of a decision tree. As it is possible to visualize, these trees are comprised of a root node, branches, internal nodes, and leaf nodes, forming a hierarchical, tree-like structure. In this figure we can observe three kinds of nodes: •Root Nodes: Is the node that starts the graph. It represents the entire population or sample and this further gets divided into two or more homogeneous sets. •Intermediate nodes: When a sub-node splits into further sub-nodes, then it is called the intermediate node. These are nodes where variables are evaluated but which are not the final nodes where predictions are made. •Leaf nodes: Nodes that do not split are called Leaf or Terminal nodes. These are the final nodes of the tree, where the predictions of a category or a numerical value are made. The leaf nodes represent all the possible outcomes within the dataset. 56
CHAPTER 3. EXPERIMENTAL SETUP Figure 28: Architecture of a decision tree. Decision tree learning employs a divide and conquer strategy by conducting a greedy search to identify the optimal split points within a tree. At each decision node, one of the features of the dataset is evaluated in order to split the observations in the training process or to make an specific data point follow a certain path when making a prediction. During the training process, the decision trees are built by recursively evaluating different features and using at each node the feature that best splits the data. When the study case is a classification problem the Gini impurity and Information Gain methods are the two that are most frequently used as a splitting criterion in decision tree models. Information gain represents the difference in entropy before and after a split on a given attribute. The attribute with the highest information gain will produce the best split since its succeeding in classifying the training data according to its target classification. Moreover, Entropy is a concept that derives from information theory, which measures the impurity of the sample values. On the other hand, the Gini Impurity of a dataset is a number that ranges between 0 and 0.5, which indicates the likelihood of a new, random data being mislabelled if it were given a random class label according to the class distribution in the dataset. When the study case is a regression problem other approaches as for example choosing for the split the attribute that presents the lowest standard deviation or the attribute which reduces metrics such as absolute error or squared error. 3.4.2 Random Forest Random Forest is a ML supervised algorithm that can be used for both classification and regression tasks. This algorithm is based on the concept of ensemble learning which is a ML technique that combines several base models in order to produce one optimal predictive model. As it is possible to 57
CHAPTER 3. EXPERIMENTAL SETUP visualize in Figure 29, random forests operate by constructing a multitude of decision trees at training time. In the end, the multiple decision trees and merges them together to get a more accurate and stable prediction. For classification problems, the output of the random forest is the class selected by most trees. However, with regression problems, the mean or average prediction of the individual trees is returned. Figure 29: Architecture of a random forest. Ensemble learning uses two types of methods: Bagging and Boosting . The random forest algorithm is an extension of the bagging method as it utilizes both bagging and feature randomness to create an uncorrelated forest of decision trees. Feature randomness, also known as feature bagging or ”the random subspace method”generates a random subset of features, which ensures low correlation among decision trees. Furthermore, the Bagging method, also known as Bootstrap Aggregating consists in training each decision tree using a different training set. This method randomly draws a fixed number of samples from the training set with replacement. This means that a data point can be drawn more than once. The random data points that each decision tree utilizes are called bootstrap samples. In addition to the bootstrap samples, and as previously referred, in the training process of random forests it is also draw random subsets of features for training the individual trees; For each split of the tree building, its computed the best splitting using only a randomly selected subset of the features. This is another way to ensure that the decision trees are as different as possible. As consequence of the random feature selection, the trees are not only more independent of each other, but also it often results in better predictive performance. 58
CHAPTER 4. RESULTS AND DISCUSSION the highest 𝑅2 Score the lowest MAE and Mean Squared Error. The value of 0.64 for the 𝑅2 Score is a satisfactory result and model explained a moderate portion of the variance. In case of the Decision Tree, in Figure 32, is visible that the model tends to predict values higher than the real ones while, in Figure 34, the Random Forest appears to have more difficulty in predicting high values for the attribute dailyHours. With this, and by comparing the standard deviations of both models, it is possible to understand that the Decision Tree is more more impacted by the extreme values present in the training phase. This is because a higher standard deviation indicates that the data points are more spread out from the mean and there is a greater degree of variability or deviation from the central value. Furthermore, despite the fact that the XGBoost and the Random Forest obtained comparable metrics, it is possible to see in Figure 36 that the XGBoost model is creating a number of undesirable outputs, more specifically is predicting negative values. Since the target is a time measure it cannot be below zero. It is also noteworthy, taking into consideration both Table 3and Figure 33 the overall performance of the Decision Tree increased significantly. However, according to also Figure 35 and Figure 37, the hyperparamenter tuning didn’t improve the performance of the Random Forest and the XGboost, even though the XGBoost model produced less frequent negative outputs. Figure 32: Predicted vs Actual Values using Decision Tree Regressor, for the district of Lisboa. Figure 33: Predicted vs Actual Values using Decision Tree Regressor with max_depth = 10, for the district of Lisboa. 65
CHAPTER 4. RESULTS AND DISCUSSION Figure 34: Predicted vs Actual Values using Random Forest Regressor, for district of Lisboa. Figure 35: Predicted vs Actual Values using Random Forest Regressor with max_depth = 20, for district of Lisboa. Figure 36: Predicted vs Actual Values using XGBoost, for district of Lisboa. Figure 37: Predicted vs Actual Values using XGBoost with max_depth = 20, for district of Lisboa. Taking into consideration the Table of results, the LSTM is not the adequate model for the observation of the district of Lisboa. In all three networks, the evaluation metrics are undesirable and below the metrics obtained with the Decision Tree, Random Forest and XGBoost. In addition, in all three LSTM networks, the validation and training curves reveal a big gap at the end of the training process, with this gap being more prominent when a higher number of epochs is used, as shown in Figure 38, Figure 40 and Figure 42. The training curves are smooth and decreasing in each iteration, while the validation curves are irregular and keep on increasing, which proves that the model is failing to predict unseen data. In Figures 39, Figure 41 and Figure 43, it corroborates what was just explained. All three LSTM networks do not capture at all the variance of the real dataset, producing unrealistic and results close in value, which is proven by the 66
CHAPTER 4. RESULTS AND DISCUSSION low standard deviation compared to the Decision Tree, Random Forest and XGBoost. Another reason why the LSTM networks are not the adequate models if the negative 𝑅2 Score. This negative metric indicates that this models are not capturing the underlying patterns in the data, and may be making predictions that are worse than simply using the mean of the dependent variable. Figure 38: Validation and training curves of LSTM. Figure 39: Predicted vs Actual Values using an LSTM network. Figure 40: Validation and training curves of LSTM. Figure 41: Predicted vs Actual Values using an LSTM network. Figure 42: Validation and training curves of LSTM. Figure 43: Predicted vs Actual Values using an LSTM network. 67
CHAPTER 4. RESULTS AND DISCUSSION Taking into consideration the presented results and the analysis made throughout this section, it was possible to understand that the LSTM networks with the implemented architecture are not the most adequate for the data of the district of Lisboa. On the other hand, the Random Forest is the model that produces the best evaluation metrics in general. Moving on to analysing other district, in Table 4are presented the obtained results of the four models implemented to predict the daily hours of usage of future charging stations for the district of Porto. Similar to what was done for the district of Lisboa, an LSTM network was trained using a different number of epochs,firstly with 50 epochs followed by 100 and finally 150 epochs. Model Validation MAE Test MAE 𝑅2Score standard deviation Decision Tree 5h 37min 5h 46min 0.13 10.76 Decision Tree (max_depth = 10) 4h 57min 5h 13min 0.56 9.81 Random Forest 4h 16min 4h 20min 0.55 8.14 Random Forest (max_depth = 20) 4h 28min 4h 45min 0.64 9.96 XGBoost 4h 16min 4h 51min 0.53 8.21 XGBoost (max_depth = 20) 4h 30min 4h 41min 0.46 8.79 LSTM 50 epochs – 7h 20min -0.11 1.22 LSTM 100 epochs – 9h 00min -0.52 7.27 LSTM 150 epochs – 8h 58min -0.47 6.94 Table 4: Results of the multiple models on the district of Porto. According to the previous table,out of the three, not considering tuning, the Random Forest model is the one that produces the lowest MAE and the highest 𝑅2 Score. A value of 0.55 for 𝑅2 Score is a satisfactory result and model explained a moderate portion of the variance. By comparing Figure 44 and Figure 46, more specifically the extreme values that the Decision Tree is producing, it is possible to see that, as similar to what was verified in Lisboa, the Decision Tree model predictions tend to be sparser than the Random Forest prediction. Once again this is justified by the fact that the Decision Tree has a higher standard deviation and therefore the prediction are more disperse. In addition, despite the fact that the XGBoost and the Random Forest obtained comparable metrics, it is possible to see in Figure 48 that 68
CHAPTER 4. RESULTS AND DISCUSSION the XGBoost model is creating a number of undesirable outputs, more specifically is predicting negative values. Since the target is a time measure it cannot be below zero. It is also noteworthy, by Table 4, Figure 45 and Figure 47 that hyperparameter tuning improved the overall performance of the Decision Tree and the Random Forest. On the other hand, the XGBoost model reduces its performance slightly, however, and taking into consideration Figure 49, with a max_depth of 20 it does not produce negative outputs, which is a more desirable outcome. Figure 44: Predicted vs Actual Values using Decision Tree Regressor, for district of Porto. Figure 45: Predicted vs Actual Values using Decision Tree Regressor with max_depth = 10, for district of Porto. Figure 46: Predicted vs Actual Values using Random Forest Regressor, for district of Porto. Figure 47: Predicted vs Actual Values using Random Forest Regressor with max_depth = 20, for district of Porto. 69
CHAPTER 4. RESULTS AND DISCUSSION Figure 48: Predicted vs Actual Values using XGBoost, for district of Porto. Figure 49: Predicted vs Actual Values using XGBoost with max_depth = 20, for district of Porto. Similar to what was verified for the district of Lisboa, the LSTM networks for the observations of Porto also under perform greatly. Here, the 𝑅2 Score is negative for the three networks which indicates that this models are not capturing the underlying patterns in the data, and may be making predictions that are worse than simply using the mean of the dependent variable. It is possible to see that an LSTM network trained with 50 epochs doesn’t produce desirable outputs. In Figure 50 it is possible to see that the validation error is stable until around epoch 30 and then increases, while the training error keeps on decreasing. However, in Figure 51 and according to the low standard variation of this model on Table 4, the produced results are not sparse enough and simply don’t capture the variance of the original data. For this reason, even though the MAE of theLSTM network with 50 epochs is lower than the other LSTM, it does not predict the actual values of dailyHours accurately. This is also corroborated by the fact that the standard deviation is extremely low. In Figure 50, the validation loss curve increases until around epoch 80 and then stabilizes a bit, while the training loss decreases significantly throughout the epochs. In Figure 51, the predicted values of the model present a higher standard deviation and therefore capture the variance of the original data better that the LSTM trained over 50 epochs. However, the results are still worse than the ones produced by the Decision Tree, Random Forest and XGBoost. 70
CHAPTER 4. RESULTS AND DISCUSSION Figure 50: Validation and training curves of LSTM. Figure 51: Predicted vs Actual Values using an LSTM network. Figure 52: Validation and training curves of LSTM. Figure 53: Predicted vs Actual Values using an LSTM network. Figure 54: Validation and training curves of LSTM. Figure 55: Predicted vs Actual Values using an LSTM network. To conclude and taking into consideration the presented results and the analysis made throughout this section, it was possible to understand that the Random Forest with a max_depth of 20 was the most adequate model for the data regarding the district of Porto. 71
CHAPTER 4. RESULTS AND DISCUSSION 4.2 Attractiveness of Charging Stations In order to gain insight into the variables that have the most influence on the attractiveness of charging station’s, and consequently answer the first research question raised in 1.3, the SHAP library, was utilized. SHAP values, short for SHapley Additive exPlanations, is a technique of the AI explainability and is mathematical method to explain the predictions of ML models by computing the contribution of each feature to that prediction. As result, this library can determine the most important features and their influence on the model prediction. In the previous section, the model with the highest performance was determined and Accordingly, this particular model will be utilized for evaluating the impact of the multiple features. To accomplish this, the model will be trained, separately, on observations of specific districts. Since it would repetitive to use this approach for every single district, in this study it will be considered the 3 districts with the highest number of observations. As previously referred, these districts are Lisboa, Porto and Setúbal. Moreover, the graphics that will be used to provide insight into the SHAP values is called the beeswarm plot, available within the SHAP library. In this type of graphic, features appear ordered by their effect on prediction, but it i also possible to see how higher and lower values of the feature will affect the result. The horizontal axis represents the SHAP value, while the color of the point shows us if that observation has a higher or a lower value. In order to facilitate both the analysis and the visualization of graphics, it will be plotted only the 10 features with the highest impact on the daily hours of usage of charging stations. In Figure 56 it is presented the plot with the 10 features that most impact the daily hours of usage of charging stations in the district of Lisboa. Firstly, the feature dailySessions with the greatest influence. It is possible to visualize that when the number of charging sessions for a specific charging stations decreases, the daily hours also reduces, which makes sense. This happens because the amount of charging hours is inversely correlated with the frequency with which automobiles utilize a charging station on a given day. For the district of Lisboa, the type of parking is also a highly important feature. Since parking_type_ON_STREET is a binary attribute, it means that the when the parking of charging station is located on a conventional street, it tends to attract more users and therefore increasing the daily hours of usage. It is also noteworthy that the highest the value of longitude, the target also tends to increase, while on the other hand a smaller value of latitude increases the target. Regarding points of interest, it is possible to conclude that the presence of nearby health facilities positively impacts the most the attractiveness of a location for a future charging station. In the Figure is also present the attribute density_2021 and it is shown that in areas where the population density is lower, the expected daily hours of usage of a charging 72
CHAPTER 4. RESULTS AND DISCUSSION station tend to reduce, while in areas with higher population density, the target value is also higher. This a realistic conclusion since locations where the population is bigger, increases the changes of more people owning EVs and consequently utilizing the charging stations service. Finally, the number of connectors also have a significant effect on the target since the smaller the number of connectors present on the station, the target value tends to decrease. Figure 56: Beeswarm plot representing the impact of the attributes on the target, for the district of Lisboa. In Figure 57 it is presented the plot with the 10 features that most impact the daily hours of usage of charging stations in the district of Porto. Similar to the scenario in Lisboa, the attribute dailySessions is the feature with the greatest impact and a decrease in its value implicated a negative impact on the target. When it comes to the coordinates, it is possible to visualize that higher values of longitude tend to increase the target while with latitude, higher values tend to decrease the target. In addition, in Porto the number of connectors is also a very relevant attribute. In Figure 57, it is shown that a higher number of connectors translates in an significant increase in the daily hours of usage of future charging stations. When it comes to points of interest, in Porto the presence of not only health facilities and stores but also lodging and food positively impact the target. 73
CHAPTER 4. RESULTS AND DISCUSSION Figure 57: Beeswarm plot representing the impact of the attributes on the target, for the district of Porto. In the previous three plots there was also present attributes referring specific connectors, as for example connector_1_power. However, since the data used to plot these graphics contains observations from multiple locations, with different numbers of connectors and distinct powers for each connectors, it is not possible to realistically understand the impact of a specific connector on the target. However, as verified on the previous analysis of the plots, the overall number of connectors on a charging station has a positive impact and the electric power of two or three connectors on the station is what will result in a variation of the daily hours of usage that charging station. Logically, it is possible to conclude that charging station will draw more consumers if it includes two or three connectors with a higher power because doing so results in faster and more efficient charging periods. 4.3 Predicting dailySessions As proved in the previous Section, the attribute dailySessions has an important effect on the target attribute. Moreover, the goal in this study is to evaluate the attractiveness of potential locations for future charging stations and therefore the models developed aim to predict the expected future daily hours of usage of those same locations, if charging station were to be installed. However, similar to the target attribute, the feature dailySessions, which indicates the number of times a charging station changed states (on a specific day), is unknown for future dates. The easiest way of dealing with this challenge would be removing the attribute, but by doing so, the model’s performance would be significantly affected as a whole. For this reason, the best course of action is to also predict the attribute dailySessions.In order to 74
CHAPTER 4. RESULTS AND DISCUSSION is only able to do so for a specific future day. However, to evaluate the attractiveness of location it is not relevant to know the expected daily hours of usage on a specific day, since what matters is the average daily hours of usage over a period of time. For this reason, the final model would have to be applied to all days of period of time and then the average of all the singular results would be the indicator for the level of attractiveness. Nonetheless, another challenge arises. Since the data used to train the model is historical data, some of the features are uncertain for the future. For instance, there is no way to know for sure how is weather going to be for a specific day next month or the electric powers of connectors for a charging station that is not even installed yet. To solve this, it was created a new dataset that contemplates all the possible combination of days, connectors electric power and weather. This means, that for each day, there is a row for each possible weather and for each combination of electric power of connectors. Of course, it is also taken into consideration the already known information of the location such as, parking type, city or coordinates. Furthermore, to choose the period of time over when the final model would make predictions, it was chosen an amount of days which would be enough to predict reliable results but would respect the tight time restrictions of this study. This way, the final results are obtained for a period of time starting on October 1st until December 31st. Another relevant aspect is the values for the electric power of connectors and the number of connectors to considerate. To do this, it was taken into consideration the conclusions of section 4.2 where it is possible to see that for Lisboa and Porto there are 3 and 2 connectors, respectively, on the top 10 of most impactful features on the target. For these reason, it was considerate 3 connectors with electric power above 0. In addition, the values for this electric power was obtained by making all possible 3�tuple with the values from the original dataset. Having this being done, the model to predict the attribute dailySessions was applied to each row followed by the final model to predict the target. In the end the dataset of ordered from the highest value of predicted daily hours of usage and then the top 10 was printed in the final report. The final report for the districts of Lisboa and Porto and the chosen locations for the test are in Appendix A. As it is possible to see in the reports, for the location in Lisboa, a charging station with 3 connectors, each with 3700 watts,3700 watts and 7200 watts respectively will generate a daily usage of about 17 hours and 8 minutes. This value, compared to the graphic in Fig 22, is above the average daily hours of usage of the district of Lisboa, which means that the location chosen appears to be attractive. The same thing was verified for the district of Porto. The highest prediction of the attribute dailyHours is 19h and 31 minutes which is definitely above the average daily hours of usage of charging stations in the district, as seen in Figure Fig 22. 81
Chapter 5 Conclusion This chapter will be centered around a summary of the results obtained during this study experiments, the future work and some final closing remarks. 5.1 Conclusions The goal of this dissertation was to assist We Can Charge in optimizing the location of charging stations for EVs. With this study it was possible to analyse, for specific districts in Portugal, the expected average daily hours of usage, if a charging station was to be installed in a certain pre-defined location. This way, it was possible to conclude which locations are going to have an affluence high enough to compensate the investment of installing and managing the charging station. In this study, we went through a specified methodology consisting of multiple steps which went from analysing and exploring the dataset, followed by data engineering and transformation processes, implementation of ML models and finally the analysis of the obtained results. Along this path, there were some challenges. First of all, the data’s time period was rather short even though the provided dataset had a disproportionately large number of rows. Additionally, there was research and discussion on how to process attributes in a list format and even what outlier treatment to use (or even if there should be a treatment). Moreover, since there is a obvious time sequence importance in the data, the modeling stage also raised some questions, mainly regarding how to split the data. Due to the fact that the final model is used to make prediction for future dates, the data split to be similar to what happens in real life, the train set and validation set should be observations prior to the test 82
CHAPTER 5. CONCLUSION data. Nonetheless, once these difficulties were overcome it was possible to implement models and analyse the outputs. Regarding the models, it was possible to conclude that out of the 4 models implemented, the Random Forest was the one that produced the most desirable outputs. Furthermore, the training process of the LSTM took the most time, as expected, specially when trained with a high number of epochs. In addition the employment of the final model as well as the consideration of all potential outcomes regarding the weather or connectors electric power, involved a significant amount of time. It is also noteworthy that with the results obtained during the experiments, it was possible to answer the main research questions previously stated in this document. Firstly, it was concluded that, it is indeed possible to employ ML techniques to address the challenge of optimizing the location of charging stations for EVs and it is also possible to determine which factors most impact the attractiveness of a location. However, by comparing the obtained results of the models with those obtained in the analysis of the state of the art, the obtained evaluation metrics do not surpass the ones in literature. 5.2 Future Work The realization of this study answered multiple questions, which are very relevant in the challenge of managing and expanding public charging infrastructure for EVs. Following this study, and in order to approximate the obtained results to those in literature, others strategies and techniques to approach the problem could be implemented. Firstly, within the supervised learning paradigm, more algorithms could be implemented and tested, as for example, investing more in alternative types of neural networks with special focus on Time Series data. Due to time restrictions, the LSTM network could not be deeply explored as initially intended and for this reason, trying change parameters of these models, as for example, the number of layers or number of nodes could be an interesting future approach. On the other hand, unsupervised approaches could also be successfully implemented. However, in this scenario, instead of developing ML models to predict the number of daily Hours of usage of a future charging station, the developed models would directly predict the locations where those charging stations should be installed. A possible strategy to be used to achieve this is clustering. In addition to changing learning paradigms, adding more information to the dataset can also be an interesting future work. For instance, adding more observations regarding the daily usage of already installed charging stations, or even adding new features such as features with information related to traffic levels near the locations of the charging stations. It is important to highlight that it was thought of adding traffic data through an external API, however these API are in most cases not 83
CHAPTER 5. CONCLUSION public and even paid. The bench marking could also be improved, by evaluating the model in the other districts of Portugal. In addition, it could also be interesting to deepen granularity by apply models to cities instead of districts. However,implementing this would result in increased computational cost and time, which were very limited during this study. 5.3 Final Thoughts The electric mobility paradigm goes through constant changes and innovations mainly due to the evolution of technology and the introduction of new methodologies. ML is gaining a highly relevant role in this paradigm specially in automatizing the management and expansion public infrastructures for EVs as presented in this dissertation. This thesis can be viewed as one more step in that direction, since it explores multiple approaches to predict the daily hours of usage of future charging stations, and consequently predicting the best locations to install them. To finish, it is expected that this thesis can prove to be useful to future works electric mobility field. 84
Bibliography [1] R. P. Singh, A. Singh, and V. Srivastava. Environmental Issues Surrounding Human Overpopulation. Hershey, PA, USA: IGI Global, 2017. [2] European Commission and Directorate-General for Communication. European green deal : delivering on our targets. https : / / ec . europa . eu / info / strategy / priorities - 2019 - 2024/european-green-deal_en. Accessed: 2022-10-29. 2021. doi: doi/10.2775/373022. [3] European Commission and Directorate-General for Climate Action. European climate pact. Accessed: 2022-10-29. Publications Office of the European Union, 2021. doi: doi/10.2834/43590 . url: https://ec.europa.eu/clima/eu-action/european-green-deal/europeanclimate-pact_pt. [4] Agência Portuguesa do Ambiente. Plano Nacional de Energia e Clima (PNEC). https://apambiente. pt/clima/plano-nacional-de-energia-e-clima-pnec. Accessed: 2022-10-29. [5] European Environment Agency. Greenhouse gas emissions from transport in Europe. https : // www.eea.europa.eu/data-and-maps/indicators /transport -emissions -of - greenhouse-gases/transport-emissions-of-greenhouse-gases-12 . Accessed: 2022- 10-29. [6] McKinsey & Company. Why the automotive future is electric. https://www.mckinsey.com/ industries / automotive - and - assembly / our - insights / why - the - automotive - future-is-electric. Accessed: 2022-10-30. [7] International Energy Agency. Global EV Outlook 2022. https://iea.blob.core.windows. net/assets/ad8fb04c-4f75-42fc-973a-6e54c8a4449a/GlobalElectricVehicleOutlook2022. pdf. Accessed: 2022-10-30. 85
BIBLIOGRAPHY [8] European Automobile Manufacturers’ Association. E-mobility: 14,000 public charging points should be installed weekly across EU, new analysis shows. https : / / www . acea . auto / press - release / e - mobility - 14000 - public - charging - points - should - be - installed - weekly-across-eu-new-analysis-shows/. Accessed: 2022-10-30. [9] United Nations Environment Programme, International Resource Panel. The Weight of Cities: Resource Requirements of Future Urbanization. 2018. url: http://hdl.handle.net/20.500. 11822/31623. [10] United Nations Environment Programme, International Resource Panel. Resource efficiency & green economy. url: https://www.unep.org/explore-topics/resource-efficiency/whatwe-do/cities/resource-efficiency-green-economy. [11] E. Estevez, N. V. Lopes, and T. Janowski. “Smart Sustainable Cities – Reconnaissance Study.” In: (2016). [12] World Commission on Environment and Development. Our Common Future. Oxford University Press, 1987. [13] UCLA Sustainability Committee. What is Sustainability? url: https://www.sustain.ucla.edu/ what-is-sustainability/. [14] A. M. Toli and N. Murtagh. “The Concept of Sustainability in Smart City Definitions.” In: (2020). doi: 10.3389/fbuil.2020.00077. [15] European Commission. “Smart cities.” In: (). Accessed: 2022-11-21. [16] InsightsIAS. “Insights into Editorial: The smart cities project must promote diversity.” In: (2018). Accessed: 2022-11-23. [17] A. Georgiadis, P. Christodoulou, and Z. Zinonos. “Citizens’ Perception of Smart Cities: A Case Study.” In: Applied Sciences 11.6 (2021). issn: 2076-3417. doi: 10.3390/app11062517 . url: https://www.mdpi.com/2076-3417/11/6/2517. [18] United Nations Economic Commission for Europe. Sustainable Smart Cities. https://unece. org/housing/sustainable-smart-cities. Accessed: 2022-11-25. [19] A. Augustyn. “Smart Cities – brand cities of the future.” In: (2013). [20] Smart City Indicators. https : / / www . beesmart . city / en / smart - city - indicators . Accessed: 2022-11-24. 86
BIBLIOGRAPHY [21] B. Chakravorti and R. S. Chaturvedi. The “Smart Society” of the Future Doesn’t Look Like Science Fiction. https://hbr.org/2017/10/the-smart-society-of-the-future-doesnt- look-like-science-fiction. 2017. [22] Sustainable Mobility for All. Sustainable Electric Mobility: Building Blocks and Policy Recommendations. Ed. by L. C. C. A. C. B. 3.0. Washington DC, 2021. [23] Types of electric cars and working principles. 2022. url: https://www.omazaki.co.id/en/ types-of-electric-cars-and-working-principles/. [24] J. A. Sanguesa, V. Torres-Sanz, P. Garrido, F. J. Martinez, and J. M. Marquez-Barja. “A Review on Electric Vehicles: Technologies and Challenges.” In: Smart Cities 4.1 (2021), pp. 372–404. issn: 2624-6511. doi: 10.3390/smartcities4010022 . url: https://www.mdpi.com/2624- 6511/4/1/22. [25] K. Parajuly and D. Ternald and R. Kuehr. The Future of Electric Vehicles and Material Resources: A Foresight Brief. UNU/UNITAR - SCYCLE (Bonn) & UNEP-IETC (Osaka), 2020, pp. 11–17. [26] H. Ritchie, M. Roser, and P. Rosado. “Energy.” In: Our World in Data (2022). https://ourworldindata.org/energy. [27] Capgemini Research Institute. The Automotive Industry in the Era of Sustainability. https:// www.capgemini.com/wp-content/uploads/2021/02/Infographic-The-Automotive- Industry-in-the-Era-of-Sustainability-1.pdf. Accessed: 2022-12-02. 2020. [28] U.S. Department of Energy and the U.S. Environmental Protection Agency. All-Electric Vehicles. Accessed: 2022-12-02. url: https://www.fueleconomy.gov/feg/evtech.shtml. [29] J. Gorzelany. By The Numbers: What It Costs To Maintain An Electric Vehicle. Accessed: 2022-12- 09. 2022. url: https://www.forbes.com/sites/jimgorzelany/2022/10/06/by-the- numbers-what-it-costs-to-maintain-an-electric-vehicle/?sh=38bfd4664d3e. [30] European Automobile Manufacturers Association. “Making the Transition to Zero-emission Mobility Addressing the Barriers to the Uptake of Electrically-chargeable Cars in the Eu.” In: (2018). [31] Institute for Energy Research. Electric Vehicle Battery Costs Soar. Accessed: 2022-12-06. url: https: // www.instituteforenergyresearch .org /renewable/ electricvehicle- battery-costs-soar/. 87
BIBLIOGRAPHY [32] G. Bhutada. Visualizing the Range of Electric Cars vs. Gas-Powered Cars. Accessed: 2022-12-08. url: https://www.visualcapitalist.com/visualizing-the-range-of-electric- cars-vs-gas-powered-cars/. [33] European Automobile Manufacturers’ Association. Electric cars: Half of all chargers in EU concentrated in just two countries. Accessed: 2022-12-06. url: https://www.acea.auto/pressrelease/electric-cars-half-of-all-chargers-in-eu-concentrated-in-just- two-countries/. [34] J. Conzade, F. Nägele, S. Ramanathan, and P. Schaufuss. Europe’s EV opportunity—and the charging infrastructure needed to meet it. Accessed: 2022-12-08. 2022. url: https://www. mckinsey.com/industries/automotive-and-assembly/our-insights/europes-ev- opportunity-and-the-charging-infrastructure-needed-to-meet-it. [35] H. Engel, R. Hensley, S. Knupfer, and S. Sahdev. “Charging Ahead: Electric Vehicle Infrastructure Demand.” In: (2018). [36] A. M. Turing. “Computing Machinery and Intelligence.” In: 59 (1950), pp. 433–460. issn: 00264423, 14602113. url: http://www.jstor.org/stable/2251299. [37] H. L. W. Thompson and A. Bolen. Artificial intelligence, machine learning, deep learning and beyond. 2018. url: https://www.sas.com/en_us/insights/articles/big-data/artificialintelligence-machine-learning-deep-learning-and-beyond.html. [38] H. Hassani, S. U. E. S. Silva, M. TajMazinani, and S. M. Feely. “Artificial Intelligence (AI) or Intelligence Augmentation (IA): What Is the Future?” In: AI 1.2 (2020), p. 143. issn: 2673-2688. url: https://www.mdpi.com/2673-2688/1/2/8. [39] PwC. “Sizing the Prize. What’s the Real Value of AI for Your Business and How Can You Capitalise?” In: (2020), pp. 3–4. url: https://www.pwc.com/gx/en/issues/analytics/assets/pwcai-analysis-sizing-the-prize-report.pdf. [40] AI, ML, and DL: How not to get them mixed! https://towardsdatascience.com/understandingthe-difference-between-ai-ml-and-dl-cceb63252a6c. Accessed: 2022-11-19. [41] J. P. Muller and L. Massaron. Machine Learning for Dummies. John Wiley & Sons, 2021, pp. 168– 172. 88
BIBLIOGRAPHY [42] J. Brownlee. What is the Difference Between a Parameter and a Hyperparameter? https:/ / machinelearningmastery.com/difference-between-a-parameter-and-a-hyperparameter/ . Accessed: 2022-11-19. 2019. [43] I. C. Education. What is Deep Learning? 2020. url: https://www.ibm.com/cloud/learn/ deep-learning. [44] A. Jung. Machine Learning: The Basics. Singapore: Springer, 2022, pp. 29–33. [45] Data Labeling. https://www.ibm.com/cloud/learn/data-labeling . Accessed: 2022-11- 11. [46] A. S. Lampropoulos and G. A. Tsihrintzis. “Machine Learning Paradigms: Applications in Recommender Systems.” In: 92 (2018), pp. 33–34. doi: 10.1007/978-3-319-19135-5. [47] What is Machine Learning? https : / / www . saagie . com / blog / machine - learning - definition/. Accessed: 2022-11-19. [48] V. Nasteski. “An overview of the supervised machine learning methods.” In: (2017), pp. 4–25. doi: 10.20544/HORIZONS.B.04.1.17.P05. [49] J. Brownlee. Difference Between Classification and Regression in Machine Learning. 2019. url: https://machinelearningmastery.com/classification-versus-regression-in- machine-learning/. [50] IBM Cloud Education. Unsupervised Learning. https : / / www . ibm . com / cloud / learn / unsupervised-learning. Accessed: 2022-11-11. 2020. [51] Association Learning. https://deepai.org/machine-learning-glossary-and-terms/ association-learning. Accessed: 2022-11-13. 2019. [52] P. Linardatos, V. Papastefanopoulos, and S. Kotsiantis. “Explainable AI: A Review of Machine Learning Interpretability Methods.” In: Entropy 23 (2021). [53] C. Molnar. “Interpretable Machine Learning.” In: (2023). [54] P. Jones and U. S. A. Lee. “Impedance-based forecasting of lithium-ion battery performance amid uneven usage.” In: Nature Communications 13.1 (2022), p. 4806. issn: 2041-1723. doi: 10. 1038/s41467-022-32422-w. url: https://doi.org/10.1038/s41467-022-32422-w. 89
BIBLIOGRAPHY [55] S. Padmanabhan, A. Petratos, A. Ting, K. Zhou, D. Hageman, J. R. Pisel, and M. J. Pyrcz. Optimal Placement of Public Electric Vehicle Charging Stations Using Deep Reinforcement Learning. 2021. doi: 10.48550/ARXIV.2108.07772. url: https://arxiv.org/abs/2108.07772. [56] D. Pevec, J. Babic, M. A. Kayser, A. Carvalho, Y. Ghiassi-Farrokhfal, and V. Podobnik. “A Data- Driven Statistical Approach for Extending Electric Vehicle Charging Infrastructure.” In: International Journal of Energy Research 42 (Feb. 2018), pp. 3102–3120. doi: 10.1002/er.3978. [57] M. Straka, P. D. Falco, G. Ferruzzi, D. Proto, G. V. D. Poel, S. Khormali, and L. Buzna. “Predicting Popularity of Electric Vehicle Charging Infrastructure in Urban Context.” In: IEEE Access 8 (2020), pp. 1–7. doi: 10.1109/access.2020.2965621. [58] T. Fontes, M. Arantes, P. V. Figueiredo, and P. Novais. “A Cluster-Based Approach Using Smartphone Data for Bike-Sharing Docking Stations Identification: Lisbon Case Study.” In: Smart Cities 5.1 (2022), pp. 251–275. issn: 2624-6511. doi: 10.3390/smartcities5010016 . url: https: //www.mdpi.com/2624-6511/5/1/16. [59] Ben Gallizzi. The European capitals with the highest density of EV charging stations. Accessed: 2023- 04-29. 2022. url: https://www.uswitch.com/electric-car/ev-charging/europeancapitals-best-density-ev-charging-stations/. [60] INE, PORDATA. Densidade populacional segundo os Censos. https : / / www . pordata . pt / municipios/densidade+populacional+segundo+os+censos-591 . Accessed: 2023-05-15. [61] S. Dobilas. LSTM Recurrent Neural Networks — How to Teach a Network to Remember the Past. https: // towardsdatascience. com/ lstmrecurrent-neural-networks -how -to - teach-a-network-to-remember-the-past-55e54c2ff22e. Accessed: 2023-08-22. 90