MACHINE LEARNING AND IoT FOR SMART GRID

: The current electricity grid is no longer an efficient solution due to increasing user demand for electricity, old infrastructure and reliability issues requires a transformation to a better grid which is called Smart Grid (SG). Also, sensor networks and Internet of Things (IoT) have facilitated the evolution of traditional electric power distribution networks to new SG, these networks are a modern electricity grid infrastructure with increased efficiency and reliability with automated control, high power converters, modern communication infrastructure, sensing and measurement technologies and modern energy management techniques based on optimization of demand, energy and availability network. With all these elements, harnessing the science of Artificial Intelligence (AI) and Machine Learning (ML) methods become better used than before for prediction of energy consumption. In this work we present the SG with their architecture, the IoT with the component architecture and the Smart Meters (SM) which play a relevant role for the collection of information of electrical energy in real time, then we treat the most widely used ML methods for predicting electrical energy in buildings. Then we clarify the relationship and interaction between the different SG, IoT and ML elements through the design of a simple to understand model, composed of layers that are grouped into entities interacting with links. In this article we calculate a case of prediction of the electrical energy consumption of a real Dataset with the two methods Recurrent Neural Network (RNN) and Long Short-Term Memory (LSTM), given their precision performances.


INTRODUCTION
In SG we are now with a large amount of data through the addition of smart metering equipment and the exponential evolution of SG infrastructure. This intelligent power grid enables two-way communication between the power grid and end customers, with emerging needs to monitor, predict, plan, learn and make decisions about energy consumption and production, in real time (Decebal Constantin Mocanu, 2016). This network has the advantage of better planning and exploiting electrical energy so the end customer becomes both consumer and producer of energy.
With SG, the end consumer is informed almost in real time of the amount of energy consumed by each electrical device used, which contributes to the reduction in consumption. All this is done through the interaction between the SG and the IoT (such as smart meters, sensors…) and energy prediction methods known as ML.
Since energy comes from three different resources like fossil fuels, renewable resources and nuclear (Ralph E.H. Simsa, 2003), it takes so much effort to track energy consumption of these types in different areas. However, by doing this we can predict the amount of energy that is consumed in different areas and try to make plans, specialized for a specific use and area.
For all of the energy types mentioned above, estimating usage is useful for policy makers and decision makers. By knowing how much energy will be used for their process or job, they can think of certain changes to reduce the amount of energy used.
(Mocanu, 2016) grouped the electricity demand forecast into three categories, with short-term forecasts ranging from one hour to one-week, medium-term forecasts ranging from one week to one year, and long-term forecasts ranging for more than one year. The literature shows that short-term demand forecasting has received a lot of attention. These forecasts are important for the control of the electrical system, economic allocation and the electricity markets (Salah Bouktif, 2018). Conversely, medium and long-term forecasts have not been sufficiently studied despite their crucial inputs for power grid planning and budget allocation (Hyndman, R.J, Shu, F, 2010).
For the prediction we used the LSTM networks (Lin, T., Horne, 1996& Gers, F. A., 2000 integrated in the RNN, in which the connections between the units form an oriented graph along a sequence. This allows it to exhibit dynamic temporal behavior for a temporal sequence. It is a popular model that has shown great potential in many prediction models that rely on past data (Yi-Ting Tsai, 2018). Therefore, we want to exploit LSTM to solve this kind of problem and take advantage of the characteristic of this method to improve the accuracy of the prediction of electrical energy in buildings.
The remaining part of this paper is organized as follows: Section 2 present the SG and architecture, in Section 3 we talk about IoT, component architecture and SM as IoT. In the section 4 we study ML Model and prediction. We propose a simplified layered model with entity and interaction between ML, SG and IoT in Section 5. Finally, Section 6 presents the conclusions and provides an outlook about the planned future work.

Definition
Traditional power networks are being transformed into smart grids to solve the problems of existing electric system due to the flow of unidirectional information, wasted energy, and growing demand for energy, reliability and security. SG integrate computing and two-way communication capabilities with existing power infrastructures. They cover all levels of the energy value chain and are not limited to SM, they make intelligent use of sensors, embedded computing and digital communications to make the electricity network observable (measurement and visualization capacity), controllable (manipulation and optimization capacity), automated (ability to adapt and self-correcting) and fully integrated (full interoperability with existing systems and ability to incorporate a diverse range of energy sources) (M. FOUAD, 2019). Therefore, a SG requires connectivity, automation and monitoring of such devices. This is achieved with the help of the IoT. IoT helps SG systems support a variety of network functions throughout generation, transmission, distribution, and power consumption by integrating IoT devices (such as sensors, actuators, and SM), as well as providing connectivity, automation and monitoring of these devices (Cynthia Rudin, David Waltz, 2011).
The SG was introduced as a promising solution to reduce waste of electrical energy and to solve the problems of traditional power grids, enabling efficiencies, reliability, security, stability and increased demand in electrical energy. The main attributes of SG are that it offers self-healing, better quality of electricity, distributed generation and demand response, mutual operation and user participation, as well as effective asset management.

Architecture
From the architectural point of view, SG is composed of three building blocks: Home Area Networks (HANs), Neighborhood Area Network (NANs), and Wide Area Networks (WANs). The connectivity of distributed RERs (Renewable Energy Resources), Plugin Electric Vehicles (PEVs), consumer devices, and SM present within the premises of consumers will be the responsibility of HANs. HANs are thus responsible for the charging of PEVs. In addition, it is estimated that homes are the places where 50% of total electricity is consumed (B. Heile, 2010).
Multiple HANs will be connected through the NANs. NANs are composed of Automatic Metering Infrastructure (AMI) and Field Area Networks (FANs). A comparison of AMI and FANs is elaborated in (K. H. Chang, 2013). WANs is responsible to connects NANs with power utility facilities and control center.

Customer side
In SG smart meters play the main role on the customer side and are considered the first basis for the efficient operation of SG. In order for power providers to deliver agile and better quality of service to customers, two-way metering interfaces are used to obtain information on customers' energy demand needs (M. Bae, H. Kim, 2014).
With advances in SM, sensor-based approaches can be exploited to provide a forecast of the energy load needed to avoid a power outage (R.K. Jain, K.M. Smith, 2014). Data collected from SM and weather stations can be used by advanced artificial smart techniques and ML algorithms to correlate energy consumption with other variables such as temperature, radiation solar, time of day or time of year and occupancy (S. Papantoniou, D. Kolokotsa, 2014). Due to the rapid progress and application of low-cost options for energy metering in recent years, energy load forecasting is becoming more and more precise, cost effective and much more in demand (C. Fan, F. Xiao, 2014) (D. Kolokotsa, 2015).
With the use of methods based on the science of artificial intelligence and ML that allow the exploitation of datasets to build models for the prediction of energy consumption and peak power demand, with the aim of improving the accuracy of the forecast is constantly evolving. These ensemble models can be valuable tools for improving strategies for fault detection and diagnosis, and interactions between buildings and SG. In addition, the processing and interpretation of data extracted by SM can provide interesting information on the energy behavior of buildings.

Definition
The RFID group defines the Internet of Things as "The worldwide network of interconnected objects uniquely addressable based on standard communication protocols." IoT is a Group of infrastructures interconnecting connected objects and allowing their management, data exploration and access to the data they generate (Bruno.dorsemaine, 2015). The IoT provides a platform for sensors and devices to communicate seamlessly and enables information sharing between different platforms and devices. The recent adaptation of different wireless technologies places IoT as the next revolutionary technology taking advantage of all the opportunities offered by Internet technology. The IoT is applied in almost all areas such as smart cities, retail, agriculture, water, transport, healthcare and energy by adding intelligence (Mohsen .
A large number of communication devices in the IoT are integrated into sensor devices in the real world. Data collection devices detect data and transmit it using built-in communication devices. Devices and objects are interconnected through a variety of communication solutions, such as Bluetooth, WIFI, ZigBee and GSM. These communication devices transmit data and receive commands, which allow direct integration with the physical world through computer systems to enhance, automate and facilitate all functions.

Bi-Directionnal information and Power Flow
The International Archives of the Photogrammetry, Remote Sensing and Spatial Information Sciences, Volume XLIV-4/W3-2020, 2020 5th International Conference on Smart City Applications, 7-8 October 2020, Virtual Safranbolu, Turkey (online)

Component Architecture
Despite the number of possible application fields to which IoT and associated technologies can be applied, connected objects are still associated with the same type of architecture: data that must be transported, stored, processed and made available.
For a simpler architecture of the IoT, we distinguish between four levels (Bruno Dorsmanin, 2015): • The equipment level contains connected objects and local collection points. These elements communicate via wired technologies (Ethernet, optical fiber, etc.) or wireless links (L. P. Luca Mainetti, 2011) (Bluetooth Low Energy, Wi-Fi, ZigBee, etc.). Local pickup points (optional) can be smartphones, small computers and other items. They are used as gateways to access the infrastructure through objects that are not powerful enough (battery, computing power, etc.). Sometimes, they allow direct user interaction with objects (an application on a smartphone for example).
• The level of data transport or connectivity that allows collection objects or equipment to communicate with control servers.
• Cloud Management platform, data storage and mining usually take place in the cloud and enables data processing.
• Finally, the management portal the user or other systems can access the data via APIs or graphical interfaces.

Smart Meters as IoT
Smart meter is one of the use cases of the IoT application which generates a large amount of data from different sources, such as SG, water flows, and calculation of the silo stock, in which processing takes a long time, even on a dedicated site and powerful machine (Mohsen . A SM is a device that electronically records the data consumption of electrical energy between the meter and the control system. Collecting and analyzing data from SM in the IoT environment helps the decision maker to forecast electricity consumption. In addition, SM analysis can also be used to forecast demand to prevent crises and meet strategic goals through specific pricing plans. Thus, public bodies and private companies and other entities must be able to handle a high volume of data and advanced analytics in order to transform data into actionable information.

Definition
Machine learning is a subfield of AI that aims to develop algorithms that can learn automatically from data. In particular, an artificially intelligent agent must be able to recognize objects in its environment and predict the behavior of its environment in order to make informed choices (Pankaj Mehtaa, 2019). ML can be divided into three broad categories: supervised learning, unsupervised learning, and reinforcement learning. Supervised learning refers to learning from labeled data (for example, a collection of tagged images that may or may not contain a cat), Common supervised learning tasks include classification and regression.
Unsupervised learning aims to look for patterns and structure in unlabeled data. Examples of unsupervised learning include grouping, dimensionality reduction, and generative modeling.
Finally, in reinforcement learning, an agent learns by interacting with his environment and modifying his behavior to maximize his reward. For example, a robot may be trained to navigate a complex environment by assigning a great reward to the actions that help it reach the desired destination (Seyedeh Narjes Fallah, 2018).
A ML algorithm is needed to train an energy consumption prediction model. Previous studies in data-driven building energy consumption prediction have utilized SVM, ANN, decision trees, and/or other statistical algorithms (Kadir Amasyali, 2018).

Machine learning models
For each model considered, there are several variations proposed in the literature, below we give a taxonomy of the most used ML models: ANN, DT, RNN, MLP, SVM/SVR, ELM, WNN, HYBRID METHODES, and DEEP LEARNING.

The role of ML in Prediction
A ML method consists of four main steps, which are data collection, data preprocessing, model training, and model testing (Wang Z, 2017). Many ML algorithms and prediction models with these steps are used to predict the energy consumption of buildings. Artificial intelligence-based prediction models can be categorized into three categories, which are simple, aggregate, and hybrid based on their prediction components. Unique prediction models use a learning algorithm, aggregate models include several prediction models, which are integrated to determine the output data.
Hybrid models combine at least two ML techniques. These models are more robust than others because they frequently exhibit the advantages of integrated techniques and provide improved forecasting accuracy (Jui-Sheng Chou, 2018). Accurate forecasting will further help businesses meet customer planning and management requirements. Prediction can be classified from various perspectives such as: economic forecasting, earthquake prediction, gain prediction, financing against risk forecasting, land use forecasting, the performance of players and teams in sports predictions, political prediction, different types of product prediction, sales and tax forecasting, technology overview and forecast, prediction in the telecommunications sector, transport planning and transport forecasting, different types of environmental parameter forecast, flood forecasting and meteorology, real-time energy, electricity demand forecast, different trends in wind speed forecast, and solar radiation forecasting, etc. Short-term (ST) predictions generally based on tactical objectives, which involve production control and planning. Medium Term (MT) prediction is used for decisive secondary management in different parts of the industrial sector as well as in public services. Long Term (LT) prediction is important for LT arrangements to be adopted in an industry or organization, and they correlate with the supplying indications (Tanveer Ahmad, 2020).

Related Works
In the literature on the prediction of electrical energy with the collection of data by IoT smart meters equipment in SG networks, there are several articles, we find a list of prediction articles with ML methods by (Amir Mosavi, Abdullah Bahmani, 2018), and another work show a detailed scope, data properties, algorithms and performance of energy consumption prediction models (Kadir Amasyali, Nora M. El-Gohary, 11 January 2018).
For the presentation of a model of interaction between all the elements we find the model Smart Grid Architecture Model (SGAM) already has a widespread use and has exceeded its initial objective of documenting the shortcomings of the standardization (Mathias Uslar 15 January 2019), another SG engineering study a modeling and design of the use case according to SGAM and design of a conceptual function (Filip Pröstl Andrén, 16 March 2017).

Entity Interaction Model:
Our model is based on three entities and four relationships, it is a simplified representation of the interaction between the SG network at the center, with the information gathering IoT entity and the ML prediction methods that exploit received data for validation.

Figure 3. The taxonomy of Research
The International Archives of the Photogrammetry, Remote Sensing and Spatial Information Sciences, Volume XLIV-4/W3-2020, 2020 5th International Conference on Smart City Applications, 7-8 October 2020, Virtual Safranbolu, Turkey (online) Figure 5. Simplified Entity Interaction Model

Descriptive Layered Model: Our model consists of five layers which can be grouped into three entities:
IoT Layer: Responsible for collecting information and data through sensors, smart meters, cameras or any equipment capable of capturing and receiving information and transmitting it.
Electrical Layer: Represents the electrical network that provides the necessary infrastructure for the transport of electrical energy from the source of production to the end customer through the distributor of electrical energy.
Communication Layer: The communication layer makes it possible to ensure the network connection between all the parts of the network via the communication protocols, these elements communicate through wired technologies (Ethernet, optical fiber, etc.) or wireless links (Bluetooth Low Energy, WIFI, ZigBee, etc.), (L. P. Luca Mainetti, 2011).

Information Layer:
This layer ensures the storage and processing of all the information received by powerful computing servers which have the capacity to store and process the information received in almost real time, these computing units are located in data centers in cloud or in the private cloud (local proprietary datacenter), the architecture of these units are designed to be scalable and extensible by increasing the storage capacity and processing resources in parallel linearly, this architecture is used by large firms which daily use a large amount of data like Google, Amazon, Facebook, Apple ...

Artificial Intelligence Layer:
This is the application layer that enables ML algorithms to learn from the received data or datasets and to make the prediction in a short time with better precision.

Validation:
All of the layers described above are illustrated in a real architecture in a SG network for the purpose of minimizing the consumption of electrical energy by controlling the flow of energy production and reducing the cost of consumption for the customer by the prediction of the electrical energy consumption, the customer can track his consumption in real time through to the installation of SM, below the descriptive diagram of our model.   Table   before showing the results, we briefly describe the RNN, LSTM method, recurrent neural networks of which LSTM are the most powerful and well-known subset, are a type of artificial neural network designed to recognize patterns in sequences of data, such as numerical times series data from sensors, stock markets The International Archives of the Photogrammetry, Remote Sensing and Spatial Information Sciences, Volume XLIV-4/W3-2020, 2020 5th International Conference on Smart City Applications, 7-8 October 2020, Virtual Safranbolu, Turkey (online) and government agencies (but also including text, handwriting and the spoken word). What differentiates RNNs and LSTMs from other neural networks is that they take time and sequence into account, they have a temporal dimension (A.I. Wiki, 2019).

Recurrent Neural Network:
is basically a generalization of feed-forward neural network that has an internal memory. RNNs are a special kind of neural networks that are designed to effectively deal with sequential data. This kind of data includes time series (a list of values of some parameters over a certain period of time) text documents, which can be seen as a sequence of words, or audio, which can be seen as a sequence of sound frequencies over time.
RNN is recurrent in nature as it performs the same function for every input of data while the output of the current input depends on the past one computation. For deciding, it considers the current input and the output that it has learned from the previous input. Figure 7. RNN with input X and output Y with multiple recurrent steps and a hidden unit.
Long Short-Term Memory: LSTM is an improved version of the regular RNN which was designed to make it easy to capture long-term dependencies in sequence data. A regular RNN functions in such a way that the hidden state activation is influenced by the other local activations nearest to them, which corresponds to a Short-Term Memory, while the network weights are influenced by the computations that take place over entire long sequences, which corresponds to Long-Term Memory. Hence the RNN was redesigned so that it has an activation state that can also act as weights and preserve information over long distances, hence the name Long Short-Term Memory (Nagesh Singh Chauhan, 2019).  We use also R² regression score function, the coefficient of determination, noted R² or r², is a measure of the quality of the prediction of a linear regression. It is defined by: ( 1) where n = number of measurements yi = value of measure n˚ i ŷ = corresponding predicted value ȳ = average of the measurements R² score for the values predicted by the trained SIMPLE RNN model equal to 0.9541.  The International Archives of the Photogrammetry, Remote Sensing and Spatial Information Sciences, Volume XLIV-4/W3-2020, 2020 5th International Conference on Smart City Applications, 7-8 October 2020, Virtual Safranbolu, Turkey (online) Figure 11. Predictions comparison We can add other input parameters such as weather, solar radiation and prices and other information to have better precision.

CONCLUSION
In this article we have clarified the complementarity, synergy and correlation between the field of ML for prediction, the IoT for information collection and the SG intelligent network which ensures the transfer of electrical energy in two-way and agile communication between all stakeholders in the network.
In addition, we proposed a simplified model made up of five layers (IoT, Electrical, Communication, Information, Artificial Intelligence) grouped into three entities (IoT, Smart Grid, Machine Learning) and linked with four relationships (Sensing, Actuating, Training, Forecasting) which facilitates the understanding of the interaction between all the elements constituting our study.
At the end we made the prediction of the short-term electrical energy with the use of the RNN-LSTM method, we have seen the advantages that it presents in particular the recalls of the previous states, and after the test on real Dataset with frequency of one hour over a period of 10 years we have found that this method gives better accuracy.
In future work we can better improve the prediction by adding other input parameters such as weather and other useful information and also using hybrid methods which have shown their effectiveness in the latest research, as well. For better performance and reliability, we recommend carrying out studies for the standardization of communication protocols and information media and implementing solutions to improve computing power in order to use the results in real time to help decision.