• Nie Znaleziono Wyników

Random Selection of Variables for Aggregated Tree-Based Models

N/A
N/A
Protected

Academic year: 2021

Share "Random Selection of Variables for Aggregated Tree-Based Models"

Copied!
9
0
0

Pełen tekst

(1)

A C T A U N I V E R S I T A T I S L O D Z I E N S I S FO LIA O EC O N O M IC A 196, 2006

Eugeni usz G a t n a r *, D o r o t a R o z m u s **

R A N D O M SELECTIO N OF VARIABLES FO R AGGREGATED TREE-BASED M O D E L S

Abstract. Tree-based models are popular a widely used because they are simple, flexible and powerful tools for classification. U nfortunately they are not stable classifiers.

Significant im provem ent o f the model stability and prediction accuracy can be obtained by aggregation of multiple classification trees. Proposed methods, i.e. bagging, adaptive bagging, and arcing are based on sampling cases from the training set while boosting uses a system o f weights for cases. The result is called comm ittee of trees, an ensemble or a forest.

Recent developments in this field showed that random ization (random selection o f va­ riables) in aggregated tree-based classifiers leads to consistent models while boosting can overfit.

In this paper we discuss optimal param eter values for the method o f random selection o f variables (RandomForest) for an aggregated tree-based model (i.e. num ber of trees in the forest and num ber of variables selected for each split).

Key words: Tree-based models, aggregation, RandomForest.

1. IN TRO D U C TIO N

The m ost successful aggregation m ethods in classification, i.e. bagging, adaptive bagging, and arcing are based on sampling cases from the training set while boosting is deterministic and uses a system o f weights for cases and combined m odels.

Although resampling causes major m odification o f the distribution o f predictors in the training samples, significant improvement o f classification

* Professor, D epartm ent of Statistics, The K arol A damiecki University o f Economics, Katowice.

** Assistant, D epartm ent o f Statistics, The K arol Adamiecki University o f Economics, Katowice.

(2)

accuracy can be also achieved by random selection o f variables to training samples or directly to the model.

Recent developments in this field showed that the randomization leads to consistent m odels while boosted models can overfit for large number o f their com ponents.

A classifier С is a function that maps from object descriptions (X) to class names (У):

and it is found by learning a set o f previously classified objects, called “training set” T :

where is an element from M -dimensional space X, and y t is an element from discrete space У. The goal o f the learning is to find a classifier C(x) that gives the lowest prediction error.

In order to measure the error between у and C(x) we use a loss function. In regression it has a form o f the squared error:

M ostly the prediction error o f C(x) is estimated using an independent test set T. In the absence o f this set one can use the training set, but the model is likely to overfit (the classification error is equal zero for large enough m odel). Different strategies are proposed to get better estim ation o f the error, e.g. cross-validation or bootstrapping.

C : X — Y (1)

T — {(^ ľ x t)> (ľa. x2)> •••» (Ум. xjv)}>

(

2

)

L(y, ć (x )) = ( у - Ć (x))2, (3)

and in classification it is a 0 - 1 function:

(4)

2. CLA SSIFICA TION TR EES

(3)

where R k are hyper-rectangular disjoint regions in the M -dimensional feature space, ak denotes real parameters and / is an indicator function (Gatnar

2001).

Each real-valued dimension o f the region Rk is characterized by its upper and lower boundary: vj^ i vjjjj respectively. Therefore the region induces a product o f M indicator functions:

I ( x e R k) =

П « < * т ОЙ>),

(6)

m= X

If x m is a categorical variable, the region R k is defined as:

/(х е Я * ) = n ^ e i U , (7)

m = 1

where Bm is a subset o f the set o f the variable values.

T he parameter estimation formula depends on how the hom ogenity of the region R k is measured. In the simplest case the entropy function is applied:

В Д = - IpO|fc)iog2pOlfc).

(8)

]= 1

The parameters o f the m odel (5) are estimated using the majorization method:

ak = arg m'dx{p(j\k)}, (9)

where p( j \ k ) is the fraction o f objects in region R k that belong to the class j.

3. AGGREGATION

The successful tree-based m ethodology has one undesirable feature: lack o f stability. That is a tree m odel depends on the training set and even small change in a predictor value could lead to a quite different model. T o solve this problem, single trees are combined into one m odel and then averaged.

In the aggregate C*(x) the component models vote for the predicted class:

C*(x) = arg m a x i £ I ( ć n(x) = у) y U = i

(4)

Several variants o f aggregation methods were proposed. They manipulate training cases (random sampling) or predictors (random selection) or values o f the у (system o f weights) or involve randomness directly.

Combined classifiers have lower error rate than single m odels and can give more insight. But they have two serious disadvantages

• slow learning (requires large computer memory),

• loss o f comprehensibility (less structure and huge models).

Perhaps stacking or stacking generalization (Wolpert 1992) was the first method used for com bining m odels in statistics. The m odels C ' ^ x ) are fitted to training samples U ~ l obtained by leave-one-out cross-validation (i.e. with i-th observation removed).

Quinlan (1993) implemented in his C4.5 system a method called win­ dowing that enlarges the initial random sample drawn from the training set by adding in consecutive steps cases misclassified in the previous step.

Bagging (Bootstrap A G G regatlN G ) was the first aggregation method proposed by Breiman (1996). It used multiple training bootstrap samples U lt t / 2, ..., UM to create classifiers that vote for the final prediction (10).

There are two variants o f bagging:

1. Adaptive bagging proposed by Breiman (1999) that works by changing output values у by using “out-of-bag” cases in subsequent steps:

where C(x,) is the average over predicted values for training samples Um such that x ; ф Um.

2. Wagging introduced by Bauer and Kohavi (1999) is similar to bagging, but reweights cases instead o f sampling them from the training set.

The m ost accurate classifiers are those combined by adaptive boosting. The algorithm AdaBoost . M 1 developed by Freund and Schapire (1997) is deterministic, sequential and works with two systems o f weights: assigned to training examples and assigned to com ponent models.

Initially the weights o f cases are uniform wt = but in consecutive steps the weights o f cases misclassified in the previous step are increased by a factor inversely proportional to the training sample error:

уГ 1) = # _ С (х1),

(

11

)

w<f+ 1) _ W(J) . ( 12)

(5)

and the error rate e is:m

N

e,m (14)

1=1 The final prediction is:

С Af

ć* (x ) = argmax^ £ amI ( Ć J x ) = у ) (15) У (т= 1

Breiman referred to AdaBoost with trees as “the best classifier in the world” . There are two variants o f boosting: boosting by weighting (A d aB oost.M l) and boosting by sampling (cases are sampled from the training set with probability proportional to their weights).

Because o f the apparent success o f AdaBoost, Breiman (1998) applied a system o f weights to his new Arc-x4 sequential algorithm (based on bootstrap sampling) called Arcing (Adaptive Resampling and C om binlN G ). Arc-x4 increases weights o f misclassified cases:

where n(xf) is the number o f misclassifications o f the case x, by classifiers:

M ethods presented so far are based on sampling cases to the training samples but there are other m ethods that use random selection o f variables to the tree model.

The first method has been developed by H o (1998) and called “ Random subspaces” . Each tree in the ensemble is fitted to the training sample containing all cases from the training set but with randomly selected features.

Random split selection has two variants. Dietterich and K ong (1995) proposed to select the split at random from among the К best splits, while Breiman (1999) proposed to select at random a small group o f predictors and then to find the best o f them that would form the split.

Recently Breiman (2001) developed a system involving random sampling called RandomForests (RF). It contains tw o procedures: RV and RC. In the first one at each node К variables are selected at random and the best split is chosen from among them.

wi = 1 + [« W ]4, (16)

(6)

In the other procedure К variables are randomly selected and added with coefficients that are uniform random numbers from [-1 ,1 ]. Then L linear com binations are generated and the best one is selected for split.

RandomForests is equal or better than AdaBoost in classification accuracy, but it is robust to noise, faster and it does not overfit.

5. EXAM PLE

Using RandomForests to build a classifier two parameters should be taken into consideration: number o f trees in the forest and number o f features randomly chosen at each node o f a single tree. These two para­ meters are responsible for the accuracy o f the model.

As far as the first parameter is discussed, it can be said that the more ensembles are built, the better model we get. It is so because this kind of aggregation doesnot lead to overfitting. The second parameter is the only parameter that needs some judgement to set, but many experiments have shown that forests are not too sensitive to its value (Breiman 2001).

In order to check how these two parameters influence on the model performance, we used the data set “ Satimage” from the UCI Repository (Blake et al. 1998). We have chosen it because o f a large size (4435 objects) and the fact that there is a separate test set (2000 objects). Objects in this database are fragments o f the Earth image from satellite “ Landsat” . Each object is described by 36 numerical features and belongs to one from six possible classes indicating a kind o f ground exploitation.

The aim o f the first study is to check the influence o f the number of trees in the forest on the aggregated model error rate. T he whole experiment was carried out due to the following scheme:

1. The number o f features randomly selected at each node take as a constant, equal 6.

2. The number o f trees take equal L = 50.

3. Build an aggregated model; calculate the error rate on learning set and test set.

4. Repeat the experiment 100 times and average the error rate, corres­ pondingly for learning and test set.

5. Take L — L + 50 and go to step 3. 6. When L = 500, stop the experiment.

The result o f the study is shown in Figure 1. What we can see is that adding more and more trees generally causes dropping o f error rate, both on learning and test set. The tendency is more noticeable on learning set while on test set it shows tendency to stabilise. The biggest drop is noticed between 50 and 100 trees.

(7)

number o f trees

Fig. 1. Effect o f the number o f trees in the forest on error rate

The second experiment was carried out in order to find the result of the number o f features randomly selected for every node on aggregated m odel performance. The scheme is as follows:

1. The number o f trees in the forest take as a constant, equal 100. 2. The number o f features take equal C = 1.

3. Build an aggregated model; calculate the error rate on learning set and test set.

4. Repeat the experiment 100 times and average the error rate, corres­ pondingly for learning and test set.

5. Take С = С -t- 1 and go to step 3. 6. When С = 30, stop the experiment.

Again we get series o f values o f learning and test set error that is shown in Figure 2. A t the beginning, choosing more and more features causes stable drop in error rate, both in learning and test set. Than they increase a little, drop again and then show stable tendency for increasing.

The computer program, RandomForest, uses a special formula to estimate the error rate on learning set (out-of-bag). That is why we decided to com pare the gained results with much more popular way o f computing error rate, i.e. cross-validation. U sing procedure boosting that is available in R we have estimated the error rate, dividing the whole learning set into 10 parts. As is shown in Figure 2, the tendency o f CV error is generally the same as described above; and it is a little bigger than the OOB error.

(8)

0 5 10 15 20 25 30

n u m b e r o f fe a tu r e s

Fig. 2. ElTect o f num ber o f random ly selected features on error rate

Results from the second study correspond to results described by Breiman (2003). He found that setting number o f trees equal to the square root o f number o f all number o f variables gives generally near optimum results. He advised to begin with this value and try a value twice as high and half as low, m onitoring the result on error rate.

REFERENCES

Blake C., K eogh E., M erz C. J. (1998), UC1 Repository o f Machine Learning Databases, D epartam ent o f Inform ation and Com puter Science, University o f California, Irvine, CA. B auer E., K ohavi R. (1999), “A n Empirical Com parison o f V oting Classification Algorithms:

Bagging, Boosting, and V ariants” , Machine Learning, 36, 105-142.

Breiman L. (2003), M anual on Settings up, Using and U nderstanding R andom Forest, http://oz.berkeley.edU /users/breim an/U singrandom forestsV 3.l.

Breiman L. (2001), “ R andom F orests” , Machine Learning, 45, 5-32.

Breiman L. (1999), “ Using A daptive Bagging to D ebias Regressions” , Technical Report 547, Statistics D epartm ent, University o f California, Berkeley.

Breiman L. (1998), “ Arcing Classifers” , AnnaLs o f Statistics, 26, 801-849. Breiman L. (1996), “ Bagging Predictors” , Machine Learning, 24, 123-140.

D ietterich T., K ong E. (1995), “ M achine Learning Bias, Statistical Bias, and Statistical Variance o f Decision Tree A lgorithm s” , Technical Report, D epartm ent o f C om puter Science, Oregon State University.

Freund Y., Schapire R. E. (1997), “A Decision-Theoretic G eneralization o f O n-Line Learning and an A pplication to Boosting” , Journal o f Computer and System Sciences, 55, 119-139.

(9)

G atn ar E. (2001), Nonparametric M ethod fo r Discrimination and Regression, (in Polish Wydaw­ nictwo N aukow e PW N, Warszawa.

Ho T. K. (1998), ‘T h e R andom Subspace M ethod for C onstructing Decision Forests” , IEEE

Trans, on Pattern Analysis and Machine learning, 20, 832-844.

Q uinlan J. R. (1993), C4.S: Programs fo r Machine Learning, M organ K aufm ann, San M ateo. W olpert D. (1992), “ Stacked G eneralization” , Neural Networks, 5, 241-259.

Eugeniusz Gatnar, Dorota Rozmus

Z A STO SO W A N IE LO SO W EG O DOBORU ZM IEN N Y CH W A GR EG A CJI D RZEW KLASYFIKACYJNYCH

(Streszczenie)

D rzewa klasyfikacyjne, z uwagi na swoją prostotę, elastyczność i skuteczność stają się coraz częściej w ykorzystywaną metodą klasyfikacji. M im o wielu zalet, w adą tej metody jest brak stabilności.

Popraw ę stabilności i dokładności predykcji m ożna osiągnąć poprzez agregację wielu drzew klasyfikacyjnych w jeden model. Proponow ane w literaturze metody agregacji, takie jak: bagging,

adaptive bagging i arcing opierają się na losowaniu obiektów ze zbioru uczącego; natom iast boosting stosuje dodatkow o system wag. W efekcie otrzymujemy zbiór drzew klasyfikacyjnych,

tworzących model zagregowany.

Ponieważ losowanie obiektów może pow odować zmiany rozkładu zmiennych w zbiorze uczącym, dlatego popraw ę dokładności predykcji m ożna uzyskać poprzez losowy dobór zmien­ nych d o p rób uczących, w oparciu o które pow stają modele składowe agregatu.

W niniejszym artykule przedm iotem rozważań jest oszacowanie optym alnej wielkości param etrów dla procedury RandomForest, realizującej losowy dob ó r zmiennych do modelu w postaci zbioru zagregowanych drzew klasyfikacyjnych.

Cytaty

Powiązane dokumenty

Definition of a continuous random variable and a density

The number N(A) of such pairs falling into a Borel set A has the Poisson distribution; if the deterioration jump (increment) occurs at time s with magnitude y when the existing

In this paper we have proposed the Generalized Beta Regression framework for modeling systematic risk in Loss-Given-Default (LGD) in the context of credit portfolio losses. The

Przekłady Literatur Słowiańskich 2/1,

The solution pro- cedure starts with the computed contact area and the corresponding pressures resulting from the normal problem where the same strategies are used to compute the

Prowadzenie dziennika jest ciągłym powracaniem do źródeł tworzenia. W przypadku Nałkowskiej wyraża nieumiejętność bezpośredniego przeżywania, by­ cia

Kluczowymi podstawami tego działania są: zniwelowanie sprzyjających warunków do rozprzestrzeniania się terroryzmu oraz jego zwalczanie, przeznaczenie środków finansowych na

Natomiast w odniesieniu do owych „kształtów zewnętrznych”, czyli tego, co można nazwać formami przypadłościowymi rzeczy, Augustyn pisze tak: „Jeśli, mając na uwadze tylko