SwarmIntelligence Based Data Mining
Algorithms for Classiﬁcation
Abstract Data mining is the process of ﬁnding hidden knowledge in large amounts
of data.Marketing,Fraud Detection,Telecommunication,and Data Cleaning are
some of few important applications of data mining.There are several methods for
change and deviation detection.Classiﬁcation is task of classifying data items into
a set of pre-deﬁned classes.A classiﬁer is created by processing a training set of
labeled data items,and constructing a set of rules.After rule construction,the clas-
siﬁer will be able to classify (label) new data items based on the rules it has learned
from the training data.Swarm Intelligence methods imitate a swarm of insects and
try to solve problems in a way similar to the way a swarmof insects are solving their
real problems (foraging,nest selection,etc.).Swarmbased methods have also been
used in data mining.In this article we investigated some classiﬁcation rule construc-
tion methods which have used Ant Colony Optimization as their base method.We
will see that swarmbased methods can performas good as non-swarmmethods.
Key words:Data Mining,Classiﬁcation,Rule Induction,Particle Swarm Opti-
mization,Ant Colony Optimization,SwarmIntelligence.
Data mining,or knowledge mining from data,is the process of ﬁnding hidden
knowledge and patterns in large amounts of data.Among diverse applications
we can name Marketing ,Fraud Detection ,Telecommunication,and Data
Cleaning.There are several methods for data mining that we deﬁne brieﬂy each of
themhere   :
Florida Institute of Technology,150 West Univ.Blvd,Melbourne,Florida e-mail:
2 Ahmed Khademzadeh
Classiﬁcation in which data items are classiﬁed to one among several predeﬁned
Regression by which a data itemis mapped to a numerical real value.Later these
values can be processed for different purposes.
Clustering is used when we dont have predeﬁned categories,and we want to put
data items that are more similar to each other in one cluster.The ultimate goal
is splitting data items up to several clusters in which each of themcontains most
similar data items.
Summarization in which an abstract and abridged description of data items is
Dependency Modeling in which structural or quantitative dependency models
among data items is researched.
Change and Deviation Detection is used to discover the substantial changes in
data items comparing to a previously seen data.
The algorithms investigated in this article are using swarm intelligence methods
for classiﬁcation purpose.In the following subsections we introduce the two main
components of this article that are classiﬁcation and swarmintelligence brieﬂy.
As mentioned before,a classiﬁer tries to classify data items to different predeﬁned
classes.Rule based classiﬁers are using rules in order to classify the data items.
Each rule has two parts:antecedent and consequent.Below a sample rule is shown:
If (x > 1.2) and (y = blue)then class = a (1)
In this rule if part is called antecedent and then part is called consequent.An-
tecedent usually consists one or several parts (called term) that are joined to each
other using conjunction operator.During classiﬁcation,if a data item satisﬁes the
antecedent of a rule will be classiﬁed based on the rules consequent.
The most important phase of classiﬁer construction is rule construction.In rule
construction phase,labeled data items of different classes of training data are ex-
amined to ﬁnd patterns.The attribute-value pairs that are repeated in each class is
considered as pattern,and rules are constructed based on these patterns.Handling
categorical (nominal) attributes (those that consist enumerable number of values) is
easy,but handling contiguous attributes is sometimes challenging and nave methods
do not handle them.
During or after rule construction,rules may be pruned in order to increase their
quality.During pruning some terms may be dropped fromthe antecedent.After con-
structing a rule set,the rules may be tested for quality.Rules with more coverage
(satisfying more data items in data set) are considered to be of more quality.This
way some rules may be dropped from the rule set,and the rules also are ordered
based on their quality.This way a sequential rule set is constructed.Algorithm 1
SwarmIntelligence Based Data Mining Algorithms for Classiﬁcation 3
shows an algorithmfor rule construction that prunes the rules during rule construc-
tion.This algorithm splits data into two different parts.One part is used for rule
construction,and the other part is used for pruning   .
Algorithm1.Algorithmfor forming rules by incremental reduced-error pruning 
S p l i t E i n t o Grow and Pr une i n t he r a t i o 2:1
For each c l a s s C f or whi ch Grow and Pr une bot h
c ont a i n an i n s t a n c e
Use t he ba s i c cover i ng a l gor i t hm t o c r e a t e t he
be s t p e r f e c t r u l e f or c l a s s C
Ca l c ul a t e t he wor t h w(R) f or t he r u l e on Prune,
and f or t he r u l e wi t h t he f i n a l c ondi t i on
omi t t ed w( R)
Whi l e w( R) > w(R),remove t he f i n a l c ondi t i on
from t he r u l e and r e pe a t t he pr e vi ous s t e p
From t he r u l e s gener at ed,s e l e c t t he one wi t h
t he l a r g e s t w(R)
Pr i n t t he r u l e
Remove t he i n s t a n c e s cover ed by t he r u l e from E
Cont i nue
Bees,ants,wasps,are the insects that sometimes do big tasks although they are not
of high intelligence.For example ants are constructing Minimum Spanning Tree,
Steiner Tree when they are doing inter-nest activities  .Ants also ﬁnd the
shortest path between their nest and the foraging site .Figure 1 illustrates this
behavior.In ﬁgure 1 (a) ants are traveling between nest and food source in a direct
line.For experiment purpose their path is disturbed by an object.Ants then try to
bypass the object by going to right and left for ﬁnding a new path.As it can be seen
in ﬁgure 1 (b) at ﬁrst half of the ants are going to right and half to the left,but since
the right way is shorter than left one,the rate of going and coming back in right way
is higher and so the amount of pheromone (chemical substance which ants deposit
on the ground when they are passing a path),on the right way will be move over time
and ants are indirectly communicating with each other and tell each other (using the
amount of pheromone) that the right way is better,and as it is shown in ﬁgure 1 (c),
right path is selected and the left one is ignored by ants.
As another example bees are able to select the best nest among several nest when
they decide to immigrate to a new nest  .There are many more examples
of this kind which shows that swarm of insects are able to perform self-organized
task while they have small amount of memories and intelligence.The notions of
4 Ahmed Khademzadeh
self-autonomy,low memory,low intelligence,distributed-ness,and yet emergence
of complicated outcomes have encouraged the scientist to imitate swarm behaviors
in design and implementation of real complicated systems   .
Many research have been done on swarm-based data mining.For example Shi
Zhongzhi and Wu Bin  have proposed a clustering algorithm based on swarm
intelligence.Abraham,A.et al. has explored the role of swarm intelligence in
clustering and proposed a technique for clustering data items into an optimized num-
ber of groups.L Xiao et al. has proposed a swarm based anomaly intrusion
Fig.1 Illustrating the behavior of real ant movements 
In this article we explore some of the researches that have been done on swarm
based classiﬁcation.Since efﬁciency of a set of classiﬁcation rules is important and
there are many possibilities for having different sets of rules for a singe data set,this
problemcould be considered as an optimization problem.Ant Colony Optimization
(ACO) and Particle Swarm Optimization (PSO) are two swarm inspired techniques
for optimization that are applied to construction of classiﬁcation rules.
In the following sections we investigate different swarminspired algorithms that
are proposed for classiﬁcation rule construction.In section 2 we discuss Ant Colony
Optimization and illustrate it using Traveling Salesman Problem (TSP) example.
One of the ACO based classiﬁcation rule construction algorithms (Ant-Miner) is
discussed in section 3.In section 4 and 5 Ant-Miner2 and Ant-Miner3 which are
improvement over Ant-Miner are discussed.Section 6 concludes the paper.
2 Ant Colony Optimization (ACO) for Classiﬁcation
This is a simple yet a powerful algorithmwhich can be used for optimization prob-
lems.We explain ACO using a simple graph related example in the following.
SwarmIntelligence Based Data Mining Algorithms for Classiﬁcation 5
Suppose we want to solve the Traveling Salesman Problem (TSP)  with the
help of ants.We put some ants in the graph and ask them to ﬁnd the best TSP tour.
Each ant is trying to ﬁnd a Hamiltonian cycle of the graph.They start froma random
node and in each step they select one of the neighbors of the current node that they
have not yet visited.At ﬁrst,when no pheromone is yet deposited on edges,they
have a tendency to select the neighbor that is closer to them.After ﬁnishing each
round,each ant deposit some pheromone on the edges in their TSP tour,and the best
tour among all is selected and edges of that tour will receive more pheromone.This
way shorter edges,and edges that have been part of at least one TSP tour of one ant
will receive some pheromones.Ants are now again ﬁnd new TSP tours.This time
each ant selects a neighbor probabilistically based on both distance and amount of
pheromone that is deposited on the edge.An edge with higher amount of pheromone
has a higher chance of being selected by ants  .This way although none of
the ants have a global view of the graph and they just have locally and without any
sophisticated algorithm have selected the next edge,the emergent outcome will be
a result that is very close to best solution.
In this section we study the Ant-Miner algorithm which is an ACO based clas-
siﬁcation algorithm.Rafael S.Parpinelli et al have propose this algorithm.
As we saw in previous example in Ant Colony Optimization each ant is con-
structing a solution to the target problem.In classiﬁcation rule context the problem
is ﬁnding a new good rule.Here each rule consists of one or several terms that each
is in the formof <attribute,operator,value>.For example <y,=,blue>.
If our attributes are categorical (nominal),then the operator will always be =,
but if we have continuous attributes,we need ,,<,and > operators too.Some
methods discretize the continuous values in order to treat them as categorical at-
tributes.Construction of a rule set can be ﬁnished when we reach to a point which
all,or almost all data items are covered by rule set.Algorithm2 shows a high-level
description of Ant-Miner algorithm.In this algorithm rule generation is continuing
while the number of remained data items in training set is higher than a threshold.
Each ant starts with an empty rule and adds terms to the rules.The terms are selected
based on the logic similar to one we observed in TSP example above.Amount of
pheromone and a heuristic function (similar to nearest neighbor in TSP example
which we will explain later for this context),are the bases for selecting a term.Term
selection is done based on the following probability:
hi j:ti j(t)
In above equation
6 Ahmed Khademzadeh
a is the number of attributes,
is one if attribute A
is not chosen by current ant,and zero if it is already
is the total number of different values for attribute A
in all data items,
(t) is the amount of pheromone of termij,and if this value is higher,the prob-
ability of selection of this termwill be higher,
is deﬁned based on a heuristic function which is problemdependent.
Algorithm2.A High-Level Description of Ant-Miner 
Di s c over e dRul eLi s t = [ ];
/ r u l e l i s t i s i n i t i a l i z e d wi t h an e mp t y l i s t /
WHILE ( Tr a i ni ngSe t > Max
t = 1;/ ant i ndex /
j = 1;/ conver gence t e s t i ndex /
I n i t i a l i z e a l l t r a i l s wi t h t he same amount of
Ant t s t a r t s wi t h an empty r u l e and i nc r e me nt a l l y
c o n s t r u c t s a c l a s s i f i c a t i o n r u l e Rt by addi ng
one t er m a t a t i me t o t he c u r r e n t r u l e;
Pr une r u l e Rt;
Updat e t he pheromone of a l l t r a i l s by i n c r e a s i n g
pheromone i n t he t r a i l f ol l owed by Ant t
( p r o p o r t i o n a l t o t he q u a l i t y of R ) and
de c r e a s i ng pheromone i n t he ot he r t r a i l s
( s i mul a t i ng pheromone e va por a t i on );
IF ( Rt i s equal t o Rt 1)/ updat e conver gence
t e s t /
THEN j = j + 1;
ELSE j = 1;
t = t + 1;
UNTIL ( t >= No
ant s ) OR ( j >= No
r ul es
conver g )
Choose t he be s t r u l e Rbest among a l l r u l e s Rt
c ons t r uc t e d by a l l t he a nt s;
Add r u l e Rbest t o Di s c over edRul eLi s t;
Tr a i ni ngSe t = Tr a i ni ngSe t f s e t of c a s e s c o r r e c t l y
cover ed by Rbest g;
As we saw in TSP example,h
was deﬁned based on the distance of the node
with its neighbors,and thus the nearer neighbor had a higher chance of getting
selected.Below this heuristic function (it is called information-theoretic heuristic
function) is deﬁned for classiﬁcation problem:
SwarmIntelligence Based Data Mining Algorithms for Classiﬁcation 7
The value of Hin above equation is deﬁned based on the following equation that
is intuitively related to entropy:
In above equations k is number of classes,W is class attribute,and P(wjA
is a conditional probability of having class w given that A
Table 1 Prediction Accuracy of Ant-Miner and CN2 After the Tenfold Cross-Validation Procedure
Accuracy (%) Accuracy (%)
Ljubljana breast cancer
Wisconsin breast cancer
Cleveland heart disease
After constructing a rule,each ant prunes the rule,and removes some terms in
antecedent to make the rule more predictive and prohibit over-ﬁttingness of the rule.
The process of rule pruning is similar to the method that is used in Algorithm 1.
The only difference here is that we may remove each of the terms in the rule;while
in Algorithm 1 the terms are removed from the end the rule.The quality of a rule
before and after pruning is evaluated using the following metrics:
True Positive:Number of data items correctly classiﬁed by the rule to the class
predicted by the rule.
True Negative:Number of data items correctly not classiﬁed by the rule to the
class predicted by the rule.
False Positive:Number of data items wrongly classiﬁed by the rule to the class
in the rule consequent.
False Negative:Number of data items wrongly not classiﬁed by the rule to the
class in the rule consequent.
The above metrics are used to compose the following composed metric:
8 Ahmed Khademzadeh
Before starting algorithm all the edges have been updated with the following
amount of pheromone:
ti j(t =0) =
Now,pheromone update is done by all ants,and each ants updates all the edges
correspond to terms in the rule according to the following equation:
ti j(t +1) =t
Next,amount of pheromones on all edges are normalized to reduce the amount
of pheromone on the edges that are not used in the rule.
As the last step in each iteration the best rule among all rules created by all ants
is selected,and is added to the rule set.
The Ant-Miner algorithm uses the following values for its parameters that are
selected based on the authors experiments:
Number of ants:3000,
Minimumnumber of cases per rule:10,
Maximumnumber of uncovered cases in the training set:10,
Number of rules used to test convergence of the ants:10.
Several experiments have been done on Ant-Miner and it has been shown  that
using pheromone has a signiﬁcant effect on the accuracy of our classiﬁer.It also has
been shown that rule pruning is also important.Table 1 compares the accuracy of
Ant-Miner and CN2 (a non-swarmclassiﬁcation algorithm).
Table 2 Accuracy Rate and Simplicity of Ant-Miner and Ant-Miner2 
Number of Rules
4 Ant-Miner2 (A density-based Ant-Miner)
Bo Liu et al. have proposed some improvements on Ant-Miner.They made some
changes in heuristic value which is calculated in original Ant-Miner based on en-
tropy function.They simpliﬁed the heuristic function and argued that this function
SwarmIntelligence Based Data Mining Algorithms for Classiﬁcation 9
need not to be very precise because the pheromone trails on edges will compensate
if our heuristic value is not very precise.They proposed the following density-based
heuristic function in which majorityClassT
is the majority class in partition T
They have conducted an experiment in which they compared Ant-Miner and Ant-
Miner using one database (Wisconsin Breast Cancer),and concluded that the accu-
racy and number of rules generated in both algorithms are identical.The result of
their experiment is shown in Table 2.
Based on their result they concluded that the heuristic function doesn’t need to
be very precise and ACO is tolerant to the simplicity of the heuristic function.
Table 3 Test Set Accuracy Rate 
Tic Tac Toe
Ant-Miner and Ant-Miner2 is improved by Bo Liu et.al .In Ant-Miner3 they
changed the pheromone update mechanismand also provided a new state transition
rule,and showed that this will increase the accuracy of the algorithm.
Pheromone update:The pheromone update equation in original Ant-Miner is
(t) =(1r) t
(t 1) +(1
(t 1) (9)
In above equation r is the rate of pheromone evaporation,and Q is quality of
the constructed rule which is calculated based on equation 5.As it can be inferred
from second operand of the + operation in the above equation,if the quality of a
10 Ahmed Khademzadeh
rule is high (close to 1),half of the amount of pheromone in the previous time will
be added in this step,and if the quality is low (close to 0) the amount of pheromone
will not be added because of the rule quality.The authors of Ant-Miner3 considered
the value of 0:1 for the evaporation rate in their experiments.
After updating the amount of pheromone based on the above equation,normal-
ization of the pheromone values will normalize and cover the pheromone evapora-
State Transition:Depositing pheromone on edges is a method which can be
considered both as distributed long-term memory and as communication mecha-
nism.This method lets ants to be more biased toward edges which has more amount
of pheromone,and thus exploitation.The more the amount of pheromone on edges,
the less the possibility of exploration.Liu et al.propose another state transition rule
in order to enhance the role of exploration.This state transition rule is as following:
with max P
In above pseudocode:
phi is a parameter fromthe range of 0 and 1,
is all values of i
is the probability which is calculated based on equation 2.
In this state transition method f is an adjustable parameter by which we can tune
the amount of exploration vs.exploitation.If the randomnumber q
is greater than f
then the system is exploiting the previously found knowledge,while when it is less
than f the systemis exploring.They used the value of 0.4 for f in their experiments.
Liu et al.used Wisconsin Breast Cancer and Tic Tac Toe Endgame dataset for
their experiments.Aten-fold cross-validation is used to compare original AntMiner
and AntMiner3.The accuracy of both algorithm is calculated based on equation 5,
and the result of all ten runs is depicted in table 3.Table 4 show the mean accuracy
and mean number of rules for original AntMiner and AntMiner3.As it can be seen
in table 3,the mean accuracy of the AntMiner3 is higher than original AntMiner.
In this article we studied 3 different swarm-based classiﬁcation rule construction al-
gorithms.Original Ant-Miner which is based on Ant Colony Optimization looks at
SwarmIntelligence Based Data Mining Algorithms for Classiﬁcation 11
Table 4 Mean accuracy rate and mean number of rule lists 
Tic Tac Toe
Accuracy Rate (%)
Number of Rules
different data item ﬁelds as paths in ACO.Every data item could be selected by an
ant as a termand can be added to a rule.Several rules are constructed by several ants
and this task is repeated until our rule set is constructed.During rule construction
phase ants deposit pheromone on the path and this help them to ﬁnd better rules.
Ant-Miner2 improves the original Ant-Miner by deﬁning a new heuristic function.
Ant-Miner2 showed that using a very precise heuristic function in ACO-based clas-
siﬁcation rule construction algorithms might not be of signiﬁcant importance.Ant-
Miner3 also suggests some improvements over original Ant-Miner.It uses a new
pheromone update equation,and also provides a new state transition mechanism.
The experiments in Ant-Miner,Ant-Miner2,and Ant-Miner3 suggests that swarm-
based classiﬁcation algorithms are performing as good as non-swarmalgorithms.
1.Abraham,A.,Das,S.,Roy,S.:Swarmintelligence algorithms for data clustering.Soft Com-
puting for Knowledge Discovery and Data Mining pp.279–313 (2008)
2.Bonabeau,E.,Dorigo,M.,Theraulaz,G.:Swarm intelligence:from natural to artiﬁcial sys-
tems.1.Oxford University Press,USA(1999)
3.Chan,P.,Fan,W.,Prodromidis,A.,Stolfo,S.:Distributed data mining in credit card fraud
detection.Intelligent Systems and their Applications,IEEE 14(6),67–74 (1999)
4.Fayyad,U.,Piatetsky-Shapiro,G.,Smyth,P.,Uthurusamy,R.:Advances in knowledge dis-
covery and data mining (1996)
5.Kantardzic,M.:Data mining:concepts,models,methods,and algorithms.Wiley-IEEE Press
Structure and formation of ant transportation networks.Journal of The Royal Society Interface
7.Leiserson,C.,Rivest,R.,Stein,C.:Introduction to algorithms,vol.6.MIT press (2001)
8.Liu,B.,Abbas,H.,McKay,B.:Classiﬁcation rule discovery with ant colony optimization.In:
Intelligent Agent Technology,2003.IAT 2003.IEEE/WIC International Conference on,pp.
83 – 88 (2003).DOI 10.1109/IAT.2003.1241052
9.Liu,B.,Abbass,H.,McKay,B.:Density-based heuristic for rule discovery with ant-miner.
In:The 6th Australia-Japan joint workshop on intelligent and evolutionary system,vol.184.
10.Parpinelli,R.,Lopes,H.,Freitas,A.:Data mining with an ant colony optimization algorithm.
Evolutionary Computation,IEEE Transactions on 6(4),321–332 (2002)
11.Seeley,T.,Buhrman,S.:Nest-site selection in honey bees:how well do swarms implement
the” best-of-n” decision rule?Behavioral Ecology and Sociobiology 49(5),416–427 (2001)
12.Shaw,M.,Subramaniam,C.,Tan,G.,Welge,M.:Knowledge management and data mining
for marketing.Decision Support Systems 31(1),127–137 (2001)
12 Ahmed Khademzadeh
13.Witten,I.,Frank,E.:Data Mining:Practical machine learning tools and techniques.Morgan
14.Xiao,L.,Shao,Z.,Liu,G.:K-means algorithm based on particle swarm optimization algo-
rithmfor anomaly intrusion detection.In:Intelligent Control and Automation,2006.WCICA
2006.The Sixth World Congress on,vol.2,pp.5854–5858.IEEE (2006)
15.Zhongzhi,S.,et al.:A clustering algorithm based on swarm intelligence.In:Info-tech and
Info-net,2001.Proceedings.ICII 2001-Beijing.2001 International Conferences on,vol.3,