Full text
A Thermodynamic Algorithm for Feature Selection Llu´ıs A. Belanche Mu˜noz F´elix F. Gonz´alez Navarro Departamento de Lenguajes y Sistemas Inform´aticos Universidad Polit´ecnica de Catalu˜na Campus NORD belanc[email protected] [email protected]c.edu Abstract The main purpose of Feature Selection (FS)is to find a reduced subset of attributes from a data set described by a feature set. This implies a search process in the space of possible solutions, trying to optimize an objective function. This work introduces TAFS,a Thermodynamic Annealing Feature Selection algorithm. Given a suitable objective function, TAFS uses a special-purpose implementation of simulated annealing to find a good subset of attributes that maximizes this objective function. A distinctive characteristic of TAFS over other search algorithms for feature subset selection is its probabilistic capability to accept momentarily worse solutions. TAFS has been evaluated against one of the most robust and reliable algorithm, the Sequential Forward Floating Search method (SFFS). Our experimental results show that TAFS achieves significant improvements over SFFS in the objective function for classification tasks with a reasonable reduction in subset size. 1 Introduction The importance of FS is beyond doubt in inductive machine learning and data mining [7]. The FS problem in terms of supervised inductive learning can be expressed as: given a set of candidate features, select a subset defined by one of two approaches: a) the subset with a specified size that optimizes an objective function, b) the subset of smaller size that satisfies a certain restriction on the objective function. The generic purpose pursued is the improvement of the inductive learner, either in terms of learning speed, generalization capacity or simplicity of representation. Other advantages are easier understanding of the results obtained by the inducer and reduction of the noise generated by irrelevant or redundant features, thereby eliminating useless knowledge. An important family of algorithms perform an explicit search in the space of subsets by iteratively adding and/or removing features one at a time until some stop condition is met. This process is guided by the objective function (usually the inducer itself). This work addresses the problem of selecting a subset of features from a given set in an inductive learning setting by introducing TAFS (Thermodynamic Annealing Feature Selection) a novel algorithm for FS. Given a suitable objective function, the algorithm makes uses of an special-purpose simulated annealing technique to find a good subset of attributes that maximizes the objective function. The algorithm is parameterized by the initial and final temperature settings and the value of the ǫparameter. These values are necessary to achieve the desired eventual exploration of worse solutions. A further characteristic of TAFS over other search algorithms for feature subset selection is its probabilistic capability to accept momentarily worse solutions, which in the end may result in better hypotheses. The TAFS algorithm is evaluated against the Sequential Forward Floating Search (SFFS) proposed by [10], one of the most robust and reliable algorithms. In our ex-
perimental results, TAFS achieves significant improvements in the maximization of the objective function for classification tasks, along with a reasonable reduction in subset size (less reduction than that obtained with SFFS). In contrast, SFFS needs the specification of the desired size of the final solution, a value very difficult to estimate in many practical situations. Figure 1: Algorithm SFFS. SFG (SBG) means the addition (removal) of the best (worst) feature. The set Xkdenotes the current solution (of size k). The document is organized as follows: first we briefly review the FS problem and the SFFS algorithm. Next, we review relevant material on Simulated Annealing. The TAFS algorithm is then introduced in pseudo-code form. The methodology and setting used in the empirical evaluation are covered in the next section, followed by the results. Next, several experiments are conducted to illustrate the behaviour of the algorithm, measuring some indicators of the annealing process. The paper ends with the conclusions and directions for future work. 2 Feature Selection Let X={x1, . . . , xn}, n > 0 denote the full feature set. Without loss of generality, we assume that the objective function (OF) J: P(X)→R+∪ {0}is to be maximized, where Pdenotes the set of parts. At all times in the discussion, Xk⊆Xdenotes a subset of currently selected features, with |Xk|=k. Hence, by definition, X0=∅, and Xn=X. The selection of a feature subset can be made under two premises: •Set 0 < m < n. Find Xm⊂X, such that J(Xm) is maximum. •Set a value J0, the minimum Jthat is going to be accepted. Find the Xm⊆X with smaller msuch that J(Xm)≥J0. Alternatively, given α > 0, find the Xm⊆ Xwith smaller m, such that |J(Xm)− J(X)|< αJ(X). Notice that, with these definitions, the optimal subset of features always exists but is not necessarily unique. In the literature, several suboptimal algorithms have been proposed for FS. Among them, a wide family is formed by those algorithms which, departing from an initial solution, iteratively add or delete features by locally optimizing the OF . Here local has to be understood has “in a neighborhood of the current solution”. These algorithms leave a sequence of visited states with no backtracking and can be cast in the general class of hill-climbing algorithms. Among the proposed such algorithms are the sequential forward generation (SFG) and sequential backward generation (SBG), the plus-l-minus- r(also called plus ltake away r) [1], the Sequential Forward Floating Search (SFFS) and its backward counterpart [10]. The high performance of this algorithm has been studied by [3] and [6] and is best described in flow-chart form, in Fig. 1. 3 Simulated Annealing Simulated Annealing (SA) is a stochastic technique inspired on statistical mechanics for finding near globally optimum solutions to large (combinatorial) optimization problems. SA is a weak method in that it needs almost no information about the structure of the search space. The algorithm works by assuming that some part of the current solution belongs to a potentially better one, and thus this part should be retained by exploring neighbors of the current solution. Assuming the OF is to be minimized, then SA can jump from hill to hill and hence escape or simply avoid suboptimal solutions. When a system S(considered as a set of possible states) is in thermal equilibrium (at a given temperature T), the probability that it is in a certain state s, called 58 Simposio de Inteligencia Computacional
PT(s) depends on Tand on the energy E(s) of the state s. This probability follows a Boltzmann distribution: PT(s) = exp(−E(s) kT ) Z, with Z= s∈S exp(−E(s) kT ) where kis the Boltzmann constant and Zacts as a normalization factor. Metropolis and his co-workers [8] developed a stochastic relaxation method that works by simulating the behavior of a system at a given T. Being sthe current state and s′a neighboring state, the probability of making a transition from sto s′ is the ratio PT(s→s′) between the probability of being in sand the probability of being in s′: PT(s→s′) = PT(s′) PT(s)=exp(−∆E kT ) where we have defined ∆E=E(s′)−E(s). Therefore, the acceptance or rejection of s′ as the new state depends on the difference of the energies of both states at T. If PT(s′)≥ PT(s) then the “move” is always accepted. It PT(s′)< PT(s) then it is accepted with probability PT(s, s′)<1 (this situation corresponds to a transition to a higher-energy state). Note that this probability depends upon and decreases with the current T. In the end, there will be a Tlow enough (the freezing point), wherein these transitions will be very unlikely and the system will be considered frozen. In order to maximize the probability of finding states of minimal energy at every T,thermal equilibrium must be reached. To do this, according to [8], there is an annealing schedule designed to prevent the process from getting stuck at a local minimum. The SA algorithm proposed by [4] consists on using the Metropolis idea at each Tfor a finite amount of time. In this algorithm the Tis first set at a initially high value, spending enough time at it so to approximate thermal equilibrium. Then a small decrement of the Tis performed and the process is iterated until the system is considered frozen. If the cooling schedule is well designed, the final reached state may be considered a near-optimal solution. However, the whole process is inherently slow, mainly because of the thermal equilibrium requirement at every T. 4 A Thermodynamical Algorithm for Feature Selection In this section we introduce TAFS (Thermodynamical Algorithm for Feature Selection), a novel algorithm for FS useful for problems of moderate feature size (up to one hundred). Considering the simulated annealing as a combinatorial optimization process [11], TAFS finds a subset of attributes that maximizes the value of a given OF . A special-purpose FS mechanism is embedded into the Simulated annealing framework, taking advantage of its most distinctive characteristic, the probabilistic acceptance capability of worse scenarios over a finite time. This characterisic is enhanced in TAFS by the notion of an ǫimprovement: a feature ǫ-improves a current solution if it has a higher value of the OF or a value not worse than ǫ%. This mechanism is intended to account for noise in the evaluation of the OF . The pseudo-code of TAFS is depicted in Fig. 2. The algorithm consists of two major loops. The outer loop waits for the inner loop to finish and then updates Taccording to the chosen cooling schedule. When this loop reaches Tmin, the algorithm halts. It keeps track of the best solution found (which is not necessarily the current one). The inner loop is the core of the algorithm and is composed of two interleaved procedures: Forward and Backward, that iterate until an equilibrium point is found. These procedures work independently of each other, but share information about the results of their respective search in the form of the current solution. Within them, FS takes place and the mechanism to escape from local minima starts working. These procedures iteratively add or remove features one at a time in such a way that an ǫ-improvement is accepted unconditionally, whereas a non ǫ-improvement is accepted probabilistically. The pseudo-code for Forward and Backward, and ǫ-improvement is Modelos, métodos y algoritmos en inteligencia computacional 59
Inputs: XnFull Feature set x1. . . xn J() Objective Function α() Cooling Schedule ǫEpsilon T0Initial Temperature Tmin Final Temperature ALGORITHM TAFS(Xn, J, α, ǫ, T0, Tmin) Xcur := ∅Initial current subset Jcur := 0 Initial objective function value T:= T0Initial temperature While T > Tmin Repeat Y:= Xcur F orward (Xcur) Backward (Xcur) until Y=Xcur T:= α(T) endwhile END ALGORITHM Figure 2: TAFS algorithm for feature selection. outlined in Fig. 3. When Forward and Backward finish their respective tasks, TAFS checks is the current solution is the same as it was prior to their execution. If it is the case, Tis adjusted according to the cooling schedule. If it is not, another loop of Forward and Backward is carried out. 5 An Experimental Study In order to determine the potential of TAFS, a number of experimental tests to obtain the best possible subset were developed. These experiments try to be a mixture of different real-life situations. In particular, full feature size ranges from just a few (7) to dozens (60), sample size from hundredths (129) to the thousands (12000) and feature type is either continuous or categorical. The problems have also been selected with a criterion in mind not very commonly found in similar experimental work, namely, that these problems are amenable to FS. By this it is meant that per- PROCEDURE Forward (var Z) Repeat x:= argmax{xi∈Xn\Z|J(Z∪ {xi})} If >ǫ(Z, x, true)then accept := true else ∆J:= J(Z∪ {x})−J(Z) accept := rand(0,1) < e ∆J T endif If accept then Z:= Z∪ {x}endif If J(Z)> Jcur then Jcur := J(Z)endif Until not accept END Forward PROCEDURE Backward (var Z) Repeat x:= argmax{xi∈Z|J(Z\ {xi})} If >ǫ(Z, x, false)then accept := true else ∆J:= J(Z\ {x})−J(Z) accept := rand(0,1) < e ∆J T endif If accept then Z:= Z\ {x}endif If J(Z)> Jcur then Jcur := J(Z)endif Until not accept END Backward FUNCTION >ǫ(Z, x, d) RETURNS boolean If dthen Z′:= Z∪ {x} else Z′:= Z\ {x}endif ∆x:= J(Z′)−J(Z) If ∆x > 0then return true else return −∆x J(Z)< ǫ endif END >ǫ Figure 3: Top: Forward procedure. Middle: Backward procedure (note Zis modified). Bottom:Function for ǫ-improvement. formance benefits clearly from a good selection process (and less clearly or even worsens with a bad one). Further, some of them are artificially generated. Demonstrating improvement in synthetic data sets is sometimes more convincing than doing so in scenarios where the true solution is unknown. This has the added advantage of controlling the amount of relevant features and the sample size. 60 Simposio de Inteligencia Computacional
5.1 Data Sets There are 11 data sets, five of them corresponding to real problems drawn from the UCI repository and six that were generated artificially, as described below. The UCI data sets are Splice,Hepatitis,Wisconsin Diagnostic Breast Cancer (BC), Ionosphere (IO) and Liver Disorder (LD). Artificial problems are Gmonks (categorical) and Kdnf,Knum,Majority,MofN and Parity (binary), generated as follows, letting x1,...,xnbe the relevant features of a problem f, the artificial problems are: GMonks: This problem is a generalization of the classic monks problems. Refer to [9] for a complete definition. Kdnf: A boolean formula in nfeatures is generated in Disjunctive Normal Form (DNF), making sure that all features x1,···, xnappear at least once in the formula but none appears more than once in each clause. fis 1 if the formula evaluates to true in the considered example and 0 otherwise. Knum: The example is split into three equal-sized parts, each interpreted as a natural number, which are then added up. fis 1 if the result is greater than a given threshod, and 0 otherwise. Majority:f(x1,···, xn) = 1 if the majority of xiis equal to 1 and 0 otherwise. MofN:f(x1,···, xn) = 1 if at least M of the nfeatures are equal to 1 and 0 otherwise. Parity: The output is 1 if the number of xi= 1 is odd and 0 otherwise. The main characteristics of these problems are summarized in Table 1. It is important to mention that all the data sets represent two-class tasks. In the case of Splice data set, it was converted from three to two classes by grouping the two less representative classes. 6 Experimental setup and results Each data set was processed with both TAFS and SFFS in wrapper mode [5], using as the OF the accuracy of several classifiers: 1- Nearest Neighbor (1NN) and Decision Tree (DT) for categorical data sets; 1-Nearest Neighbor, Linear and Quadratic discriminant analysis (LDA and QDA) for continuous data sets. In spite of taking more time, Leave- Name size features type Gmonks 12000 60 artif, categ Kdnf 4000 40 artif, categ Knum 4000 30 artif, categ Majority 1000 21 artif, categ MofN 1000 20 artif, categ Parity 1000 20 artif, categ Hepatitis 129 17 real, categ Splice 3175 60 real, categ Breast Cancer 569 30 real, cont Ionosphere 351 34 real, cont Liver Disorder 345 6 real, cont Table 1: Problem characteristics. Size is the number of instances, features is that of features, type is artificial/real and categorical/continous. One-Out Cross validation (LOOCV) was used to obtain reliable generalization estimates. The TAFS parameters are as follows: ǫ= 0.001, T0= 10 and Tmin = 0.0001. The cooling function was chosen to be geometric α(t) = ct, taking c= 0.8, following educated guesses in the literature [11]. The SFFS algorithm needs a user-specified parameter d(Fig. 1), the desired final size of the solution, acting as a stop criterion1. This parameter is difficult to estimate in practice. To overcome this, we decided to perform two sets of experiments (E1 and E2). In experiment E1 SFFS is modified so as to stop whenever there is no improvement in the mandatory SFG step (therefore no dvalue is needed). In experiment E2, the algorithm is used in its original form and dis set to the optimal size of the solution found by TAFS. Although this heuristic distorts the comparison (in a practical application, certainly one would not use TAFS to initialise SFFS), it does so in favor of SFFS, which is given sort of a “privileged information”. The alternative (choosing a heuristically obtained value) would have been unfair to SFFS. Note this has the effect of equaling final subset sizes for both algorithms. A number of questions are raised prior to the realization of the experiments: 1. Does the FS process help to find solutions 1In all cases we set ∆ = 0. Modelos, métodos y algoritmos en inteligencia computacional 61
TAFS NR 1NN DT 1NN DT Data Set Jopt k Jopt k Jopt Jopt Gmonks 0.87 7 0.81 2 0.81 0.81 Kdnf 0.77 12 0.59 2 0.59 0.59 Knum 0.91 12 0.52 2 0.68 0.52 Majority 0.95 9 0.64 2 0.64 0.64 MofN 0.84 12 0.62 2 0.65 0.62 Parity 0.58 11 0.51 2 0.53 0.51 Hepatitis 0.91 4 0.90 8 0.81 0.81 Splice 0.90 6 0.52 2 0.77 0.52 Table 2: Performance of TAFS on categorical data sets. Jopt is the final (best) value of the objective function; kis the reduction in feature size. NR are the results with no reduction. of similar or better accuracy using less features? 2. Is there any systematic difference in performance for the various classifiers? 3. In the settings of E1 it is reasonable to expect that SFFS finds smaller subsets (probably smaller than TAFS). Which of them finds better solutions in terms of J? 4. In the settings of E2 both algorithms end up in the same size. Which of them finds better solutions in terms of J? SFFS (E1) SFFS (E2) 1NN DT 1NN DT Data Set Jopt k Jopt k Jopt Jopt Gmonks 0.81 2 0.81 2 0.86 0.81 Kdnf 0.62 4 0.59 2 0.71 0.59 Knum 0.90 17 0.52 2 0.90 0.52 Majority 0.73 3 0.64 2 0.94 0.62 MofN 0.71 3 0.62 2 0.81 0.64 Parity 0.54 2 0.51 2 0.56 0.50 Hepatitis 0.90 4 0.81 2 0.90 0.82 Splice 0.90 6 0.52 2 0.90 0.51 Table 3: Performance of SFFS on categorical data sets. Final TAFS and SFFS performance results are presented for both sets of experiments, as follows, the results for categorical data sets are displayed in Tables 2 and 3 and the results for continuous data sets are displayed in Table 4. Tables also display the results obtained with no feature selection, as a reference. In all cases, the final (best) values of the objective function Jand the size of the solution are shown. 7 Discussion Upon realization of the results we can give answers to the previously raised questions. 1. The FS process indeed helps to find solutions of similar or better accuracy using (much) lower numbers of features. This is true for both algorithms and most of the classifiers. 2. In all cases, and for categorical data sets, 1NN outperforms DT. This is because DT has its own feature selection process which, in the end, yields very small subsets. For the continuous data sets the results are non-conclusive, but LDA/QDA seem a bit superior. 3. In the settings of E1 the hypothesis that SFFS finds subsets of smaller size than TAFS is confirmed. In this situation TAFS outperforms SFFS in all of the data sets in terms of the OF , no matter the classifier. This result should not be overlooked, since it is by no means clear that solutions of bigger size should have better value of the OF . Further, in order to avoid the danger of loosing relevant information, many times it is better to accept solutions of somewhat bigger size if these entail a significantly higher value of the OF . The only exception is the Splice data set for which both algorithms are in ties. However, in this case, TAFS finds a solution of smaller size. 4. In the settings of E2 both algorithms are forced to end up in the same size. In this scenario the two algorithms yield solutions of similar OF value. Nonetheless, TAFS is always on the lead. It is observed that TAFS produces slightly bigger relative reductions with respect to data 62 Simposio de Inteligencia Computacional
TAFS NR SFFS (E1) SFFS (E2) 1NN LDC QDC 1NN LDC QDC 1NN LDC QDC 1NNLDCQDC Jopt k Jopt k Jopt k Jopt Jopt Jopt Jopt k Jopt k Jopt k Jopt Jopt Jopt BC 0.97 18 0.97 23 0.98 13 0.97 0.99 0.96 0.95 5 0.96 3 0.96 3 0.92 0.97 0.97 IO 0.93 20 0.89 16 0.95 18 0.36 0.84 0.87 0.91 5 0.87 4 0.91 6 0.90 0.87 0.91 LD 0.67 3 0.68 4 0.64 4 0.61 0.68 0.56 0.63 2 0.65 2 0.61 2 0.64 0.64 0.62 Table 4: Performance of TAFS and SFFS on the continuous data sets. Jopt is the final (best) value of the objective function; kis the reduction in feature size. NR are the results with no reduction. sets having more features, representing this matter a promising characteristic, under these conditions. Also, if the solutions delivered by SFFS are worse that those delivered by TAFS, this is because SFFS did never came across them in the search process (otherwise they would have been recorded). In this sense it is conjectured that TAFS can have a better access to hidden good subsets than SFFS does. Further, TAFS gives priority to optimize the OF , without any specific concern for reducing the final size, resulting in better values of accuracy. 8 How does TAFS work? In order to apply any generic sampling technique like SA over many classes of nonlinear problems, it should be expected that tuning of some basic search parameters will be required. One must specify at least the neighbor selection method and the annealing schedule. These choices can have a significant impact on the method’s effectiveness. The twophase interleaved mechanism for forward and backward exploration seems to improve the neighborhood exploration of a configuration, thereby contributing to a faster relaxation of the algorithm. In consequence, the setup of the algorithm is then made easier than a conventional SA algorithm since the time spent at each Tis automatically and dynamically set. Furthermore in our experiments this mechanism does not lead to the stagnation of the process. If Tis reduced sufficiently slowly, TAFS can reach a steady state or equilibrium. To illustrate the mechanism and performance of the TAFS algorithm, we will use one of the experiments using the Kdnf problem. Fig. 4 shows the evolution of the annealing process going from initial to final Tvalues. This data set consists of 4000 examples and 40 binary features2. In this same run SFFS gets a Jvalue of 0.71 with 12 features (experiment E2). TAFS starts its process reaching one good solution at the seventh cycle. It permits degradation of Jat several cycles (e.g. 13, 19, 22, 23). Stabilization initiates approximately at cycle 28. A steady state is reached at the 38th cycle, giving a notorious increment in the final value of accuracy over SFFS: TAFS gives 0.77 of J with a different subset of 12 features. 0 10 20 30 40 50 60 0.55 0.6 0.65 0.7 0.75 0.8 Cycle Accuracy TAFS BSFS SFFS BSFS Figure 4: TAFS performance on the Kdnf Data Set. The boxes labeled ’BSFS’ indicate the final solutions. That obtained SFFS only indicates the final objective function value. Another issue analyzed is the distribution of features as selected by TAFS. In order to determine this, a perfectly known data set is needed. We chose the Majority data set, of which 10 different data samples of 1000 examples each were generated with the corresponding 20 features and using 31 diferent values of the epsilon parameter (from 10−1to 10−7in steps of 1 310−3) , amounting to a total of 310 2This run took 3 hours to complete and 52 annealing cycles. Modelos, métodos y algoritmos en inteligencia computacional 63
0 10 20 30 40 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 Features Frequency Figure 5: Distribution of features for the Majority data set as selected by TAFS. runs. The truth about Majority data set is: 8 relevant features (1-8), 8 irrelevant (9-16) and 5 redundant (17-21). Results are shown in Fig. 5. It is remarkable that TAFS gives priority to all the relevant features in almost all cases, rejects all the irrelevant features, and some of the redundant features are allowed (which account for the performance of 0.95. These figures should be compared to the performance of 0.64 obtained with the full feature set. 9 Conclusion A new algorithm for FS has been introduced based on simulated annealing. Experimental results indicate that it offers a solid and reliable framework for moderate-size FS tasks. The final subsets generated by TAFS in classification problems using a number of inducers as wrappers show remarkable results in most cases superior to the full feature set. In comparative results with the floating forward algorithm, TAFS generates feature subsets with substantially better classification power with a higher number of features, representing this an interesting option for data mining practitioners. The future work is devised to explore the precise influence of the ǫparameter and the use of simulated annealing enhancements, such as simulated re-annealing [2]. 10 Acknowledgements Authors wish to thank to Spanish CICyT Project no. CGL2004-04702-C02-02, CONA- CyT and UABC for supporting this research. References [1] Devijver, P., and Kittler, J. Pattern Recognition - A Stat. Approach. Prentice Hall, London, GB, 1982. [2] Ingber, L. Very fast simulated reannealing. Mathl. Comput. Modelling 12, 8 (1989), 967-973. [3] Jain, A., and Zongker, D. Feature selection: Eval., application, and small sample performance. IEEE Trans. Pattern Anal. Mach. Intell. 19, 2 (1997), 153-158. [4] Kirkpatrick, S. Optimization by simulated annealing: Quantitative studies. J. of Stat. Phy. 34 (1984). [5] Kohavi, R., and John, G. H. Wrappers for feature subset selection. Artificial Intell. 97, 1-2 (1997), 273-324. [6] Kudo, M., Somol, P., Pudil, P., Shimbo, M., and Sklansky, J. Comparison of classifier-specific feature selection algorithms. In Procs. of the Joint IAPR Intl. Workshop on Adv. in Pattern Recognition (2000), pp. 677-686. [7] Liu, H., and Motoda, H. Feature Selection for Knowledge Discovery and Data Mining. Kluwer Academic Publishers, London, GB, 1998. [8] Metropolis, N., Rosenbluth, A., Rosenbluth, M., Teller, A., and Teller, E. Equations of state calculations by fast computing machines. J. of Chem. Phy. 21 (1953). [9] Molina, S., Belanche, L. and NEbot, A. Feature selection algorithms: a survey and experimental evaluation. In IEEE Int. Conf. on Data Mining (2002), pp. 306-313. [10] Pudil, P., Ferri, F., Novovicova, J., and Kittler, J. Floating search methods for feature selection. PRL 15, 11 (November 1994), 1119-1125. [11] Reeves, C. R. Modern Heuristic Techniques for Combinatorial Problems. Mc- Graw Hill, 1995. 64 Simposio de Inteligencia Computacional