# Time Series Prediction of Electricity Demand Using Adaptive Neuro-Fuzzy Inference Systems

Authors: Amevi Acakpovi; Alfred Tettey Ternor; Nana Yaw Asabere; Patrick Adjei; Abdul-Shakud Iddrisu
Journal: Mathematical Problems in Engineering
 (2020)

---

## Abstract

This paper is concerned with the reliable prediction of electricity demands using the Adaptive Neuro-Fuzzy Inference System (ANFIS). The need for electricity demand prediction is fundamental and vital for power resource planning and monitoring. A dataset of electricity demands covering the period of 2003 to 2018 was collected from the Electricity Distribution Company of Ghana, covering three urban areas namely Mallam, Achimota, and Ga East, all in Ghana. The dataset was divided into two parts: one part covering a period of 0 to 500 hours was used for training of the ANFIS algorithm while the second part was used for validation. Three scenarios were considered for the simulation exercise that was done with the MATLAB software. Scenario one considered four inputs sampled data, scenario two considered an additional input making it 5, and scenario 3 was similar to scenario 1 with the exception of the number of membership functions that increased from 2 to 3. The performance of the ANFIS algorithm was assessed by comparing its predictions with other three forecast models namely Support Vector Regression (SVR), Least Square Support Vector Machine (LS-SVM), and Auto-Regressive Integrated Moving Average (ARIMA). Findings revealed that the ANFIS algorithm can perform the prediction accurately, the ANFIS algorithm converges faster with an increase in the data used for training, and increasing the membership function resulted in overfitting of data which adversely affected the RMSE values. Comparison of the ANFIS results to other previously used methods of predicting electricity demands including SVR, LS-SVM, and ARIMA revealed that there is merit to the potentials of the ANFIS algorithm for improved predictive accuracy while relying on a quality data for training and reliable setting of tuning parameters.


---

## Body

## 1. Introduction

Forecasting electricity demand is vital for power generation and planning. Accurate forecast of electricity demands presents a better understanding of the electricity network expansion and generation to sustainably cater for future demands [1–3].Similarly, a forecast of electricity demand informs network operators about the growth of the grid and provides optimal development and expansion of the Grid system. Load forecasting is important to satisfy the power demand and meet consumers growing electrical needs [4]. Load forecasting is a major field in electrical engineering especially power systems. The power industry requires a forecast to predict production and financial outlay. It is important to predict energy demand as well as peak power demand. Accurate information on electricity demand is a requirement in the reliable operation of power systems. Since electricity is expensive to store efficiently in large quantities, the amount generated at any given time must meet all the demand from consumers as well as grid losses.Load forecasting can, therefore, be defined as the estimation of future load conditions and their effect on power generation based on previous data [4]. Load forecasting is very crucial to decision-making in electrical energy production and distribution. To carry out a load forecast, past data records are necessary input decision variables. A load forecast can be more specific and may cover a range of possible outcomes.Load forecasting is used to decide whether extra generation must be injected into the grid by either increasing the output of the online generator system, by commissioning one or more extra generating units or by interchanging power with a less loaded generating system. In addition, load forecasts are used to decide whether the output of existing online generator must be reduced or switched off, which is determined by the generation control strategy used by the power system company like scheduling, unit-commitment, interchange evaluation, reserve management, economic load dispatch, and co-ordination [5, 6]. Consequently, the accuracy of forecasted loads directly impacts the financial outlay and reliability of system operations.Load forecasting is divided into three types according to the time period in which the forecast is undertaken. The three types of load forecasts are short-term, medium-term, and long-term load forecasting [7]. In short-term load forecasting [8], the aim is to estimate the load for the next half hour up to the next two weeks. Short-term load forecasting helps power system operators with various decision-making in the power system, including supply planning, generation reserve, system security, dispatching scheduling, demand-side management, and financial planning. Medium-Term Load Forecasting (MTLF) is a category of electric load forecasting that covers a time span of up to one year. It suits outages and maintenance planning, as well as load switching operation. Long-Term Load Forecasting (LTLF) is load forecasting that usually covers forecasting horizons of one to ten years and sometimes extends to several decades [9]. It provides weekly/monthly forecasts for peak and valley loads which are important to expand generation, transmission, and distribution systems. In addition, long-term forecasts are used for investment planning and the expansion of power system infrastructure.Load forecasting must be carefully done to avoid wrong planning or causing financial burden. An overestimation of load demand causes economic waste because huge financial commitment will be required for the construction of additional power capacity, while underestimation will result in unreliable supply or shortage of supply to customers.Load forecasting can also be classified into quantitative and qualitative methods. Quantitative methods are based on established mathematical analysis like the regression analysis, exponential smoothing, Box-Jenkins methods, and decomposition methods. Qualitative load forecasting methods sample views from experts in order to forecast future load intuitively. The latter method is used when previous or past data are not available for the analysis. These qualitative methods include the Delphi method, Technological comparisons, and subjective curving.This paper is concerned with a medium-term load forecasting Electricity demand for a selected town in the Greater Accra Region, Mallam town, which is densely populated. This study is useful in the generation capacity planning for future network upgrades due to the increasing load demand of the community. The rest of the paper is structured to cover the methodology, the result, discussion, and conclusion sections, respectively.


## 2. Literature Review

Electricity load forecasting is an activity that has been carried regularly in the past with numerous methods. The accuracy and reliability of this prediction varies based on the methodology used; some of the prominent methods used in the past to conduct time series electricity forecasting include the following: simple moving average (SMA), weighted moving average (WMA), simple exponential smoothing (SES), Holt linear trend (HL), Holt-Winters (HW), ARIMA models, vector autoregressive (VAR) forecasting models, and artificial neural networks and support vector machines (SVM). This section presents the strengths and weaknesses of the above-mentioned methods and makes a case for the consideration of the Adaptive Neuro-Fuzzy Inference System (ANFIS) in predicting electricity load forecast.Moving average is based on the calculation of average price over a given period, an average that is termed as moving. In other terms, it is the average of a selected range of prices by the period in that range. SMA is popularly used to determine price direction either upward or downward. SMA has been used for electricity demand prediction by a number of available studies [6, 10] even though its original strength has to do with cost prediction of goods that vary often like fuel. The exponential moving average (EMA) is an enhancement of the SMA that weights recent price action better. It has been proved that the longer the period of the SMA, the smoother the result. However, the same longer period introduces lags between the SMA prediction and its source.Weighted Moving Average (WMA) is a similar method to the Simple Moving Average but puts more weight on recent previous data than past ones. In WMA, a heavier weighting is assigned to more current data than past data. This approach enhances the prediction, and the method seems to be generally more accurate than the SMA. WMA also helps determine trend direction.Like the WMA, the exponential moving average also considers more weighting to recent data than past data; however, the difference between previous and current data follows an exponential model rather than being simply additive or incremental. The main difference is that the EMA reacts more significantly to recent price changes.Moving average (MA) techniques, however, have several limitations. Just like any other time series prediction tool, MA does not take into account the fundamental factors that affect electricity consumption and pattern, but it is only based on a history of recorded data. MA techniques have the flexibility to be spread out over any time period and this poses some challenges in terms of accuracy of prediction. In this regard, a prediction that seems to be upward for a 50-day prediction may turn to become downward for 200-days prediction. The emphasis on recent data seems to be challenging because the real factors affecting the pattern of electricity demand are not necessarily linked to recent data but to seasonal behavior of people, rain and dry seasons, and many more factors; the prediction may be more accurate depending on vast data.On the other hand, Holt-Winters (HW) methodologies are used to cater for seasonal changes in predicting electricity demand. There is great merit to this technique since electricity consumption for typical communities follows regular patterns based on seasons. In actual fact seasons determine the type and form of activities that communities carry and at the same time their capacity to generate electricity locally with renewables which subsequently reduce their reliance on grids. The Holt-Winter’s method is one of several exponential smoothing methods that have the power to directly analyse time series data. Several academic papers used the Holt-Winters method in the past to predict electricity demands [6, 11, 12]. Holt-Winters method falls under the category of exponential smoothening problems which are affected by some few factors. The first factor known as lag implies that the prediction often lags behind the actual trends [12, 13]. Also, exponential smoothening may be best suited for forecasts that are short-term rather than seasonal or cyclic.Moreover, ARIMA, known for Auto-Regressive Integrated Moving Average, is actually a robust method of forecast that determines its future values based on the known past value of the series only. The strength of ARIMA compared to exponential smoothening methods resides in the fact that ARIMA uses the autocorrelation between series of values while the latter targets trends and seasonality. According to [14], ARIMA models are mainly “backward looking” meaning their prediction lack accuracy at a turning point. ARIMA has been used intensively to predict electricity demand by the authors of [6, 11, 15, 16].Furthermore, Artificial Neural Network (ANN) has recently emerged as a reliable model for electricity demand prediction. According to [17], an Adaptive Neural Network is a computational model that is derived from a biological neural network. It is made up of highly interconnected processing elements called neurons that work together to resolve specific problems. ANNs are generally composed of three main elements, namely, neurons, interconnections, and learning rules. Neural networks have the capability to learn from real-life scenarios which may be very complex. ANN can easily handle nonlinear relationships between dependent and independent variables and are best suited for complex information processing. The main disadvantage has to do with the black-box nature of ANN. The black box implies that while approximating a function, there is less information on the internal structure of the ANN and how it approximates the function. ANN is however proving reliable and has gained widespread use in forecasting and optimisation theories. The following papers [4, 18–21] adopted ANN in forecasting electricity demand in various location and for varying durations.Likewise, support vector regression is another family of a neural network used for classification and forecasting of time series data with considerable accuracy. They are provided with learning algorithms, capable of handling linear and nonlinear problems especially with the recent introduction of the loss function of Vapbik’sε-intensity [22]. The authors of [23–27] used SVR models to predict several relevant variables using time series forecasting. Similarly, Dong et al. [28] combined SVR with a chaotic cuckoo search model. The Chaotic Cuckoo Search model is expected to improve on the capabilities of the original Cuckoo Search algorithm by diversifying the population and avoiding local optima. The objective of SVR is to find a function which may be defined for instance as(1)fx=wTφx+b,where fx denotes the forecasting values; w and b are adjustable coefficients and φx represents the mapping function that maps the training data into a high-dimensional feature space [22]. The coefficient is estimated by using any appropriate optimization method like the Lagrange multipliers or by minimizing some empirical risk functions.Hybridising SVR with other metaheuristic optimization techniques may lead to improved accuracy and results in predicting electricity demand. In this regard, Fan et al. [29] presented a hybridised model of SVR with an empirical mode decomposition (EMD) method and autoregression (AR) which was applied to data collected from New South Wales in Australia. The result of this hybridisation was mainly improved accuracy and interpretability. Chen et al. [30] performed a similar hybridisation using least square SVR, Fuzzy time series, and global harmony search algorithm. The resulting accuracy shows superiority in terms of predictive accuracy over existing methods such as ARIMA, Genetic Algorithm, and simple least square SVR. A similar hybrid system was developed by Hong et al. [31] who combined SVR with a Chaotic Immune Algorithm and demonstrated that the new system yielded better accuracy than the ARIMA and other forms of a hybrid system using SVR. Zhang et al. [32] further combined SVR with empirical mode decomposition (EMD) and the krill herd (KH) algorithm. His hybrid system also demonstrated superiority over the existing methods in terms of accuracy of prediction.SVR has many advantages that make it attractive especially when combined with other heuristic optimization techniques like simple Fuzzy logic, GA, EMD, and KH. Some of these advantages include effectiveness with high-dimensional spaces and memory efficiency [33]. On the other hand, SVR disadvantages include its computational complexity irrespective of the dimensionality of its input space [34]. SVR algorithms are also not suitable for large datasets especially in the presence of more noise.Recently there has been the development of an advanced form of ANN among which the combination of fuzzy logic and artificial neural network known as Adaptive Neuro-Fuzzy Inference Systems (ANFIS). While Fuzzy logic on its own is considered as a reliable method, its combination with ANN gives some advantages that are highly enviable in forecasting. ANFIS is a type of ANN that is derived from the Takagi–Sugeno fuzzy system [35–37]. It combines the benefits of fuzzy systems and ANN in a single framework, and it is perceived for this reason as the universal estimator.While it is believed that the prediction capabilities of ANFIS surpass all the previously listed methods in the literature, it is also remarkable to highlight the fact that there is no prevalence of previous studies on electricity load forecasting that adopted ANFIS. This is a claim of novelty in this study. ANFIS is therefore used in this study to predict electricity demands with more accuracy and reliability and also minimise considerably the lag problems encountered with the exponential and moving average methods.


## 3. Methodology

This study makes use of data on electricity demands collected from Mallam, Achimota, and Ga East, all towns in the Greater Accra Region of Ghana to predict future electricity need using ANFIS. The data was collected from the Electricity Company of Ghana that is the sole supplier of electricity to residents and companies in the Mallam area. The dataset used to train the model and to test for prediction comprises monthly electricity demand from the region for the period of June 2013 to February 2018. In total, there were 1200 samples in the dataset.


### 3.1. ANFIS Architecture

Consider a fuzzy inference system having two inputsx and y for simplicity and one output z. Based on a first-order Sugeno fuzzy model, the rule set using the “if-then rules” is depicted below:(2)Rule1:IfxisA1andyisB1,thenf1=p1x+q1y+r1,Rule2:IfxisA2andyisB2,thenf2=p2x+q2y+r2.The reasoning of the Sugeno model and its corresponding ANFIS architecture is illustrated in Figures1(a) and 1(b). In the diagram, the output of the ith node on layer l is denoted Ol,i.Layer 1: Every node belonging to this layer is designated as an adaptive node with an expression below:(3)O1,i=μAix,fori=1,2,orO1,i=μBi−2y,fori=3,4,wherex (or y) is the input to node i and Ai, Bi−2 is a label associated with the node. In other terms, O1,i is the membership grade of a fuzzy set AA1,A2,B1,B2 and it specifies the degree to which the input x (or y) satisfies the quantifier A. The membership function A can be any parametrized membership function like the Bell function defined as follows:(4)μAx=11+x−ci/ai2bi,whereai, bi, ci are the parameter sets. Variation in the values of these parameters affects the shape of the Bell function, thus exhibiting varying forms of membership functions.Layer 2: The output of nodes in this layer is the product of all the incoming signals:(5)O2,i=wi=μAixμBi−2y,i=1,2.Each node output represents the firing strength of a rule.Layer 3: At this level, theith node calculates the ratio of the ith rule’s firing strength to the sum of all rules’ firing strengths:(6)O2,i=wi¯=wiw1+w2,i=1,2.Output of layer 3 are called normalized firing strengths.Layer 4: All nodes in this layer are called adaptive node with a node function defined as follows:(7)O4,i=wi¯fi=wi¯pix+qiy+ri,wherewi¯ represents a normalized firing strength from layer 3 and pi,qi,ri, the parameter set of this node. Parameters in this layer are called consequent parameters.Layer 5: The single node in this layer computes the overall output as the summation of all incoming signals:(8)overall  output=O5,1=∑iwi¯fi=∑iwifi∑iwi.Figure 1
(a) A two-input first-order Sugeno Fuzzy model with two rules. (b) Equivalent ANFIS structure.
(a)(b)The five layers described above constitutes an adaptive network that is functionally equivalent to a Sugeno fuzzy model. The structure can be altered by combining for instance layers 3 and 4 to obtain an equivalent network with only four layers. The Sugeno model can further be extended to Tsukamoto ANFIS model. Furthermore, the Mamdani model can be derived from the first two models by using some discrete approximations and is finally far more complicated than the first two.


### 3.2. Application of ANFIS to the Data with Matlab

To use the ANFIS algorithm to train and then consequently use it for prediction, there are four main important steps to complete as illustrated in Figure2. These steps are discussed in the following points.Figure 2
Flow diagram of training and testing of ANFIS system.


#### 3.2.1. Constructing the Learning Contextual Elements

This is the point where the various contextual elements are formulated. The contextual elements are basically the factors that influence electricity demand. For electricity demand generally, the following factors are considered: economic growth, housing and population growth, income growth, and weather. Particularly for this paper, we considered the history of electricity demand that covers all the other factors listed. Historical data on these factors will help construct our feature set for a good training of the model.


#### 3.2.2. Input Selection for the System

After constructing the learning contextual elements, there is the need for the selection of the input for the system. The objective in selecting inputs is to eliminate irrelevant inputs or input that does not have a significant influence on the output and consequently reduce the time required to construct the model.


#### 3.2.3. ANFIS System Training Process

After data gathering and selection of the input parameters and contextual parameters, the ANFIS training system process begins by loading the training and checking dataset, which forms the two vectors used in the training of the ANFIS system. The data is loaded into the FIS model using the “genfis” function, to generate the initial membership functions of the premise parameters from the training data. After the initial membership functions are created, the “anfis” function is used to train the ANFIS system. The training data and checking data are fed to the “anfis” function as a matrix. The membership function created is also fed to the function to be used in the training of the data with the use of the “anfisOptions” function. The same membership function is used to supply the checking data for validation and checking. The “anfisOptions” is also used to provide the number of training epochs for the ANFIS system. After training is complete, the “evalfis” function is used to evaluate the performance of the system and provide the final output of the ANFIS system.


### 3.3. Prediction

At this point, the trained model is then used to make predictions for the future.The training of the model and execution of the prediction in MATLAB software for the simulation for this paper was done with the following procedures:(1)
The dataset was loaded and then plotted to obtain a graphical representation of the data. The dataset was then divided into two parts: the training data and the checking data which contained each 500 data values. The first 500 data values were used for training and the last 500 data values after the training data were used for testing and validation. The data division in MATLAB was performed with the two instructions below:(9)trnData=Data1:500,:;chkData=Data501:end,:.(2)
For time series prediction, a mapping fromD sample data points sampled every Δ units in time xt−D−1Δ,…,xt−Δ,xt is created to predict a future value xt+P. This was how the various input vectors and output vectors deduced as will be seen in the scenarios below.Subsequently, a number of scenarios have been considered to cover many reasonable assumptions under which the simulations were conducted.Scenario 1.
For the first scenario, four input sampled data units were used as input training data for the ANFIS algorithm. It was a four-column vector of the formw1t=xt−30,xt−20,xt−10,xt and the output training data for this scenario was x (t+10) and this is the future value from the above past values that we wish to predict in this scenario. The GENFIS was used to generate the initial FIS structure to train our ANFIS algorithm. The default values of the GENFIS function were used; therefore, a FIS structure with 2 member functions and two generalized bell membership functions on each of the four inputs was generated to train our ANFIS algorithm. This structure is supplied to the ANFIS algorithm through the “anfisOption” function. The check data was supplied to the ANFIS algorithm to perform validation. The ANFIS algorithm was trained with 10 epochs after which there was convergence.Scenario 2.
Five column vector of the formw2t=xt−40,xt−30,xt−20,xt−10,xt and output xt+10 was used. All other parameters were the same as in Scenario 1. The objective was to increase the history of past data which may subsequently affect the accuracy of the prediction.Scenario 3.
For this scenario,Scenario 1 was revisited, but this time around, the number membership of function for the FIS structure to be created was increased from 2 to 3. But all other parameters remained the same. The aim was to see the effect of the number of membership functions on the prediction.


## 3.1. ANFIS Architecture

Consider a fuzzy inference system having two inputsx and y for simplicity and one output z. Based on a first-order Sugeno fuzzy model, the rule set using the “if-then rules” is depicted below:(2)Rule1:IfxisA1andyisB1,thenf1=p1x+q1y+r1,Rule2:IfxisA2andyisB2,thenf2=p2x+q2y+r2.The reasoning of the Sugeno model and its corresponding ANFIS architecture is illustrated in Figures1(a) and 1(b). In the diagram, the output of the ith node on layer l is denoted Ol,i.Layer 1: Every node belonging to this layer is designated as an adaptive node with an expression below:(3)O1,i=μAix,fori=1,2,orO1,i=μBi−2y,fori=3,4,wherex (or y) is the input to node i and Ai, Bi−2 is a label associated with the node. In other terms, O1,i is the membership grade of a fuzzy set AA1,A2,B1,B2 and it specifies the degree to which the input x (or y) satisfies the quantifier A. The membership function A can be any parametrized membership function like the Bell function defined as follows:(4)μAx=11+x−ci/ai2bi,whereai, bi, ci are the parameter sets. Variation in the values of these parameters affects the shape of the Bell function, thus exhibiting varying forms of membership functions.Layer 2: The output of nodes in this layer is the product of all the incoming signals:(5)O2,i=wi=μAixμBi−2y,i=1,2.Each node output represents the firing strength of a rule.Layer 3: At this level, theith node calculates the ratio of the ith rule’s firing strength to the sum of all rules’ firing strengths:(6)O2,i=wi¯=wiw1+w2,i=1,2.Output of layer 3 are called normalized firing strengths.Layer 4: All nodes in this layer are called adaptive node with a node function defined as follows:(7)O4,i=wi¯fi=wi¯pix+qiy+ri,wherewi¯ represents a normalized firing strength from layer 3 and pi,qi,ri, the parameter set of this node. Parameters in this layer are called consequent parameters.Layer 5: The single node in this layer computes the overall output as the summation of all incoming signals:(8)overall  output=O5,1=∑iwi¯fi=∑iwifi∑iwi.Figure 1
(a) A two-input first-order Sugeno Fuzzy model with two rules. (b) Equivalent ANFIS structure.
(a)(b)The five layers described above constitutes an adaptive network that is functionally equivalent to a Sugeno fuzzy model. The structure can be altered by combining for instance layers 3 and 4 to obtain an equivalent network with only four layers. The Sugeno model can further be extended to Tsukamoto ANFIS model. Furthermore, the Mamdani model can be derived from the first two models by using some discrete approximations and is finally far more complicated than the first two.


## 3.2. Application of ANFIS to the Data with Matlab

To use the ANFIS algorithm to train and then consequently use it for prediction, there are four main important steps to complete as illustrated in Figure2. These steps are discussed in the following points.Figure 2
Flow diagram of training and testing of ANFIS system.


### 3.2.1. Constructing the Learning Contextual Elements

This is the point where the various contextual elements are formulated. The contextual elements are basically the factors that influence electricity demand. For electricity demand generally, the following factors are considered: economic growth, housing and population growth, income growth, and weather. Particularly for this paper, we considered the history of electricity demand that covers all the other factors listed. Historical data on these factors will help construct our feature set for a good training of the model.


### 3.2.2. Input Selection for the System

After constructing the learning contextual elements, there is the need for the selection of the input for the system. The objective in selecting inputs is to eliminate irrelevant inputs or input that does not have a significant influence on the output and consequently reduce the time required to construct the model.


### 3.2.3. ANFIS System Training Process

After data gathering and selection of the input parameters and contextual parameters, the ANFIS training system process begins by loading the training and checking dataset, which forms the two vectors used in the training of the ANFIS system. The data is loaded into the FIS model using the “genfis” function, to generate the initial membership functions of the premise parameters from the training data. After the initial membership functions are created, the “anfis” function is used to train the ANFIS system. The training data and checking data are fed to the “anfis” function as a matrix. The membership function created is also fed to the function to be used in the training of the data with the use of the “anfisOptions” function. The same membership function is used to supply the checking data for validation and checking. The “anfisOptions” is also used to provide the number of training epochs for the ANFIS system. After training is complete, the “evalfis” function is used to evaluate the performance of the system and provide the final output of the ANFIS system.


## 3.2.1. Constructing the Learning Contextual Elements

This is the point where the various contextual elements are formulated. The contextual elements are basically the factors that influence electricity demand. For electricity demand generally, the following factors are considered: economic growth, housing and population growth, income growth, and weather. Particularly for this paper, we considered the history of electricity demand that covers all the other factors listed. Historical data on these factors will help construct our feature set for a good training of the model.


## 3.2.2. Input Selection for the System

After constructing the learning contextual elements, there is the need for the selection of the input for the system. The objective in selecting inputs is to eliminate irrelevant inputs or input that does not have a significant influence on the output and consequently reduce the time required to construct the model.


## 3.2.3. ANFIS System Training Process

After data gathering and selection of the input parameters and contextual parameters, the ANFIS training system process begins by loading the training and checking dataset, which forms the two vectors used in the training of the ANFIS system. The data is loaded into the FIS model using the “genfis” function, to generate the initial membership functions of the premise parameters from the training data. After the initial membership functions are created, the “anfis” function is used to train the ANFIS system. The training data and checking data are fed to the “anfis” function as a matrix. The membership function created is also fed to the function to be used in the training of the data with the use of the “anfisOptions” function. The same membership function is used to supply the checking data for validation and checking. The “anfisOptions” is also used to provide the number of training epochs for the ANFIS system. After training is complete, the “evalfis” function is used to evaluate the performance of the system and provide the final output of the ANFIS system.


## 3.3. Prediction

At this point, the trained model is then used to make predictions for the future.The training of the model and execution of the prediction in MATLAB software for the simulation for this paper was done with the following procedures:(1)
The dataset was loaded and then plotted to obtain a graphical representation of the data. The dataset was then divided into two parts: the training data and the checking data which contained each 500 data values. The first 500 data values were used for training and the last 500 data values after the training data were used for testing and validation. The data division in MATLAB was performed with the two instructions below:(9)trnData=Data1:500,:;chkData=Data501:end,:.(2)
For time series prediction, a mapping fromD sample data points sampled every Δ units in time xt−D−1Δ,…,xt−Δ,xt is created to predict a future value xt+P. This was how the various input vectors and output vectors deduced as will be seen in the scenarios below.Subsequently, a number of scenarios have been considered to cover many reasonable assumptions under which the simulations were conducted.Scenario 1.
For the first scenario, four input sampled data units were used as input training data for the ANFIS algorithm. It was a four-column vector of the formw1t=xt−30,xt−20,xt−10,xt and the output training data for this scenario was x (t+10) and this is the future value from the above past values that we wish to predict in this scenario. The GENFIS was used to generate the initial FIS structure to train our ANFIS algorithm. The default values of the GENFIS function were used; therefore, a FIS structure with 2 member functions and two generalized bell membership functions on each of the four inputs was generated to train our ANFIS algorithm. This structure is supplied to the ANFIS algorithm through the “anfisOption” function. The check data was supplied to the ANFIS algorithm to perform validation. The ANFIS algorithm was trained with 10 epochs after which there was convergence.Scenario 2.
Five column vector of the formw2t=xt−40,xt−30,xt−20,xt−10,xt and output xt+10 was used. All other parameters were the same as in Scenario 1. The objective was to increase the history of past data which may subsequently affect the accuracy of the prediction.Scenario 3.
For this scenario,Scenario 1 was revisited, but this time around, the number membership of function for the FIS structure to be created was increased from 2 to 3. But all other parameters remained the same. The aim was to see the effect of the number of membership functions on the prediction.


## 4. Results and Interpretations

Figure3 shows a graphical representation of the entire dataset. This gives a pictorial representation of the electricity demand from 2013 to 2018.Figure 3
Graphical representation of the dataset.


### 4.1. Scenario 1

Membership functions are used to graphically represent a fuzzy set. Usually, each fuzzy set is mapped to a value between 0 and 1. Figure4 shows the plot of the initial membership function generated by the “genfis” function for each of the four inputs.Figure 4
Initial membership function (Scenario 1).The height of the graph indicates the maximum value of the membership function. Membership function gives a pictorial view of the value of each fuzzy set. A fuzzy set of height less than 1 is considered a subnormal fuzzy set and that with a height of 1 is a normal fuzzy set. This membership function is the fuzzy rule set that forms part of the initial FIS structure used to start training the ANFIS algorithm.Figure5 shows the plot of the final membership function that is derived at the end of the training. It contains the final fuzzy set rules for the ANFIS algorithm. The final membership function exhibited the least minimum checking error because the validation data option was properly set with enough data for training the ANFIS algorithm.Figure 5
Final membership function (Scenario 1).Figure6 shows the prediction of data done by the ANFIS algorithm in comparison with the actual data. It also shows the plot of the error in the prediction done by the ANFIS algorithm. The actual data is plotted in blue while the predicted data is in orange as indicated by the legend. The errors are really small as illustrated by the second graph on errors. Some peak values were however obtained towards a time limit of 1000 s. These may be due to some aberrant data that probably ought to be corrected with some more cleaning of data.Figure 6
Dataset vs. ANFIS output and prediction error (Scenario 1).


### 4.2. Scenario 2

After increasing the record of past data from 4 to 5 thereby creating a fifth input vector as a feature of the fuzzy set, the following results illustrated in Figure6 were obtained.Increasing the input vector by 1 doubled the number of fuzzy rules generated by the model which also had an impact on the speed and accuracy of the prediction. There is a minor difference between the predictions in Figure6 (Scenario 1) and Figure 7 (Scenario 2).Figure 7
Actual data vs. ANFIS prediction and prediction error (Scenario 2).


### 4.3. Scenario 3

Figures8–10 show the results obtained after increasing the number of membership functions for the same parameters of Scenario 1. The default number of the membership function is usually 2 which was applied for Scenario 1. For this test, the number of membership functions was increased to 3.Figure 8
Initial membership function (Scenario 3).Figure 9
Final membership function (Scenario 3).Figure 10
Actual data vrs. ANFIS prediction and prediction error (Scenario 3).Increasing the number of member function by 1 has considerably affected the number of fuzzy rules generated to be used in the prediction, an increase of about triple the initial number of rules. The number of rules subsequently affects the speed and accuracy of the prediction as it can be observed that there is a slight difference between the predictions in Figure6 (Scenario 1) and Figure 10 (Scenario 3).


### 4.4. Comparative Analysis with Other Methods of Electricity Demand Prediction

The prediction is repeated in Matlab software with the same input data using the SVR approach, the Least Square SVM, and the ARIMA model. The SVR model was applied in Matlab with the help of some special functions included in the LIBSVM library which provides a combination of functions that were used to apply the State Vector Regression approach on the same dataset. Some of the useful functions used in developing the code included the FITCSVM function previously known as SVMTRAIN which fits a classification Support Vector Machine and the SVMPREDICT function which classifies observations using support vector machine (SVM) classifier.Furthermore, the Least Square Support Vector Machine toolbox in Matlab was used to model the same data and perform the prediction with Matlab. Additionally, the ARIMA model was established and tested in Matlab using the estimate function which helped to evaluate the parameters of the ARIMA model. For each of the model tested, the Root Mean Square Error at the end of each epoch were evaluated and are summarized in Table1. Figures 11 and 12 give a histogram plot of the RMSE values of the different scenarios.Table 1
Root mean square values for each epoch considering all the scenarios.
Epoch numberANFISScenario 1ANFISScenario 2ANFISScenario 3SVRLS-SVRARIMARMSE values for trainingRMSE values for checkingRMSE values for trainingRMSE values for checkingRMSE values for trainingRMSE values for checkingRMSE values for trainingRMSE values for checkingRMSE values for trainingRMSE values for checkingRMSE values for trainingRMSE values for checking157.2167112.55846.4971103.66334.32916537.1466.4006170.88765.6463102.70170.3049148.376257.2117112.63146.4912102.5934.31636478.6665.3564170.89665.4131109.13670.3043148.409357.2067112.70546.4853101.5234.34096517.8964.8084170.90965.2659116.98970.3038148.432457.2017112.77946.4795105.15134.33476467.8664.6973170.92265.098117.01870.3032148.489557.1968112.85346.4736105.86834.33026480.1964.7074170.93464.6657120.45770.3027148.513657.1919113.92846.4677111.79534.33236557.9364.5821170.94864.2683121.73870.3022148.493757.1864113.0146.4613117.97734.38426594.0764.6992170.9663.6042119.82170.3016148.513857.181113.09346.4549119.55834.33166551.4864.5605170.97763.1597122.8570.301148.559957.1751113.17646.4485131.34234.34066524.0464.5173170.99263.0961123.91970.3004148.5961057.1703113.25946.4421132.51434.33386552.7864.4919171.00863.244384.491970.2998148.62Average57.19383112.999246.47012113.197834.337376526.20464.88211170.943364.34616113.9120970.30239148.5Figure 11
Comparative result of RMSE for training for different methods.Figure 12
Comparative result of RMSE for checking for different methods.


## 4.1. Scenario 1

Membership functions are used to graphically represent a fuzzy set. Usually, each fuzzy set is mapped to a value between 0 and 1. Figure4 shows the plot of the initial membership function generated by the “genfis” function for each of the four inputs.Figure 4
Initial membership function (Scenario 1).The height of the graph indicates the maximum value of the membership function. Membership function gives a pictorial view of the value of each fuzzy set. A fuzzy set of height less than 1 is considered a subnormal fuzzy set and that with a height of 1 is a normal fuzzy set. This membership function is the fuzzy rule set that forms part of the initial FIS structure used to start training the ANFIS algorithm.Figure5 shows the plot of the final membership function that is derived at the end of the training. It contains the final fuzzy set rules for the ANFIS algorithm. The final membership function exhibited the least minimum checking error because the validation data option was properly set with enough data for training the ANFIS algorithm.Figure 5
Final membership function (Scenario 1).Figure6 shows the prediction of data done by the ANFIS algorithm in comparison with the actual data. It also shows the plot of the error in the prediction done by the ANFIS algorithm. The actual data is plotted in blue while the predicted data is in orange as indicated by the legend. The errors are really small as illustrated by the second graph on errors. Some peak values were however obtained towards a time limit of 1000 s. These may be due to some aberrant data that probably ought to be corrected with some more cleaning of data.Figure 6
Dataset vs. ANFIS output and prediction error (Scenario 1).


## 4.2. Scenario 2

After increasing the record of past data from 4 to 5 thereby creating a fifth input vector as a feature of the fuzzy set, the following results illustrated in Figure6 were obtained.Increasing the input vector by 1 doubled the number of fuzzy rules generated by the model which also had an impact on the speed and accuracy of the prediction. There is a minor difference between the predictions in Figure6 (Scenario 1) and Figure 7 (Scenario 2).Figure 7
Actual data vs. ANFIS prediction and prediction error (Scenario 2).


## 4.3. Scenario 3

Figures8–10 show the results obtained after increasing the number of membership functions for the same parameters of Scenario 1. The default number of the membership function is usually 2 which was applied for Scenario 1. For this test, the number of membership functions was increased to 3.Figure 8
Initial membership function (Scenario 3).Figure 9
Final membership function (Scenario 3).Figure 10
Actual data vrs. ANFIS prediction and prediction error (Scenario 3).Increasing the number of member function by 1 has considerably affected the number of fuzzy rules generated to be used in the prediction, an increase of about triple the initial number of rules. The number of rules subsequently affects the speed and accuracy of the prediction as it can be observed that there is a slight difference between the predictions in Figure6 (Scenario 1) and Figure 10 (Scenario 3).


## 4.4. Comparative Analysis with Other Methods of Electricity Demand Prediction

The prediction is repeated in Matlab software with the same input data using the SVR approach, the Least Square SVM, and the ARIMA model. The SVR model was applied in Matlab with the help of some special functions included in the LIBSVM library which provides a combination of functions that were used to apply the State Vector Regression approach on the same dataset. Some of the useful functions used in developing the code included the FITCSVM function previously known as SVMTRAIN which fits a classification Support Vector Machine and the SVMPREDICT function which classifies observations using support vector machine (SVM) classifier.Furthermore, the Least Square Support Vector Machine toolbox in Matlab was used to model the same data and perform the prediction with Matlab. Additionally, the ARIMA model was established and tested in Matlab using the estimate function which helped to evaluate the parameters of the ARIMA model. For each of the model tested, the Root Mean Square Error at the end of each epoch were evaluated and are summarized in Table1. Figures 11 and 12 give a histogram plot of the RMSE values of the different scenarios.Table 1
Root mean square values for each epoch considering all the scenarios.
Epoch numberANFISScenario 1ANFISScenario 2ANFISScenario 3SVRLS-SVRARIMARMSE values for trainingRMSE values for checkingRMSE values for trainingRMSE values for checkingRMSE values for trainingRMSE values for checkingRMSE values for trainingRMSE values for checkingRMSE values for trainingRMSE values for checkingRMSE values for trainingRMSE values for checking157.2167112.55846.4971103.66334.32916537.1466.4006170.88765.6463102.70170.3049148.376257.2117112.63146.4912102.5934.31636478.6665.3564170.89665.4131109.13670.3043148.409357.2067112.70546.4853101.5234.34096517.8964.8084170.90965.2659116.98970.3038148.432457.2017112.77946.4795105.15134.33476467.8664.6973170.92265.098117.01870.3032148.489557.1968112.85346.4736105.86834.33026480.1964.7074170.93464.6657120.45770.3027148.513657.1919113.92846.4677111.79534.33236557.9364.5821170.94864.2683121.73870.3022148.493757.1864113.0146.4613117.97734.38426594.0764.6992170.9663.6042119.82170.3016148.513857.181113.09346.4549119.55834.33166551.4864.5605170.97763.1597122.8570.301148.559957.1751113.17646.4485131.34234.34066524.0464.5173170.99263.0961123.91970.3004148.5961057.1703113.25946.4421132.51434.33386552.7864.4919171.00863.244384.491970.2998148.62Average57.19383112.999246.47012113.197834.337376526.20464.88211170.943364.34616113.9120970.30239148.5Figure 11
Comparative result of RMSE for training for different methods.Figure 12
Comparative result of RMSE for checking for different methods.


## 5. Discussion

Figures6, 7, and 10 illustrate the forecast done by the ANFIS algorithm after training and predicting the electricity demand. After training, the ANFIS algorithm makes a prediction for the entire 1000 hours period which was compared with the actual data that is plotted in blue. The algorithm is only trained with 500 hours set of data but was able to make predictions beyond the 500-hour mark, and this is cross-checked with the checking dataset for the validity of the prediction. Additionally, the data on the prediction error gives a better understanding of the accuracy of the proposed ANFIS algorithm in the prediction of electricity demand. From the results, it can be observed that the prediction errors are usually not huge, and depending on the dataset used, increasing the membership function to 3 resulted in overfitting. The fuzzy rules define the characteristics of the clustering type that was used to define the membership function. For each of the scenarios, the default clustering type which is the “GridPartition” was used. For this type of clustering, the system generated input membership functions by uniformly partitioning the input variable range and then creating a single-output Sugeno fuzzy system. This is the reason why the membership function plots illustrated in Figures 3, 4, 7, and 8 were all uniformly spaced and covered the entire input space. Scenario 1–3 after training, resulted in 16, 32, and 81 fuzzy rules respectively. All these rules have been stored and used in coming up with the predictions. Increasing the input vector by 1 resulted in doubling the number of fuzzy rules generated by the model. Increasing the number of member function by 1 also nearly tripled the number of fuzzy rules generated to be used in the prediction. Consequently, the number of rules affects the speed and accuracy of the prediction. The ANFIS uses a combination of optimization techniques such as the gradient descent back propagation and mean least squares algorithms to fine-tune the model.The rules implemented by the ANFIS model helped to improve upon the prediction by reducing the error at the end of each epoch. Table1 shows the Root Mean Square Error at the end of each epoch for each of the scenarios. From Table 1 above, it can be noticed that, increasing the amount of past data used for learning actually improved upon the speed at which the algorithm converges to an optimal value. Scenario 1 had a minimum training and checking RMSE of 57.17 and 112.55, respectively. Scenario 2 had a minimum training and checking RMSE values of 46.44 and 101.52, respectively.Moreover, RMSE values keep decreasing and increasing around a specific range of values as illustrated in Table1 for the first three scenarios relating to the ANFIS model. This implies that, for the current dataset, increasing the number of membership functions is not a good decision to improve upon the performance of the model and this led in actual fact to very high values of errors in the prediction. Subsequently, the smoothness of the data used for training is very important in ANFIS modeling. The data determines what input membership type, number of input member functions, and other decisions to consider when producing an efficient and effective system for prediction.It can be observed that with the exception of the 3-membership function which resulted in data overfitting and subsequently led to some high RMSE values, the SVR could not perform better than the ANFIS in the first two scenarios. The scenario with three (3) membership functions was worse for this dataset hence, its poor performance in the prediction. Comparing the RMSE of the additional two methods, namely, LS-SVM and ARIMA, as illustrated in Figure11 for the training data, it can be observed that the ANFIS scenarios one and two overperformed all the other methods by indicating lower values of RMSE and therefore led to improved accuracy.Comparing the average RMSE over the ten epochs sampled in Table1, it can be observed that the ANFIS Scenario 1 and 2 have training RMSE values of 57.19 and 46.47 compared to the RMSE values of SVR, LS-SVM, and ARIMA that are respectively 64.88, 64.34, and 70.30. It is then obvious that the well-set two scenarios based on ANFIS are more accurate than the counterpart methods listed above.Similarly, a comparison of the checking RMSE shows a similar trend withScenarios 1 and 2 having the least averages as compared to the other methods. However, a critical look at Figure 12 shows that the LS-SVM is very close in performance to the ANFIS method and has outperformed them at the 10th epoch. In average, Scenarios 1 and 2 have recorded checking RMSE values of 112.99 and 113.20. SVR, LS-SVM, and ARIMA recorded the following averages for checking RMSE, respectively, 170.94, 113.91, and 148.5. Therefore, the ANFIS methods used in Scenarios 1 and 2 have the minimum RMSE values for checking followed by the LS-SVM.This shows that the ANFIS algorithms were mostly more accurate in the prediction of the checking data when compared with the SVR, LS-SVM, and ARIMA. However,Scenario 3 of the ANFIS algorithm due to its high overfitting problem did not perform quite well in the prediction of error. In conclusion, the ANFIS algorithm given the right parameters performs with high accuracy. Unlike the SVR, ANFIS prediction is even more accurate as the volume of the time series data increases.


## 6. Conclusion

This paper considered the prediction of electricity demand using the ANFIS method. The study made the following fundamental findings: the speed of convergence of the ANFIS algorithm can be significantly improved with an increase in the initial data used for learning; the prediction errors are considerably small and depending on the dataset used; increasing the membership function to three resulted in overfitting; and increase in the membership function causes RMSE values to vary uncontrollably. Moreover, the ANFIS result was compared to the other three methods including SVR, LS-SVM, and ARIMA models using the same input series data. The analysis of the outcome shows that the similarities in prediction were high; meanwhile, the ANFIS scenario performed better than all other predictions and therefore predicted the data with more accuracy. It was therefore inferred that the efficiency of an ANFIS prediction model depends considerably on the data quality and the tuning parameters.In view of these findings, ANFIS can be considered as a reliable and promising method that could challenge already known electricity demand prediction models including moving average, ARIMA, SVR, LS-SVM methods provided the training data and essential parameters are properly set. We, therefore, envisage in the future study a framework to accurately predict optimal parameters for ANFIS algorithm and compare results with other emerging techniques for time series data prediction.



---

*Source: 4181045-2020-08-08.xml*