Feature Selection with the Boruta Package

This article describes a R package Boruta , implementing a novel feature selection algorithm for ﬁnding all relevant variables . The algorithm is designed as a wrapper around a Random Forest classiﬁcation algorithm. It iteratively removes the features which are proved by a statistical test to be less relevant than random probes. The Boruta package provides a convenient interface to the algorithm. The short description of the algorithm and examples of its application are presented


Introduction
Feature selection is often an important step in applications of machine learning methods and there are good reasons for this.Modern data sets are often described with far too many variables for practical model building.Usually most of these variables are irrelevant to the classification, and obviously their relevance is not known in advance.There are several disadvantages of dealing with overlarge feature sets.One is purely technical -dealing with large feature sets slows down algorithms, takes too many resources and is simply inconvenient.Another is even more important -many machine learning algorithms exhibit a decrease of accuracy when the number of variables is significantly higher than optimal (Kohavi and John 1997).Therefore selection of the small (possibly minimal) feature set giving best possible classification results is desirable for practical reasons.This problem, known as minimaloptimal problem (Nilsson, Peña, Björkegren, and Tegnér 2007), has been intensively studied and there are plenty of algorithms which were developed to reduce feature set to a manageable size.
Nevertheless, this very practical goal shadows another very interesting problem -the identification of all attributes which are in some circumstances relevant for classification, the so-called all-relevant problem.Finding all relevant attributes, instead of only the non-redundant ones, may be very useful in itself.In particular, this is necessary when one is interested in understanding mechanisms related to the subject of interest, instead of merely building a black box predictive model.For example, when dealing with results of gene expression measurements in context of cancer, identification of all genes which are related to cancer is necessary for complete understanding of the process, whereas a minimal-optimal set of genes might be more useful as genetic markers.A good discussion outlining why finding all relevant attributes is important is given by Nilsson et al. (2007).
The all-relevant problem of feature selection is more difficult than usual minimal-optimal one.One reason is that we cannot rely on the classification accuracy as the criterion for selecting the feature as important (or rejecting it as unimportant).The degradation of the classification accuracy, upon removal of the feature from the feature set, is sufficient to declare the feature important, but lack of this effect is not sufficient to declare it unimportant.One therefore needs another criterion for declaring variables important or unimportant.Moreover, one cannot use filtering methods, because the lack of direct correlation between a given feature and the decision is not a proof that this feature is not important in conjunction with the other features (Guyon and Elisseeff 2003).One is therefore restricted to wrapper algorithms, which are computationally more demanding than filters.
In a wrapper method the classifier is used as a black box returning a feature ranking, therefore one can use any classifier which can provide the ranking of features.For practical reasons, a classifier used in this problem should be both computationally efficient and simple, possibly without user defined parameters.
The current paper presents an implementation of the algorithm for finding all relevant features in the information system in a R (R Development Core Team 2010) package Boruta (available from the Comprehensive R Archive Network at http://CRAN.R-project.org/package=Boruta).The algorithm uses a wrapper approach built around a random forest (Breiman 2001) classifier (Boruta is a god of the forest in the Slavic mythology).The algorithm is an extension of the idea introduced by Stoppiglia, Dreyfus, Dubois, and Oussar (2003) to determine relevance by comparing the relevance of the real features to that of the random probes.Originally this idea was proposed in the context of filtering, whereas here it is used in the wrapper algorithm.In the remaining sections of this article firstly a short description of the algorithm is given, followed by the examples of its application on a real-world and artificial data set.

Boruta algorithm
Boruta algorithm is a wrapper built around the random forest classification algorithm implemented in the R package randomForest (Liaw and Wiener 2002).The random forest classification algorithm is relatively quick, can usually be run without tuning of parameters and it gives a numerical estimate of the feature importance.It is an ensemble method in which classification is performed by voting of multiple unbiased weak classifiers -decision trees.These trees are independently developed on different bagging samples of the training set.The importance measure of an attribute is obtained as the loss of accuracy of classification caused by the random permutation of attribute values between objects.It is computed separately for all trees in the forest which use a given attribute for classification.Then the average and standard deviation of the accuracy loss are computed.Alternatively, the Z score computed by dividing the average loss by its standard deviation can be used as the importance measure.Unfortunately the Z score is not directly related to the statistical significance of the feature importance returned by the random forest algorithm, since its distribution is not N (0, 1) (Rudnicki, Kierczak, Koronacki, and Komorowski 2006).Nevertheless, in Boruta we use Z score as the importance measure since it takes into account the fluctuations of the mean accuracy loss among trees in the forest.
Since we cannot use Z score directly to measure importance, we need some external reference to decide whether the importance of any given attribute is significant, that is, whether it is discernible from importance which may arise from random fluctuations.To this end we have extended the information system with attributes that are random by design.For each attribute we create a corresponding 'shadow' attribute, whose values are obtained by shuffling values of the original attribute across objects.We then perform a classification using all attributes of this extended system and compute the importance of all attributes.
The importance of a shadow attribute can be nonzero only due to random fluctuations.Thus the set of importances of shadow attributes is used as a reference for deciding which attributes are truly important.
The importance measure itself varies due to stochasticity of the random forest classifier.Additionally it is sensitive to the presence of non important attributes in the information system (also the shadow ones).Moreover it is dependent on the particular realization of shadow attributes.Therefore we need to repeat the re-shuffling procedure to obtain statistically valid results.
In short, Boruta is based on the same idea which forms the foundation of the random forest classifier, namely, that by adding randomness to the system and collecting results from the ensemble of randomized samples one can reduce the misleading impact of random fluctuations and correlations.Here, this extra randomness shall provide us with a clearer view of which attributes are really important.
The Boruta algorithm consists of following steps: 1. Extend the information system by adding copies of all variables (the information system is always extended by at least 5 shadow attributes, even if the number of attributes in the original set is lower than 5).
2. Shuffle the added attributes to remove their correlations with the response.
3. Run a random forest classifier on the extended information system and gather the Z scores computed.
4. Find the maximum Z score among shadow attributes (MZSA), and then assign a hit to every attribute that scored better than MZSA.
5. For each attribute with undetermined importance perform a two-sided test of equality with the MZSA.
6. Deem the attributes which have importance significantly lower than MZSA as 'unimportant' and permanently remove them from the information system.
7. Deem the attributes which have importance significantly higher than MZSA as 'important'.
8. Remove all shadow attributes.9. Repeat the procedure until the importance is assigned for all the attributes, or the algorithm has reached the previously set limit of the random forest runs.
In practice this algorithm is preceded with three start-up rounds, with less restrictive importance criteria.The startup rounds are introduced to cope with high fluctuations of Z scores when the number of attributes is large at the beginning of the procedure.During these initial rounds, attributes are compared respectively to the fifth, third and second best shadow attribute; the test for rejection is performed only at the end of each initial round, while the test for confirmation is not performed at all.
The time complexity of the procedure described above in realistic cases is approximately O(P • N ), where P and N are respectively the numbers of attributes and objects.That may be time consuming for large data sets; still, this effort is essential to produce a statistically significant selection of relevant features.
To illustrate the scaling properties of Boruta algorithm we performed following experiment using Madalon data set.It is an artificial data set, which was one of the NIPS2003 problems.(Guyon, Gunn, Ben-Hur, and Dror 2005) The data set contains 2000 objects described with 500 attributes.We generated subsamples of Madelon set containing 250, 500, 750, . . ., 2000 objects.Then for each subsample we created seven extended sets containing respectively 500, 1000, . . ., 3500 superficial attributes obtained as a uniform random noise.Then we performed standard feature selection with Boruta on each of 64 test sets and measured the execution time.The results of the experiment are displayed in Figure 1.One may see almost perfect linear scaling for the increasing number of attributes.On the other hand execution times grow faster than the number of objects, but the difference is not very big and it seems to converge to linear scaling for large number of objects.
The timings are reported in CPU hours.Using the values from the largest data set, one can estimate the time required to complete Boruta run on a single core of modern CPU to be one hour per one million (attribute × objects).
One should notice that in many cases, in particular for a biomedical problems, the computation time is a small fraction of the time required to collect the data.One should also note, that the prime reason for running the 'all-relevant' feature selection algorithm is not the reduction of computation time (altough it can be achieved if the data set pruned from non-informative attributes will be subsequently analysed numerous times).The main reason is to find all attributes for which their correlation with decision is higher than that of the random attributes.Moreover, while Boruta is generally a sequential algorithm, the underlying random forest classifier is a trivially parallel task and thus Boruta can be distributed even over a hundreds of cores, provided that a parallel version of the random forest algorithm is used.

Using the Boruta package
The Boruta algorithm is implemented in Boruta package.
R> library("Boruta") R> library("mlbench") R> data("Ozone") R> Ozone <-na.omit(Ozone) The algorithm is performed by the Boruta function.For its arguments, one should specify the model, either using a formula or predictor data frame with a response vector; the confidence level (which is recommended to be left default) and the maximal number of random forest runs.
One can also provide values of mtry and ntree parameters, which will be passed to randomForest function.Normally default randomForest parameters are used, they will be sufficient in most cases since random forest performance has rather a weak dependence on its parameters.If it is not the case, one should try to find mtry and ntree for which random forest classifier achieves convergence at minimal value of the OOB error.
Setting doTrace argument to 1 or 2 makes Boruta report the progress of the process; version 2 is a little more verbose, namely it shows attribute decisions as soon as they are cleared.
Figure 2 shows the Z scores variability among attributes during the Boruta run.It can be easily generated using the plot method of Boruta object: R> plot(Boruta.Ozone) One can see that Z score of the most important shadow attribute clearly separates important and non important attributes.
Moreover, it is clearly evident that attributes which consistently receive high importance scores in the individual random forest runs are selected as important.On the other hand, one can observe quite sizeable variability of individual scores.The highest score of a random attribute in a single run is higher than the highest importance score of two important attributes, and the lowest importance score of five important attributes.It clearly shows that the results of Boruta are generally more stable than those produced by feature selection methods based on a single random forest run, and this is why several iterations are required.
Due to the fact that the number of random forest runs during Boruta is limited by the maxRuns argument, the calculation can be forced to stop prematurely, when there are still attributes which are judged neither to be confirmed nor rejected -and thus finally marked tentative.
For instance 1 : R> set.seed(1)R> Boruta.Short <-Boruta(V4 ~., data = Ozone, maxRuns = 12) 1 The number of steps and the seed were intentionally selected to show this effect in the familiar data set.Due to slight differences between Windows and Linux versions of randomForest package, which probably arise due to compilation, the actual results of the procedure described above might differ slightly from the results shown here (these were obtained in R version 2.10.0 and randomForest version 4.5-33 on x86-64 Linux workstation).q q q q q q q q q randMin V2 V3  Running Boruta (execution may take a few hours): R> set.seed(7777)R> Boruta.Madelon <-Boruta(decision ~., data = Madelon)

R> Boruta.Madelon
Boruta performed 51 randomForest runs in 1.861855 hours.20 attributes confirmed important: (the rest of the output was omitted) One can see that we have obtained 20 confirmed attributes.The plotZScore function visualizes the evolution of attributes' Z scores during a Boruta run: R> plotZHistory(Boruta.Madelon) The result can be seen on Figure 3.One may notice that consecutive removal of random noise increases the Z score of important attributes and improves their separation from the unimportant ones; one of them is even 'pulled' out of the group of unimportant attributes just after the first initial round.Also, on certain occasions, unimportant attributes may achieve a higher Z score than the most important shadow attribute, and this is the reason why we need multiple random forest runs to arrive at a statistically significant decision.
The reduction of attribute number is considerable (96%).One can expect that the increase of accuracy of a random forest classifier can be obtained on the reduced data set due to the elimination of noise.
It is known that feature selection procedure can introduce significant bias in resulting models.
For example Ambroise and McLachlan (2002) have shown that, with the help of feature selection procedure, one can obtain a classifier, which is using only non-informative attributes and is 100% accurate on the training set.Obviously such classifier is useless and is returning random answers on the test set.
Therefore it is necessary to check whether Boruta is resistant to this type of error.It is achieved with the help of cross-validation procedure.The part of the data is set aside as a test set.Then the complete feature selection procedure is performed on the remaining data set -a training set.Finally the classifier obtained on the training set is used to classify objects from the test set to obtain classification error.The procedure is repeated several times, to obtain estimate of the variability of results.
Boruta performs several random forest runs to obtain statistically significant division between important and irrelevant attributes.One should expect that ranking obtained in the single RF run should be quite similar to that obtained from Boruta.We can check if this is the case, taking advantage of the cross-validation procedure described above.
Madelon data was split ten times into train and test sets containing respectively 90% and 10% of objects.Than, Boruta was run on each train set.Also, three random forest classifiers were generated on each train set: first using all attributes, the second one using only these attributes that were selected by Boruta, and the third one using the same number of attributes as found by Boruta, but selected as a top important by the first random forest trained on all attributes.Finally, the OOB error estimate on a train set and the error on a test set for all classifiers was collected.
The results are shown in the mean of the differences -0.182 As one may expect, the feature ranking provided by plain random forest agrees fairly well with Boruta results.This explains why the simple heuristic feature selection procedure in random forest, namely selecting a dozen or so top scoring attributes, works well for obtaining good classification results.Nevertheless, this will not necessarily be a case when dealing with larger and more complex sets, where stochastic effects increase the variability of the random forest importance measure and thus destabilize the feature ranking.
One should note that the Boruta is a heuristic procedure designed to find all relevant attributes, including weakly relevant attributes.Following Nilsson et al. (2007), we say that attribute is weakly important when one can find a subset of attributes among which this attribute is not redundant.The heuristic used in Boruta implies that the attributes which are significantly correlated with the decision variables are relevant, and the significance here means that correlation is higher than that of the randomly generated attributes.Obviously the set of all relevant attributes may contain highly correlated but still redundant variables.Also, the correlation of the attribute with the decision does not imply causative relation; it may arise when both decision attribute and descriptive attribute are independently correlated with some other variable.An illustrative example of such situation was given by Strobl, Hothorn, and Zeileis (2009).Users interested in finding a set of highly relevant and uncorrelated attributes within the result returned by Boruta may use for example package party (Strobl et al. 2009), caret (Kuhn 2008;Kuhn, Wing, Weston, Williams, Keefer, and Engelhardt 2010), varSelRF (Diaz-Uriarte 2007, 2010) or FSelector (Romanski 2009) for further refinement.

Summary
We have developed Boruta, a novel random forest based feature selection method, which provides unbiased and stable selection of important and non-important attributes from an information system.Due to the iterative construction, our method can deal both with the fluctuating nature of a random forest importance measure and the interactions between attributes.We have also demonstrated its usefulness on an artificial data set.The method is available as an R package.

Figure 1 :
Figure1: The scaling properties of Boruta with respect to the number of attributes (left) and number of objects (right).Each line on the left panel corresponds to the set with identical number of objects and on the right panel it corresponds to the set with identical number of attributes.One may notice that scaling is linear with respect to number of attributes and not far from linear with respect to the number of objects.

Figure 3 :
Figure3: Z score evolution during Boruta run.Green lines correspond to confirmed attributes, red to rejected ones and blue to respectively minimal, average and maximal shadow attribute importance.Gray lines separate rounds.
One should consider increasing the maxRuns parameter if tentative attributes are left.Nevertheless, there may be attributes with importance so close to MZSA that Boruta won't be able to make a decision with the desired confidence in realistic number of random forest runs.Therefore Boruta package contains a TentativeRoughFix function which can be used to fill missing decisions by simple comparison of the median attribute Z score with the median Z score of the most important shadow attribute: Figure 2: Boruta result plot for ozone data.Blue boxplots correspond to minimal, average and maximum Z score of a shadow attribute.Red and green boxplots represent Z scores of respectively rejected and confirmed attributes.

Table 1 .
One can see that both the OOB error as well as the error on the test set is consistently smaller for random forest runs performed on the reduced set of attributes.This observation is verified by a t test:

Table 1 :
Cross-validation of the error reduction due to limiting the information system to attributes claimed confirmed by Boruta.