Icatces2018 92

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

International Conference on Advanced Technologies, Computer Engineering and Science (ICATCES’18),

May 11-13, 2018 Safranbolu, Turkey

Training ANFIS using The Whale Optimization


Algorithm
M.CANAYAZ1 and R. ÖZDAĞ2
1 Van Yuzuncu Yil University, Van/Turkey, mcanayaz@yyu.edu.tr
2Van Yuzuncu Yil University, Van/Turkey, rozdag@yyu.edu.tr

problems and engineering problems. ANFIS networks need to


Abstract - Nowadays, it is tried to predict the future events be trained so that they can yield productive results. The
through the data. Practical areas such as deep learning are purpose in training is to find the appropriate parameter values.
primarily trying to regulate data, and then these data are used
These networks have been trained using several heuristic
for estimation. There are many algorithms used in this area.
Besides these algorithms, artificial neural networks are also methods such as PSO[1], ABC[2], Genetic Algorithm[3] and
widely used in this field. ANFIS is a special network that uses applied to various problems.
artificial neural network and fuzzy classifier. It computes the The aim of this study is to demonstrate the performance of
output by distributing the input data blurred by the membership the Whale Optimization Algorithm (WOA)[4], which is one of
functions with the fuzzy rules on the network. S ome parameter the current meta-heuristic algorithms to be used in the training
values need to be set in ANFIS . In this study, ANFIS networks
of ANFIS networks for the first time, on various problems. In
will be trained with the Whale Optimization Algorithm, one of
the current swarm-based meta-heuristic algorithms to find this context, the study will consist of Whale Optimization
suitable parameter values and evaluation will be made on sampl e Algorithm, ANFIS structure, proposed method, and results.
problems.
II. T HE WHALE OPTIMIZATION ALGORITHM
Keywords – ANFIS , Whale Optimization Algorithm, Nonlinear
The Whale Optimization Algorithm is one of the current
S ystem Identification, Prediction Time S eries
swarm based meta-heuristic algorithms developed by being
inspired by the hunting strategies of humpback whales [4-6]
I. INT RODUCT ION The unique hunting strategies of these whales were modeled in
three steps. These are encircling the prey, moving towards the
Nowadays, big data emerge as a concept used to express the prey and searching for the prey.
size of the data obtained from all kinds of sources. Great
successes are achieved both from economic and scientific A. Encircling the Prey
aspects along with the efficient use of the applications that
will process this huge data size. Deep learning algorithms The whales know the location of prey and encircle them.
provide improved tools for the processing of big data. Big Initially, they think that the current best candidate solution is
companies use artificial intelligence in most of deep learning the best solution reached and the closest optimal solution.
applications. Artificial intelligence applications have gained After the best candidate solution is determined, other members
great momentum along with the developing technology. It is of the population update their positions using this best
seen that the studies in this regard have increased both in solution. This is represented as in equation (1,2).
universities and in the private sector in recent years. As it is
known, the development of these applications requires high �⃗ = � 𝐶𝐶⃗.𝑋𝑋⃗∗ (𝑡𝑡) − 𝑋𝑋⃗(𝑡𝑡) �
𝐷𝐷 (1)
costs. The processing of high-sized data used in these
applications sometimes lasts for days or sometimes for weeks.
When technological developments are examined, it is seen that 𝑋𝑋⃗(𝑡𝑡 + 1) = �𝑋𝑋⃗∗ (𝑡𝑡) − 𝐴𝐴⃗.𝐷𝐷
�⃗� (2)
autonomous tools are the most important of these applications.
Apart from this, artificial intelligence is significantly used in
t represents the current iteration, A and C represent the
computer vision applications, in the biomedical field. When
coefficient vectors, X* represents the best solution vector.
we look at literature in the field of artificial intelligence, it is
The coefficients vectors A and C are formulized as in
possible to see that it has developed in many fields. Artificial
equations (3) and (4), respectively.
neural networks that are created by being inspired by the
human nervous system are mainly used while developing   
these applications. The use of these networks in various forms A = 2a.r − a (3)
is available. ANFIS networks are a special networking model
composed of a combination of these neural networks and
fuzzy logic tools. ANFIS has been used in many estimation

409
International Conference on Advanced Technologies, Computer Engineering and Science (ICATCES’18),
May 11-13, 2018 Safranbolu, Turkey

of other whales. The mathematical model of this search is


 
C = 2.r (4) presented in Equation 8 and Equation 9.
   
D ' = C. X rand − X (8)
r- represents a random vector, 𝑎𝑎- represents a vector
decreasing from 2 to 0 throughout the iterations.
   
B. Moving Towards the Prey X (t + 1) = X rand − A.D (9)

Humpback whales approach their prey with a strategy X rand represents a randomly selected solution vector.
called bubble-net feeding method. In this method, they move Which one of them, global or local searches, will be
towards their prey by blocking the view of their prey with the performed is decided based on the value of vector 𝐴𝐴. Since the
bubbles they create. They move towards their prey by 2 point which is more distant than the best point can be selected
methods that are called narrowing the circle and spiral when it is 𝐴𝐴 >1 or 𝐴𝐴 <1 for vector A, these cases are regarded
movement method. The method of narrowing the circle is as global search.
possible by decreasing the value of "a" in equation (3).
The steps of the WOA are presented below.
In the spiral movement method, the distance between the Steps of the Algorithm
whale and prey is first calculated as in equation (5). This value Step 1: Population n, a parameter, A, C coefficient
is then used to calculate the spiral movement method in parameters, Maximum iteration are set.
equation (6). Spiral movement is presented in Figure 1. Step 2: Candidate solutions with n populations are created
randomly and the fitness function value of each candidate is
   calculated.
D ' = X * (t ) − X (t ) (5)
Step 3: Initially, the best solution X* is accepted as the global
best.
   Step 4: A,C, a, p parameters are updated throughout the
X (t + 1) = D ' .ebl . cos(2πl ) + X * (t ) (6) algorithm.
Step 5: The movements of the whale are updated according to
b-represents the logarithmic spiral constant, l-represents a the value of p.
random number in the range of [-1,1]. Step 6: The best solution is offered when maximum iteration
is reached.

III. ANFIS
Adaptive network-based fuzzy inference system (ANFIS) is
an artificial neural network developed by applying the Sugeno
fuzzy model. ANFIS has an extensive area of usage in the
literature as special network structures that combine the
learning ability of artificial neural networks with the
Figure 1. Spiral Hareket
inference-making ability of fuzzy systems. "If Then" rule
structure is frequently used in estimation problems that require
In the algorithm, which one of them, spiral movement or decision making mechanisms because it uses the input, output
linear movement, will be employed is determined by 50% values. ANFIS has five-layer architecture [7-12].
probability as it is shown in Equation 7. Assume - two inputs X and Y and one output Z
Rule 1: If x is A 1 and y is B1 ,
then f 1 = p 1 x + q 1 y +r 1
 *  
 X (t ) − A.D , p < 0.5 Rule 2: If x is A 2 and y is B2 ,

X (t + 1) =  (7) then f 2 = p 2 x + q 2 y +r 2
  ' bl *
 D .e . cos(2πl ) + X (t ) , p ≥ 0.5 Layer 1
Each node in this layer represents a fuzzy set such as A i and
p-represents a random number in the range of [0,1]. Bi . The membership grades depending on the input samples
and the membership function used are used as the output of
C. Searching for the Prey the nodes. In other words, it is the layer where input values are
made fuzzy. The node outputs are presented in equation (10).
During this searching for prey, the whales search for prey
randomly and change their position according to the positions
ui2 = µ A i ( x) i=1,2 (10)

410
International Conference on Advanced Technologies, Computer Engineering and Science (ICATCES’18),
May 11-13, 2018 Safranbolu, Turkey

ui2+ 2 = µ Bi ( y ) ANFIS's learning algorithm is a hybrid learning algorithm


formed by the combined use of the least squares method and
the backpropagation learning algorithm.

IV. TRAINING OF ANFIS USING THE WOA


Here, x, y and i represent the deterministic input values in the
node, A i and Bi represent the fuzzy terms, and μ Ai and μ Bi In ANFIS, parameters are needed for the processes of
represent the membership functions. There are 2 different fuzzification in layer 1 and defuzzification in layer 4. These
output values and a total of 4 nodes in the network with two are called premise and consequent parameters [2]. These
different inputs such as x and y, as it is shown in equation parameters are provided by the WOA in the proposed method.
(10). For each node, membership functions with a maximum These parameter values are expressed by the position values of
of 1 and a minimum of 0 are used. In general, the membership the whales in the algorithm. As the position of the whales is
function of a fuzzy set can be any parameterized membership updated according to the leading whale, these parameter
function, such as triangle, Gaussian, or the generalized Bell values are updated and the ANFIS is trained with the updated
function. The parameters in this layer are called Premise parameter values. For the fitness function that determines the
Parameters. suitability of the solution in the optimization algorithms, the
Layer 2 RMSE error function shown in Equation (15) is used.
This layer is called the rule layer. The nodes in this layer N (15)
represent the rules and numbers created using the Sugeno ∑(y i − yi )
fuzzy logic inference system. The output of the rule nodes, µ i , RMSE = i =1

is the multiplication of membership grades from the previous N


layer. The node output shows the firing strength of a rule. µi yi used in Equation (15) represents the output obtained by
values, where it is (i=1,….,n), are obtained as follows.
ANFIS in time I, and y i represents the actual output of the
system. N represents the number of samples used in the
ωi = µ A ( x) * µ B ( y )
i i
(11)
application.

Layer 3
In this layer, the firing strengths from the rule layer are V. EXPERIMENTS
normalized. For this reason, this layer is called the
Two types of problems were addressed in the applications
normalization layer. The firing strength normalized for i th
developed for the training of ANFIS. These are the application
node is calculated as follows.
for the identification of nonlinear systems and the chaotic time
ωi series estimation problems. For the identification of non-linear
ϖi = (12)
ω1 + ω2 systems, a dynamic system consisting of an input and an
output (SISO) was used in the given problem. Furthermore, 2
Layer 4 input values and 1 output value are used for the ANFIS
In this layer that is called the defuzzification layer, the structure. Gaussian functions are used as membership
weighted output values of each rule are calculated. This functions for the inputs in the ANFIS structure. The two inputs
calculation is achieved by the multiplication of the normalized of ANFIS are defined as the previous input u(t) and the
firing strength in the figure below with the {p i ,r i ,q i } values, previous output y(t) of dynamic systems. y(t+1) is accepted
that are the output parameters of the fuzzy inference system. for the output value. Equation (16) is used to obtain the input
The parameters in this layer are referred to as consequent value u(t).
parameters. (16)
sin(πk / 25) k < 250
1 250 ≤ k ≤ 500
ϖ i f i = ϖ i ( pi x + qi y + ri ) (13) 
u ( k ) = − 1 500 < k ≤ 750
Layer 5 0.3 sin(πk / 25) + 750 < k ≤ 1000
This layer is called output layer. The output of ANFIS is 
achieved with the summation of the outputs obtained for each 0.1sin(πk / 32) + 0.6 sin(πk / 10)
rule in the previous layer. In this layer, a single number is 25 populations, 1000 maximum iterations were used for the
produced by the defuzzification of fuzzy rules. WOA. The same values are used for GA.
Another problem is the chaotic time series estimation problem.
4 The dataset used for this application is the dataset called
4 ∑ω f i i “mdata” which is prepared by Matlab program. The purpose
f ( x, y ) = ∑ϖ i f i = i
4
(14) of the problem is to estimate the x(t+6) value using the x(t-
i
∑ω i
i
18), x(t-12), x(t-6), and x(t) data. The data set is divided into
500 training and 500 test data.

411
International Conference on Advanced Technologies, Computer Engineering and Science (ICATCES’18),
May 11-13, 2018 Safranbolu, Turkey

The application was performed in the MATLAB program on a


computer with I7 processor and 8 GB Ram. The algorithms Table 1. Example 1 results
were run independently of each other for 30 times and the Algorithms Number of RMSE RMSETest
ANFIS was trained, and the average of the RMSE values parameters Train
obtained at the end of these trainings is presented in Table 1 GA 24 0.05342 0.044854
for Example 1 and in Table 2 for Example 2. WOA 24 0.047588 0.059755

Example 1: Nonlinear System Identification


Equation (17) is used in the application to be performed for For the example 1, the Training error value obtained from the
the non-linear dynamic system. 1000 input and output values WOA RMSEtrain is 0.047588 and the test error value
are generated using this system. These are divided into 70% RMSEtest is 0.059755. The standard deviation value is
training and 30% test data and used in ANFIS training. The 0.0024313, 0.0019072, respectively. The training and test
results of this problem are presented in Table 1. In addition, result graphic obtained at the end of the algorithm is presented
the values taken from ANFIS(GA) is also included in the in Figure 2 and Figure 3, and the comparison values with other
table. algorithm are presented in Table 1.

y p (k + 1) = f ( y p (k ), y p (k − 1), y p (k − 2), u (k ), u (k − 1)) (17)


x1 x2 x3 x5 ( x3 − 1) + x4
f ( x1 , x2 , x3 , x4 , x5 ) =
1 + x22 + x32

Train Data
1

Target
Output
0.5

-0.5

-1
0 100 200 300 400 500 600 700

Sample Index

MSE = 0.0020287, RMSE = 0.045042 Error Mean = -7.5735e-06, Error St.D. = 0.045074
0.6 250

Error

0.4 200

0.2 150

0 100

-0.2 50

-0.4 0
0 100 200 300 400 500 600 700 -0.3 -0.2 -0.1 0 0.1 0.2 0.3 0.4 0.5

Figure 2. Example 1 Train Data Results


Test Data
1

Target
Output
0.5

-0.5

-1
0 50 100 150 200 250 300

Sample Index

MSE = 0.0036196, RMSE = 0.060163 Error Mean = 0.0001341, Error St.D. = 0.060263
0.4 100

Error
0.2
80

0
60

-0.2

40
-0.4

20
-0.6

-0.8 0
0 50 100 150 200 250 300 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4

Figure 3. Example 1 Test Data Results

412
International Conference on Advanced Technologies, Computer Engineering and Science (ICATCES’18),
May 11-13, 2018 Safranbolu, Turkey

Example 2:Predict of Caotic Time Series Mackey-Glass 1.4


Mackey-Glass Chaotic Time Series

The data is generated from the Mackey-Glass time-delay 1.2

differential equation which is defined by

0.2 x(t − τ )
1

dx(t )
= − 0.1x(t ) (18)
dt 1 + ( x(t − τ ))10 0.8

x(t)
When x(0) = 1.2 and = 17, we have a non-periodic and non- 0.6

convergent time series that is very sensitive to initial


conditions. (We assume x(t) = 0 when t < 0.) 0.4

The time series graphic used for Mackey-Glass is presented in 0.2


0 200 400 600 800 1000 1200
Figure 4. For the example 2, the Training error value obtained Time (sec)

from the WOA RMSEtrain is 0.042904 and the test error value Figure 4. Mackey-Glass time series
RMSEtest is 0.04227. The standard deviation value is
0.0034821, 0.0034207, respectively. The training and test VI. CONCLUSION
result graphic obtained at the end of the algorithm is presented
In this study, the WOA, which is one of the current swarm
in Figure 5, and in Figure 6 and the comparison values with
based algorithms, was first used for the training of ANFIS
other algorithm are presented in Table 2. networks. ANFIS networks have a special network structure
When we look at the result figures for Example 2, although that is the combination of fuzzy logic and artificial neural
the minimum result is obtained, the target and output values networks. The premise and consequent parameters in this
are not exactly matched. This shows that ANFIS trained with network are updated by means of the WOA. When the results
WOA in the time series estimation problem is weak.
are examined, it is seen that the WOA had the values with
Table 2. Example 2 results
lower error rates compared to GA. In conclusion, it is
Algorithms Number of RMSE RMSETest
demonstrated that the WOA can be used in the training of
parameters Train
ANFIS.
GA 208 0.056788 0.056184
WOA 208 0.042904 0.04227

Train Data
1.4

Target

1.2 Output

0.8

0.6

0.4
0 50 100 150 200 250 300 350 400 450 500

Sample Index

MSE = 0.0013796, RMSE = 0.037143 Error Mean = 0.0010801, Error St.D. = 0.037164
0.1 30

Error
25
0.05
20

0 15

10
-0.05
5

-0.1 0
0 50 100 150 200 250 300 350 400 450 500 -0.15 -0.1 -0.05 0 0.05 0.1 0.15

Figure 5. Example 2 Train Data Results

413
International Conference on Advanced Technologies, Computer Engineering and Science (ICATCES’18),
May 11-13, 2018 Safranbolu, Turkey

Test Data
1.4

Target

1.2 Output

0.8

0.6

0.4
0 50 100 150 200 250 300 350 400 450 500

Sample Index

MSE = 0.0013334, RMSE = 0.036516 Error Mean = 0.001087, Error St.D. = 0.036536
0.1 35

Error
30

0.05
25

20
0
15

10
-0.05

-0.1 0
0 50 100 150 200 250 300 350 400 450 500 -0.15 -0.1 -0.05 0 0.05 0.1 0.15

Figure 6. Example 2 Test Data Results

REFERENCES

[1] V. S. Ghomsheh, M. A. Shoorehdeli and M. T eshnehlab, "T raining


ANFIS structure with modified PSO algorithm," in 2007 Mediterranea n
Conf. on Control & Automation, Athens, pp. 1-6.
[2] D. Karaboga and E. Kaya, “Training ANFIS using artificial bee co lony
algorithm for nonlinear dynamic systems identification,” in 20 14 2 2 nd
Signal Processing and Communications Applications Conference (SIU),
pp. 493–496.
[3] B. Haznedar, and A. Kalınlı, “Training ANFIS Using Genetic Algorithm
for Dynamic Systems Identification,” Int. J. of Intell. Sys. and App l. in
Eng., vol. 4, no. 1, pp. 44-47, 2016.
[4] S. Mirjalili, and A. Lewis, “ T he Whale Optimization Algorithm,” Adv .
in Eng. Soft, vol. 95, pp. 51-67, 2016.
[5] E. T anyıldızı, and T . Cigal, “ Kaotik Haritalı Balina Optimizasyon
Algoritmaları”, Fırat Ünv. Müh. ve Bilim Dergisi, vol 29, no.1, pp. 309-
319, 2017.
[6] M. Canayaz and M. Demir, "Feature selection with the whale
optimization algorithm and artificial neural network," in 2017 Int.
Artificial Intell. and Data Processing Symposium (IDAP), pp. 1-5.
[7] J. S. R. Jang, “ ANFIS: Adaptive-Network-Based Fuzzy Inference
System,” IEEE Trans Syst Man Cybern, vol. 23, no. 3 , p p . 6 6 5–6 85,
1993.
[8] J.S.R, Jang. C.T ., Sun, and E., Mizutani, Neurofuzzy and soft
computing, Prentice Hall, Upper Saddle River, 1997
[9] R. T ür, C. E. Balas, “ Belirgin Dalga Yüksekliklerinin Neuro-Fuzzy
Yaklaşımı İle T ahmini: Filyos Deniz Yöresi Örneği”, J. Fac. Eng. Arch .
Gazi Univ. vol. 25, no. 3, pp. 505-510, 2010
[10] D, Karaboğa, E., Kaya, “ T raining ANFIS by using the artificial bee
colony algorithm”, Turk J Elec Eng & Comp Sci v o l. 2 5, p p. 1 66 9-
1679, 2017.
[11] Ö. Demirel, A. Kakilli and M. Tektaş, “ANFIS ve Arma Mode lle ri İ le
Elektrik Enerjisi Yük Tahmini”, J. Fac. Eng. Arch. Gazi Univ., vol. 2 5,
no 3, pp. 601-610, 2010.
[12] Ç. Elmas, Yapay Zeka Uygulamaları, Seçkin Yayıncılık, 2016.

414

You might also like