000 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047 048 049 050 051 052 053 054

Consistency of Online Random Forests

Abstract

As a testament to their success, the theory of random forests has long been outpaced by their application in practice. In this paper, we take a step towards narrowing this gap by providing a consistency result for online random forests.

present what is to the best of our knowledge the ﬁrst consistency result for online random forests. We show that the theory provides guidance for designing online random forest algorithms. A few simple experiments with our algorithm conﬁrm the requirements for consistency predicted by the theory. The experiments also highlight some theoretical and practical problems that need to be addressed.

1. Introduction

Random forests are a class of ensemble method whose base learners are a collection of randomized tree predictors, which are combined through averaging. The original random forests framework described in Breiman (2001) has been extremely inﬂuential (Svetnik et al., 2003; Prasad et al., 2006; Cutler et al., 2007; Shotton et al., 2011; Criminisi et al., 2011). Despite their extensive use in practical settings, very little is known about the mathematical properties of these algorithms. A recent paper by one of the leading theoretical experts states that Despite growing interest and practical use, there has been little exploration of the statistical properties of random forests, and little is known about the mathematical forces driving the algorithm (Biau, 2012). Theoretical work in this area typically focuses on stylized versions of the random forests algorithms used in practice. For example, Biau et al. (2008) prove the consistency of a variety of ensemble methods built by averaging base classiﬁers. Two of the models they study are direct simpliﬁcations of the forest growing algorithms used in practice; the others are stylized neighbourhood averaging rules, which can be viewed as simpliﬁcations of random forests through the lens of Lin & Jeon (2002). In this paper we make further steps towards narrowing the gap between theory and practice. In particular, we

Preliminary work. Under review by the International Conference on Machine Learning (ICML). Do not distribute.

2. Related Work

Diﬀerent variants of random forests are distinguished by the methods they use for growing the trees. The model described in Breiman (2001) builds each tree on a bootstrapped sample of the training set using the CART methodology (Breiman et al., 1984). The optimization in each leaf that searches for the optimal split point is restricted to a random selection of features, or linear combinations of features. The framework of Criminisi et al. (2011) operates slightly diﬀerently. Instead of choosing only features at random, this framework chooses entire decisions (i.e. both a feature or combination of features and a threshold together) at random and optimizes only over this set. They also oﬀer a variety of diﬀerent objectives which can be optimized to split each leaf, depending on the task at hand (e.g. classiﬁcation vs manifold learning). Unlike the work of Breiman (2001), this framework chooses not to include bagging, preferring instead to train each tree on the entire data set and introduce randomness only in the splitting process. The authors argue that without bagging their model obtains max-margin properties. In addition to the frameworks mentioned above, many practitioners introduce their own variations on the basic random forests algorithm, tailored to their speciﬁc problem domain. A variant from Bosch et al. (2007) is especially similar to the technique we use in this paper: When growing a tree the authors randomly select one third of the training data to determine the structure of the tree and use the remaining two thirds to ﬁt the leaf estimators. However, the authors consider this only as a technique for introducing randomness into the trees, whereas in our model the partitioning

055 056 057 058 059 060 061 062 063 064 065 066 067 068 069 070 071 072 073 074 075 076 077 078 079 080 081 082 083 084 085 086 087 088 089 090 091 092 093 094 095 096 097 098 099 100 101 102 103 104 105 106 107 108 109

Consistency of Online Random Forests

110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164

of data plays a central role in consistency. In addition to these oﬄine methods, several researchers have focused on building online versions of random forests. Online models are attractive because they do not require that the entire training set be accessible at once. These models are appropriate for streaming settings where training data is generated over time and should be incorporated into the model as quickly as possible. Several variants of online decision tree models are present in the MOA system of Bifet et al. (2010). The primary diﬃculty with building online decision trees is their recursive nature. Data encountered once a split has been made cannot be used to correct earlier decisions. A notable approach to this problem is the Hoeﬀding tree (Domingos & Hulten, 2000) algorithm, which works by maintaining several candidate splits in each leaf. The quality of each split is estimated online as data arrive in the leaf, but since the entire training set is not available these quality measures are only estimates. The Hoeﬀding bound is employed in each leaf to control the amount of data which must be collected to ensure that the split chosen on the basis of these estimates is the true best split with high probability. Domingos & Hulten (2000) prove that under reasonable assumptions the online Hoeﬀding tree converges to the oﬄine tree with high probability. The Hoeﬀding tree algorithm is implemented in the system of Bifet et al. (2010). Alternative methods for controlling tree growth in an online setting have also been explored. Saﬀari et al. (2009) use the online bagging technique of Oza & Russel (2001) and control leaf splitting using two parameters, in their online random forest. One parameter speciﬁes the minimum number of data points which must be seen in a leaf before it can be split, and another speciﬁes a minimum quality threshold that the best split in a leaf must reach. This is similar in ﬂavor to the technique used by Hoeﬀding trees, but trades theoretical guarantees for more interpretable parameters. One active avenue of research in online random forests involves tracking non-stationary distributions, also known as concept drift. Many of the online techniques incorporate features designed for this problem (Gama et al., 2005; Abdulsalam, 2008; Saﬀari et al., 2009; Bifet et al., 2009; 2012). However, tracking of nonstationarity is beyond the scope of this paper. The most well known theoretical result for random forests is that of Breiman (2001), which gives an upper bound on the generalization error of the forest in

terms of the correlation and strength of trees. Following Breiman (2001), an interpretation of random forests as an adaptive neighborhood weighting scheme was published in Lin & Jeon (2002). This was followed by the ﬁrst consistency result in this area from Breiman (2004), which proves consistency of a simpliﬁed model of the random forests used in practice. In the context of quantile regression the consistency of a certain model of random forests has been shown by Meinshausen (2006). A model of random forests for survival analysis was shown to be consistent in Ishwaran & Kogalur (2010). Signiﬁcant recent work in this direction comes from Biau et al. (2008) who prove the consistency of a variety of ensemble methods built by averaging base classiﬁers, as is done in random forests. A key feature of the consistency of the tree construction algorithms they present is a proposition that states that if the base classiﬁer is consistent then the forest, which takes a majority vote of these classiﬁers, is itself consistent. The most recent theoretical study, and the one which achieves the closest match between theory and practice, is that of Biau (2012). The most signiﬁcant way in which their model diﬀers from practice is that it requires a second data set which is not used to ﬁt the leaf predictors in order to make decisions about variable importance when growing the trees. One of the innovations of the model we present in this paper is a way to circumvent this limitation in an online setting while maintaining consistency.

3. Random Forests

In this section we brieﬂy review the random forests framework. For a more comprehensive review we refer the reader to Breiman (2001) and Criminisi et al. (2011). Random forests are built by combining the predictions of several trees, each of which is trained in isolation. Unlike in boosting (Schapire & Freund, 2012) where the base classiﬁers are trained and combined using a sophisticated weighting scheme, typically the trees are trained independently and the predictions of the trees are combined through a simple majority vote. There are three main choices to be made when constructing a random tree. These are (1) the method for splitting the leafs, (2) the type of predictor to use in each leaf, and (3) the method for injecting randomness into the trees. Specifying a method for splitting leafs requires selecting the shapes of candidate splits as well as a method

165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219

Consistency of Online Random Forests

220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274

for evaluating the quality of each candidate. Typical choices here are to use axis aligned splits, where data are routed to sub-trees depending on whether or not they exceed a threshold value in a chosen dimension; or linear splits, where a linear combination of features are thresholded to make a decision. The threshold value in either case can be chosen randomly or by optimizing a function of the data in the leafs.

4. Online Random Forests with Stream Partitioning

In this section we describe the workings of our online random forest algorithm. A more precise (pseudocode) description of the training procedure can be found in Appendix A. 4.1. Forest Construction The random forest classiﬁer is constructed by building a collection of random tree classiﬁers in parallel. Each tree is built independently and in isolation from the other trees in the forest. Unlike many other random forest algorithms we do not preform bootstrapping or subsampling at this level; however, the individual trees each have their own optional mechanism for subsampling the data they receive.

Figure 1. Three potential splits for a leaf node and the class histograms for the children each split would create. The rightmost split creates the purest children and will have the greatest information gain.

4.2. Tree Construction Each node of the tree is associated with a rectangular subset of RD , and at each step of the construction the collection of cells associated with the leafs of the tree forms a partition of RD . The root of the tree is RD itself. At each step we receive a data point (Xt , Yt ) from the environment. Each point is assigned to one of two possible streams at random with ﬁxed probability. We denote stream membership with the variable It ∈ {s, e}. How the tree is updated at each time step depends on which stream the corresponding data point is assigned to. We refer to the two streams as the structure stream and the estimation stream; points assigned to these streams are structure and estimation points, respectively. These names reﬂect the diﬀerent uses of the two streams in the construction of the tree: Structure points are allowed to inﬂuence the structure of the tree partition, i.e. the locations of candidate split points and the statistics used to choose between candidates, but they are not permitted to inﬂuence the predictions that are made in each leaf of the tree. Estimation points are not permitted to inﬂuence the shape of the tree partition, but can be used to estimate class membership probabilities in whichever leaf they are assigned to. Only two streams are needed to build a consistent forest, but there is no reason we cannot have more. For instance, we explored the use of a third stream for points that the tree should ignore completely, which gives a form of online sub-sampling in each tree. We found empirically that including this third stream hurts performance of the algorithm, but its presence

In order to split a leaf, a collection of candidate splits are generated and a criterion is evaluated to choose between them. A simple strategy is to choose among the candidates uniformly at random, as in the models analyzed in Biau et al. (2008). A more common approach is to choose the candidate split which optimizes a purity function over the leafs that would be created. Typical choices here are to maximize the information gain, or the Gini gain (Hastie et al., 2013). This situation is illustrated in Figure 1. The most common choice for predictors in each leaf is to use the majority vote over the training points which fall in that leaf. Criminisi et al. (2011) explore the use of several diﬀerent leaf predictors for regression and manifold learning, but these generalizations are beyond the scope of this paper. We consider majority vote classiﬁers in our model. Injecting randomness into the tree construction can happen in many ways. The choice of which dimensions to use as split candidates at each leaf can be randomized, as well as the choice of coeﬃcients for random combinations of features. In either case, thresholds can be chosen either randomly or by optimization over some or all of the data in the leaf. Another common method for introducing randomness is to build each tree using a bootstrapped or subsampled data set. In this way, each tree in the forest is trained on slightly diﬀerent data, which introduces diﬀerences between the trees.

275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329

Consistency of Online Random Forests

330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384

or absence does not aﬀect the theoretical properties. 4.3. Leaf Splitting Mechanism When a leaf is created the number of candidate split dimensions for the new leaf is set to min(1 + Poisson(λ), D), and this many distinct candidate dimensions are selected uniformly at random. We then collect m candidate splits in each candidate dimension (m is a parameter of the algorithm) by projecting the ﬁrst m structure points to arrive in the newly created leaf onto the candidate dimensions. We maintain several structural statistics for each candidate split. Speciﬁcally, for each candidate split we maintain class histograms for each of the new leafs it would create, using data from the estimation stream. We also maintain structural statistics, computed from data in the structure stream, which can be used to choose between the candidate splits. The speciﬁc form of the structural statistics does not aﬀect the consistency of our model, but it is crucial that they depend only on data in the structure stream. Finally, we require two additional conditions which control when a leaf at depth d is split: 1. Before a candidate split can be chosen, the class histograms in each of the leafs it would create must incorporate information from at least α(d) estimation points. 2. If any leaf receives more than β (d) estimation points, and the previous condition is satisﬁed for any candidate split in that leaf, then when the next structure point arrives in this leaf it must be split regardless of the state of the structural statistics. The ﬁrst condition ensures that leafs are not split too often, and the second condition ensures that no branch of the tree ever stops growing completely. In order to ensure consistency we require that α(d) → ∞ monotonically in d. We also require that β (d) ≥ α(d) for convenience. When a structure point arrives in a leaf, if the ﬁrst condition is satisﬁed for some candidate split then the leaf may optionally be split at the corresponding point. The decision of whether to split the leaf or wait to collect more data is made on the basis of the structural statistics collected for the candidate splits in that leaf. 4.4. Structural Statistics In each candidate child we maintain an estimate of the posterior probability of each class, as well as the total

number of points we have seen fall in the candidate child, both counted from the structure stream. In order to decide if a leaf should be split, we compute the information gain for each candidate split which satisﬁes condition 1 from the previous section, I (S ) = H (A) − |A | |A | H (A ) − H (A ) . |A| |A|

Here S is the candidate split, A is the cell belonging to the leaf to be split, and A and A are the two leafs that would be created if A were split at S . The function H (A) is the discrete entropy, computed over the labels of the structure points which fall in the cell A. We select the candidate split with the largest information gain for splitting, provided this split achieves a minimum threshold in information gain, τ . The value of τ is a parameter of our algorithm. 4.5. Prediction At any time the online forest can be used to make predictions for unlabelled data points using the model built from the labelled data it has seen so far. To make a prediction for a query point x at time t, each tree computes, for each class k ,

k ηt (x) =

1 N e (A

t (x)) (Xτ ,Yτ )∈At (x) Iτ =e

I {Yτ = k } ,

where At (x) denotes the leaf of the tree containing x at time t, and N e (At (x)) is the number of estimation points which have been counted in At (x) during its lifetime. Similarly, the sum is over the labels of these points. The tree prediction is then the class which maximizes this value:

k gt (x) = arg max{ηt (x)} . k

The forest predicts the class which receives the most votes from the individual trees. Note that this requires that we maintain class histograms from both the structure and estimation streams separately for each candidate child in the fringe of the tree. The counts from the structure stream are used to select between candidate split points, and the counts from the estimation stream are used to initialize the parameters in the newly created leafs after a split is made. 4.6. Memory Management The typical approach to building trees online, which is employed in Domingos & Hulten (2000) and Saffari et al. (2009), is to maintain a fringe of candidate

385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439

Consistency of Online Random Forests

440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494

children in each leaf of the tree. The algorithm collects statistics in each of these candidate children until some (algorithm dependent) criterion is met, at which point a pair of candidate children is selected to replace their parent. The selected children become leafs in the new tree, acquiring their own candidate children, and the process repeats. Our algorithm also uses this approach. The diﬃculty here is that the trees must be grown breadth ﬁrst, and maintaining the fringe of potential children is very memory intensive when the trees are large. Our algorithm also suﬀers from this deﬁciency, as maintaining the fringe requires O(cmd) statistics in each leaf, where d is the number of candidate split dimensions, m is the number of candidate split points (i.e. md pairs of candidate children per leaf) and c is the number of classes in the problem. The number of leafs grows exponentially fast with tree depth, meaning that for deep trees this memory cost becomes prohibitive. Oﬄine forests do not suﬀer from this problem, because they are able to grow the trees depth ﬁrst. Since they do not need to accumulate statistics for more than one leaf at a time, the cost of computing even several megabytes of statistics per split is negligible. Although the size of the trees still grows exponentially with depth, this memory cost is dwarfed by the savings from not needing to store split statistics for all the leafs. In practice the memory problem is resolved either by growing small trees, as in Saﬀari et al. (2009), or by bounding the number of nodes in the fringe of the tree, as in Domingos & Hulten (2000). Other models of streaming random forests, such as those discussed in Abdulsalam (2008), build trees in sequence instead of in parallel, which reduces the total memory usage. Our algorithm makes use of a bounded fringe and adopts the technique of Domingos & Hulten (2000) to control the policy for adding and removing leafs from the fringe. In each tree we partition the leafs into two sets: we have a set of active leafs, for which we collect split statistics as described in earlier sections, and a set of inactive leafs for which we store only two numbers. We call the set of active leafs the fringe of the tree, and describe a policy for controlling how inactive leafs are added to the fringe. In each inactive leaf At we store the following two quantities • p ˆ(At ) which is an estimate of µ(At ) = P (X ∈ At ),

and • e ˆ(At ) which is an estimate P (gt (X ) = Y | X ∈ At ). of e(A) =

Both of these are estimated based on the estimation points which arrive in At during its lifetime. From these two numbers we form the statistic s ˆ(A) = p ˆ(A)ˆ e(A) (with corresponding true value s(A) = p(A)e(A)) which is an upper bound on the improvement in error rate that can be obtained by splitting A. Membership in the fringe is controlled by s ˆ(A). When a leaf is split it relinquishes its place in the fringe and the inactive leaf with the largest value of s ˆ(A) is chosen to take its place. The newly created leafs from the split are initially inactive and must compete with the other inactive leafs for entry into the fringe. Unlike Domingos & Hulten (2000), who use this technique only as a heuristic for managing memory use, we incorporate the memory management directly into our analysis. The analysis in Appendix B shows that our algorithm, including a limited size fringe, is consistent.

5. Theory

In this section we state our main theoretical results and give an outline of the strategy for establishing consistency of our online random forest algorithm. In the interest of space and clarity we do not include proofs in this section. Unless otherwise noted, the proofs of all claims appear in Appendix B. We denote the tree partition created by our online random forest algorithm from t data points as gt . As t varies we obtain a sequence of classiﬁers, and we are interested in showing that the sequence {gt } is consistent, or more precisely that the probability of error of gt converges in probability to the Bayes risk, i.e. L(gt ) = P (gt (X, Z ) = Y | Dt ) → L∗ , as t → ∞. Here (X, Y ) is a random test point and Z denotes the randomness in the tree construction algorithm. Dt is the training set (of size t) and the probability in the convergence is over the random selection of Dt . The Bayes risk is the probability of error of the Bayes classiﬁer, which is the classiﬁer that makes predictions by choosing the class with the highest posterior probability, g (x) = arg max P (Y = k | X = x) ,

k

(where ties are broken in favour of the smaller index). The Bayes risk L(g ) = L∗ is the minimum achievable

495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549

Consistency of Online Random Forests

550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604

risk of any classiﬁer for the distribution of (X, Y ). In order to ease notation, we drop the explicit dependence on Dt in the remainder of this paper. More information about this setting can be found in Devroye et al. (1996). Our main result is the following theorem: Theorem 1. Suppose the distribution of X has a density with respect to the Lebesgue measure and that this density is bounded from above and below. Then the online random forest classiﬁer described in this paper is consistent. The ﬁrst step in proving Theorem 1 is to show that the consistency of a voting classiﬁer, such as a random forest, follows from the consistency of the base classiﬁers. We prove the following proposition, which is a straightforward generalization of a proposition from Biau et al. (2008), who prove the same result for two class ensembles. Proposition 2. Assume that the sequence {gt } of randomized classiﬁers is consistent for a certain distribu(M ) tion of (X, Y ). Then the voting classiﬁer, gt obtained by taking the majority vote over M (not necessarily independent) copies of gt is also consistent. With Proposition 2 established, the remainder of the eﬀort goes into proving the consistency of our tree construction. The ﬁrst step is to separate the stream splitting randomness from the remaining randomness in the tree construction. We show that if a classiﬁer is conditionally consistent based on the outcome of some random variable, and the sampling process for this random variable generates acceptable values with probability 1, then the resulting classiﬁer is unconditionally consistent. Proposition 3. Suppose {gt } is a sequence of classiﬁers whose probability of error converges conditionally in probability to the Bayes risk L∗ for a speciﬁed distribution on (X, Y ), i.e. P (gt (X, Z, I ) = Y | I ) → L∗ for all I ∈ I and that ν is a distribution on I . If ν (I ) = 1 then the probability of error converges unconditionally in probability, i.e. P (gt (X, Z, I ) = Y ) → L∗ In particular, {gt } is consistent for the speciﬁed distribution. Proposition 3 allows us to condition on the random variables {It }∞ t=1 which partition the data stream into

structure and estimation points in each tree. Provided that the random partitioning process produces acceptable sequences with probability 1, it is suﬃcient to show that the random tree classiﬁer is consistent conditioned on such a sequence. In particular, in the remainder of the argument we assume that {It }∞ t=1 is a ﬁxed, deterministic sequence which assigns inﬁnitely many points to each of the structure and estimation streams. We refer to such a sequence as a partitioning sequence. S I E

Figure 2. The dependency structure of our algorithm. S represents the randomness in the structure of the tree partition, E represents the randomness in the leaf estimators and I represents the randomness in the partitioning of the data stream. E and S are independent conditioned on I .

The reason this is useful is that conditioning on a partitioning sequence breaks the dependence between the structure of the tree partition and the estimators in the leafs. This is a powerful tool because it gives us access to a class of consistency theorems which rely on this type of independence. However, before we are able to apply these theorems we must further reduce our problem to proving the consistency of estimators of the posterior distribution of each class. Proposition 4. Suppose we have regression estik mates, ηt (x), for each class posterior η k (x) = P (Y = k | X = x), and that these estimates are each consistent. The classiﬁer

k gt (x) = arg max{ηt (x)} k

(where ties are broken in favour of the smaller index) is consistent for the corresponding multiclass classiﬁcation problem. Proposition 4 allows us to reduce the consistency of the multiclass classiﬁer to the problem of proving the consistency of several two class posterior estimates. Given a set of classes {1, . . . , c} we can re-assign the labels using the map (X, Y ) → (X, I {Y = k }) for any k ∈ {1, . . . , c} in order to get a two class problem where P (Y = 1 | X = x) in this new problem is equal to η k (x) in the original multiclass problem. Thus to prove consistency of the multiclass classiﬁer it is enough to show that each of these two class posteriors is consistent. To this end we make use of the following theorem from Devroye et al. (1996). Theorem 5. Consider a partitioning classiﬁcation rule which builds a prediction ηt (x) of η (x) = P (Y = 1 | X = x) by averaging the labels in each cell

605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659

Consistency of Online Random Forests

660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714

of the partition. If the labels of the voting points do not inﬂuence the structure of the partition then E [|ηt (x) − η (x)|] → 0 provided that 1. diam(At (X )) → 0 in probability, 2. N e (At (X )) → ∞ in probability.

6. Experiments

In this section we demonstrate some empirical results on simple problems in order to illustrate the properties of our algorithm. We also provide a comparison to an existing online random forest algorithm. Following the review process we plan to release code to reproduce all of the experiments in this section.

0.70

Forest and tree accuracy

Proof. See Theorem 6.1 in Devroye et al. (1996). Here At (X ) refers to the cell of the tree partition containing a random test point X , and diam(A) indicates the diameter of set A. The diameter is deﬁned as the maximum distance between any two points falling in A, diam(A) = sup ||x − y || .

x,y ∈A

0.65 0.60

0.55 0.50 0.45 0.40 0.35 2 10 103

Trees Forest Bayes Data Size

104

The quantity N e (At (X )) is the number of points contributing to the estimation of the posterior at X . This theorem places two requirements on the cells of the partition. The ﬁrst condition ensures that the cells are suﬃciently small that small details of the posterior distribution can be represented. The second condition requires that the cells be large enough that we are able to obtain high quality estimates of the posterior probability in each cell. The leaf splitting mechanism described in Section 4.3 ensures that the second condition of Theorem 5 is satisﬁed. However, showing that our algorithm satisﬁes the ﬁrst condition requires signiﬁcantly more work. The chief diﬃculty lies in showing that every leaf of the tree will be split inﬁnitely often in probability. Once this claim is established a relatively straightforward calculation shows that the expected size of each dimension of a leaf is reduced each time it is split. So far we have described the approach to proving consistency of our algorithm with an unbounded fringe. If the tree is small (i.e. never has more leafs than the maximum fringe size) then the analysis is unchanged. However, since our trees are required to grow to unbounded size this is not possible. To handle this case we derive an upper bound on the time required for an inactive leaf to enter the fringe. Once the leaf it remains there until it is split and the analysis from the unbounded fringe case applies. These details are somewhat technical, so we refer the interested reader to Appendix B for more information, as well as the proofs of the propositions stated in this section.

Figure 3. Prediction accuracy of the forest and the trees it averages on a simple mixture of Gaussians problem. The horizontal line shows the accuracy of the Bayes classiﬁer on this problem. We see that the accuracy of the forest consistently dominates the expected accuracy of the trees. The forest in this example contains 100 trees. Error regions show one standard deviation computed over 10 runs.

6.1. Advantage of a Forest Our ﬁrst experiment demonstrates that although the individual trees are consistent classiﬁers, empirically the performance of the forest is signiﬁcantly better than each of the trees for problems with ﬁnite data. We demonstrate this on a synthetic ﬁve class mixture of Gaussians problem with signiﬁcant class overlap and variation in prior weights. From Figure 3 it is clear that the forest converges much more quickly than the individual trees. Result proﬁles of this kind are common in the boosting and random forests literature; however, in practice one often uses inconsistent base classiﬁers in the ensemble (e.g. boosting with decision stumps or random forests where the trees are grown to full size). This experiment demonstrates that although our base classiﬁers provably converge, empirically there is still a beneﬁt from averaging in ﬁnite time. 6.2. Growing leaves Our next experiment demonstrates the importance of the condition that α(d) → ∞, i.e. having the num-

715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769

Accuracy

Consistency of Online Random Forests

770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824

Gap to Bayes Error

α (d ) = 1 α (d ) = 2 d Excess Error

1.0 0.9

USPS

Accuracy

0.8 0.7 0.6 0.5

Bayes

103

Data Size

104

105

106

0.4

Offline Online Saffari et al. (2009)

102

Data Size

103

Figure 4. Excess error above the Bayes risk for a simple synthetic problem. The solid line shows the excess error for a forest where each tree is built to full depth. The dashed line shows a forest where each tree requires 2d examples in a leaf at level d in order to split. Both forests contain 100 trees.

Figure 5. Comparison between oﬄine random forests and our online algorithm on the USPS data set. The online forest uses 10 passes through the data set. The third line is our implementation of the algorithm from Saﬀari et al. (2009); the performance shown here is identical to what they report. Error regions show one standard deviation computed over 10 runs.

6.3. Comparison to Oﬄine ber of data points in each leaf grow over time. We demonstrate this using a synthetic two class distribution speciﬁcally designed to exhibit problems when α(d) does not grow. In the distribution we construct, P (X = x) is uniform on the unit square in R2 , and the posterior P (Y = 1 | X = x) = 0.5001 for all x. Figure 4 shows the excess error of two forests trained on several data sets of diﬀerent sizes sampled from this distribution. In one of the forests the trees are grown to full depth, while in the other we force the size of the leafs to increase with their depth in the tree. As can be seen in Figure 4, building trees to full depth prevents the forest from making progress towards the Bayes error over a huge range of data set sizes, whereas the forest composed of trees with growing leafs steadily decreases its excess error. Admittedly, this scenario is quite artiﬁcial, and it can be diﬃcult to ﬁnd real problems where the diﬀerence is so pronounced. It is still an open question as to whether a forest can be made consistent by averaging over an inﬁnite number of trees of full depth (although see Breiman (2004) and Biau (2012) for results in this direction). The purpose of this example is to show that in the common scenario where the number of trees is a ﬁxed parameter of the algorithm, having leafs that grow over time is important. In our third experiment, we demonstrate that our online algorithm is able to achieve similar performance to an oﬄine implementation of random forests and also compare to an existing online random forests algorithm on a small non-synthetic problem. In particular, we demonstrate this on the USPS data set from the LibSVM repository (Chang & Lin, 2011). We have chosen the USPS data for this experiment because it allows us to compare our results directly to those of Saﬀari et al. (2009), whose algorithm is very similar to our own. In the interest of comparability we also use a forest of 100 trees and set the minimum information gain threshold (τ in our model) to 0.1. We show results from both online algorithms with 10 passes through the data. Figure 5 shows that we are able to achieve performance very similar to the oﬄine random forest on the full data. The performance we achieve is identical to the performance reported by Saﬀari et al. (2009) on this data set. 6.4. Kinect application For our ﬁnal experiment we evaluate our online random forest algorithm on the challenging computer vision problem of predicting human body part labels from a depth image. Our procedure closely follows the work of Shotton et al. (2011) which is used in the commercially successful Kinect system. Applying the

825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879

Consistency of Online Random Forests

880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934

0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0.0 2 10 103

Kinect

α(d) =10 ·(1.01d )

Saffari et al. (2009) Data Size

104 105 106

Figure 6. Left: Depth, ground truth body parts and predicted body parts. Right: A candidate feature speciﬁed by two oﬀsets.

Figure 7. Comparison of our online algorithm with Saﬀari et al. (2009) on the kinect application; Our algorithm does signiﬁcantly better with less memory.

same approach as Shotton et al. (2011), our online classiﬁer predicts the body part label of a single pixel P in a depth image. To predict all the labels of a depth image, the classiﬁer is applied to every pixel in parrallel. For our dataset, we generate pairs of 640x480 resolution depth and body part images by rendering random poses from the CMU mocap dataset. The 19 body parts and one background class are represented by 20 unique color identiﬁers in the body part image. Figure 6 (left) visualizes the raw depth image, ground truth body part labels and body parts predicted by our classiﬁer for one pose. During training, we sample 50 pixels without replacement for each body part class from each pose; thus, producing 1000 data points for each depth image. During testing we evaluate the prediction accuracy of all non background pixels as this provides a more informative accuracy metric since most of the pixels are background and are relatively easy to predict. For this experiment we use a stream of 1000 poses for training and 500 poses for testing. Each node of each decision tree computes the depth diﬀerence between two pixels described by two oﬀsets from P (the pixel being classiﬁed). At training time, candidate pairs of oﬀsets are sampled from a 2dimensional Gaussian distributions with variance 75.0. The oﬀsets are scaled by the depth of the pixel P to produce depth invariant features. Figure 6 (right) visualizes a candidate feature for the pixel in the green box. The resulting feature value is the depth diﬀerence between the pixel in the red box and the pixel in the white box. In this experiment we construct a forest of 25 trees with 2000 candidate oﬀsets (λ), 10 candidate splits

(m) and a minimum information gain of 0.01 (τ ). For Saﬀari et al. (2009) we set the number of sample points required to split to 10 and for our own algorithm we set α(d) = 10 · (1.01d ) and β (d) = 4 · α(d). With this parameter setting each active leaf stores 20 · 10 · 2000 · 2 = 400, 000 statistics which requires 1.6MB of memory. By limiting the fringe to 1000 active leaves our algorithm requires 1.6GB of memory for leaf statistics. To limit the maximum memory used by Saﬀari et al. (2009) we set the maximum depth to 8 which uses up to 25 · 28 = 6400 active leaves which requires up to 10GB of memory for leaf statistics. Figure 7 shows that our algorithm achieves signiﬁcantly better accuracy while requiring less memory. However, our algorithm does not do as well when seeing a small number of data points. This is likely a result of separating data points into structure and estimation streams and not including all leaves in the active set.

7. Discussion and Future Work

In this paper we described an algorithm for building online random forests and showed that our algorithm is consistent. To the best of our knowledge this is the ﬁrst consistency result for online random forests. The theory guides certain choices made when designing our algorithm, notably that it is necessary for the leafs in each tree to increase in size over time. Our experiments on simple problems conﬁrm that this requirement is important. Growing trees online in the obvious way requires large amounts of memory, since the trees must be grown breadth ﬁrst and each leaf must store are large num-

935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989

Accuracy

Consistency of Online Random Forests

990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044

ber of statistics related to its potential children. We incorporated a memory management technique from Domingos & Hulten (2000) in order to limit the number of leafs in the fringe of the tree. This reﬁnement is important, since it enables our algorithm to grow large trees. The analysis shows that our algorithm is still consistent with this reﬁnement. Finally, our current algorithm is restricted to axis aligned splits. Many implementations of random forests use more elaborate split shapes, such as random linear or quadratic combinations of features. These strategies can be highly eﬀective in practice, especially in sparse or high dimensional settings. Understanding how to maintain consistency in these settings is another potentially interesting direction of inquiry.

1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099

Consistency of Online Random Forests

1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154

References

H. Abdulsalam. Streaming Random Forests. PhD thesis, Queens University, 2008. G. Biau. Analysis of a Random Forests model. JMLR, 13 (April):1063–1095, 2012. G. Biau, L. Devroye, and G. Lugosi. Consistency of random forests and other averaging classiﬁers. JMLR, 9:2015– 2033, 2008. A. Bifet, G. Holmes, and B. Pfahringer. MOA: Massive Online Analysis, a framework for stream classiﬁcation and clustering. In Workshop on Applications of Pattern Analysis, pp. 3–16, 2010. A. Bifet, E. Frank, G. Holmes, and B. Pfahringer. Ensembles of Restricted Hoeﬀding Trees. ACM Transactions on Intelligent Systems and Technology, 3(2):1–20, February 2012. A. Bifet, G. Holmes, and B. Pfahringer. New ensemble methods for evolving data streams. In ACM SIGKDD Intl. Conference on Knowledge Discovery and Data Mining, 2009. A. Bosch, A. Zisserman, and X. Munoz. Image classiﬁcation using random forests and ferns. In International Conference on Computer Vision, pp. 1–8, 2007. L. Breiman. Random forests. Machine Learning, 45(1): 5–32, 2001. L. Breiman. Consistency for a Simple Model of Random Forests. Technical report, University of California at Berkeley, 2004. L. Breiman, J. Friedman, C. Stone, and R. Olshen. Classiﬁcation and Regression Trees. CRC Press LLC, Boca Raton, Florida, 1984. C. Chang and C. Lin. LIBSVM: A library for support vector machines. ACM Transactions on Intelligent Systems and Technology, 2:27:1–27:27, 2011. G. Cormode. Sketch techniques for approximate query processing. Synposes for Approximate Query Processing: Samples, Histograms, Wavelets and Sketches, Foundations and Trends in Databases, 2011. G. Cormode and S. Muthukrishnan. An improved data stream summary: the count-min sketch and its applications. Journal of Algorithms, 55(1):58–75, April 2005. A. Criminisi, J. Shotton, and E. Konukoglu. Decision forests: A uniﬁed framework for classiﬁcation, regression, density estimation, manifold learning and semisupervised learning. Foundations and Trends in Computer Graphics and Vision, 7(2-3):81–227, 2011. D. Cutler, T. Edwards, and K. Beard. Random forests for classiﬁcation in ecology. Ecology, 88(11):2783–92, November 2007. L. Devroye, L. Gy¨ orﬁ, and G. Lugosi. A Probabilistic Theory of Pattern Recognition. Springer-Verlag, New York,

USA, 1996. P. Domingos and G. Hulten. Mining high-speed data streams. In International Conference on Knowledge Discovery and Data Mining, pp. 71–80. ACM, 2000. J. Gama, P. Medas, and P. Rodrigues. Learning decision trees from dynamic data streams. In ACM symposium on Applied computing, SAC ’05, pp. 573–577, New York, NY, USA, 2005. ACM. T. Hastie, R. Tibshirani, and J. Friedman. The Elements of Statistical Learning. Springer, 10 edition, 2013. H. Ishwaran and U. Kogalur. Consistency of random survival forests. Statistics and Probability Letters, 80:1056– 1064, 2010. Y. Lin and Y. Jeon. Random forests and adaptive nearest neighbors. Technical Report 1055, University of Wisconsin, 2002. N. Meinshausen. Quantile regression forests. JMLR, 7: 983–999, 2006. N. Oza and S. Russel. Online Bagging and Boosting. In Artiﬁcial Intelligence and Statistics, volume 3, 2001. A. Prasad, L. Iverson, and A. Liaw. Newer Classiﬁcation and Regression Tree Techniques: Bagging and Random Forests for Ecological Prediction. Ecosystems, 9(2):181– 199, March 2006. ISSN 1432-9840. A. Saﬀari, C. Leistner, J. Santner, M. Godec, and H. Bischof. On-line random forests. In International Conference on Computer Vision Workshops (ICCV Workshops), pp. 1393–1400. IEEE, 2009. R. Schapire and Y. Freund. Boosting: Foundations and Algorithms. MIT Press, Cambridge, Massachusetts, 2012. J. Shotton, A. Fitzgibbon, M. Cook, T. Sharp, M. Finocchio, R. Moore, A. Kipman, and A. Blake. Real-time human pose recognition in parts from single depth images. CVPR, pp. 1297–1304, 2011. V. Svetnik, A. Liaw, C. Tong, J. Culberson, R. Sheridan, and B. Feuston. Random forest: a classiﬁcation and regression tool for compound classiﬁcation and QSAR modeling. Journal of Chemical Information and Computer Sciences, 43(6):1947–58, 2003.

1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209

Consistency of Online Random Forests

1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264

A. Algorithm pseudo-code

Candidate split dimension A dimension along which a split may be made. Poisson(λ), D) of these when it is created. Candidate split point One of the ﬁrst m structure points to arrive in a leaf. Candidate split A combination of a candidate split dimension and a position along that dimension to split. These are formed by projecting each candidate split point into each candidate split dimension. Candidate children Each candidate split in a leaf induces two candidate children for that leaf. These are also referred to as the left and right child of that split. N e (A) is a count of estimation points in the cell A, and Y e (A) is the histogram of labels of these points in A. N s (A) is a count of structure point in the cell A, and Y s (A) is the histogram of labels of these points in A. Algorithm 1 BuildTree Require: Initially the tree has exactly one leaf (TreeRoot) which covers the whole space Require: The dimensionality of the input, D. Parameters λ, m and τ . SelectCandidateSplitDimensions(TreeRoot, min(1 + Poisson(λ), D)) for t = 1 . . . do Receive (Xt , Yt , It ) from the environment At ← leaf containing Xt if It = estimation then UpdateEstimationStatistics(At , (Xt , Yt )) for all S ∈ CandidateSplits(At ) do for all A ∈ CandidateChildren(S ) do if Xt ∈ A then UpdateEstimationStatistics(A, (Xt , Yt )) end if end for end for else if It = structure then if At has fewer than m candidate split points then for all d ∈ CandidateSplitDimensions(At ) do CreateCandidateSplit(At , d, πd Xt ) end for end if for all S ∈ CandidateSplits(At ) do for all A ∈ CandidateChildren(S ) do if Xt ∈ A then UpdateStructuralStatistics(A, (Xt , Yt )) end if end for end for if CanSplit(At ) then if ShouldSplit(At ) then Split(At ) else if MustSplit(At ) then Split(At ) end if end if end if end for Each leaf selects min(1 +

1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319

Consistency of Online Random Forests

1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374

Algorithm 2 Split Require: A leaf A S ← BestSplit(A) A ← LeftChild(A) SelectCandidateSplitDimensions(A , Poisson(λ), D)) A ← RightChild(A) SelectCandidateSplitDimensions(A , Poisson(λ), D)) return A , A Algorithm 3 CanSplit Require: A leaf A d ← Depth(A) for all S ∈ CandidateSplits(A) do if SplitIsValid(A, S ) then return true end if end for return false

min(1

+

Algorithm 5 MustSplit Require: A leaf A d ← Depth(A) return N e (A) ≥ β (d) Algorithm 6 ShouldSplit Require: A leaf A for all S ∈ CandidateSplits(A) do if InformationGain(S ) > τ then if SplitIsValid(A, S ) then return true end if end if end for return false Algorithm 7 BestSplit Require: A leaf A Require: At least one valid candidate split exists for A best split ← none for all S ∈ CandidateSplits(A) do if InformationGain(A, S ) > InformationGain(A, best split) then if SplitIsValid(A, S ) then best split ← S end if end if end for return best split Algorithm 8 InformationGain Require: A leaf A Require: A split S A ← LeftChild(S ) A ← RightChild(S ) s (A ) s return Entropy(Y s (A))− N N s (A) Entropy(Y (A ))−

N s (A ) N s (A)

min(1

+

Algorithm 4 SplitIsValid Require: A leaf A Require: A split S d ← Depth(A) A ← LeftChild(S ) A ← RightChild(S ) return N e (A ) ≥ α(d) and N e (A ) ≥ α(d)

Entropy(Y s (A ))

Algorithm 9 UpdateEstimationStatistics Require: A leaf A Require: A point (X, Y ) N e (A) ← N e (A) + 1 Y e (A) ← Y e (A) + Y Algorithm 10 UpdateStructuralStatistics Require: A leaf A Require: A point (X, Y ) N s ( A) ← N s ( A) + 1 Y s ( A) ← Y s ( A) + Y

1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429

Consistency of Online Random Forests

1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484

B. Proof of Consistency

B.1. A note on notation A will be reserved for subsets of RD , and unless otherwise indicated it can be assumed that A denotes a cell of the tree partition. We will often be interested in the cell of the tree partition containing a particular point, which we denote A(x). Since the partition changes over time, and therefore the shape of A(x) changes as well, we use a subscript to disambiguate: At (x) is the cell of the partition containing x at time t. Cells in the tree partition have a lifetime which begins when they are created as a candidate child to an existing leaf and ends when they are themselves split into two children. When referring to a point Xτ ∈ At (x) it is understood that τ is restricted to the lifetime of At (x). We treat cells of the tree partition and leafs of the tree deﬁning it interchangeably, denoting both with an appropriately decorated A. N generally refers to the number of points of some type in some interval of time. The various decorations the N receives specify which particular type of point or interval of time is being considered. A superscript always denotes type, so N k refers to a count of points of type k . Two special types, e and s, are used to denote k estimation and structure points, respectively. Pairs of subscripts are used to denote time intervals, so Na,b denotes the number of points of type k which appear during the time interval [a, b]. We also use N as a function e whose argument is a subset of RD in order to restrict the counting spatially: Na,b (A) refers to the number of estimation points which fall in the set A during the time interval [a, b]. We make use of one additional variant of N as a function when its argument is a cell in the partition: when we write N k (At (x)), without subscripts on N , the interval of time we count over is understood to be the lifetime of the cell At (x). B.2. Preliminaries Lemma 6. Suppose we partition a stream of data into c parts by assigning each point (Xt , Yt ) to part It ∈ {1, . . . , c} with ﬁxed probability pk , meaning that

b k Na,b = t=a k Then with probability 1, Na,b → ∞ for all k ∈ {1, . . . , c} as b − a → ∞.

I {It = k } .

(1)

Proof. Note that P (It = 1) = p1 and these events are independent for each t. By the second Borel-Cantelli lemma, the probability that the events in this sequence occur inﬁnitely often is 1. The cases for It ∈ {2, . . . , c} are similar. Lemma 7. Let Xt be a sequence of iid random variables with distribution µ, let A be a ﬁxed set such that µ(A) > 0 and let {It } be a ﬁxed partitioning sequence. Then the random variable

k Na,b ( A) = a≤t≤b:It =k k is Binomial with parameters Na,b and µ(A). In particular, k P Na,b (A) ≤

I {Xt ∈ A}

µ(A) k Na,b 2

≤ exp −

µ(A)2 k Na,b 2

k which goes to 0 as b − a → ∞, where Na,b is the deterministic quantity deﬁned as in Equation 1. k Proof. Na,b (A) is a sum of iid indicator random variables so it is Binomial. It has the speciﬁed parameters k k k because it is a sum over Na,b elements and P (Xt ∈ A) = µ(A). Moreover, E Na,b (A) = µ(A)Na,b so by Hoeﬀding’s inequality we have that k k k k k k P Na,b (A) ≤ E Na,b (A) − Na,b = P Na,b (A) ≤ Na,b (µ(A) − ) ≤ exp −2 2 Na,b

.

Setting

=

1 2 µ(A)

gives the desired result.

1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539

Consistency of Online Random Forests

1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594

B.3. Proof of Proposition 2 Proof. Let g (x) denote the Bayes classiﬁer. Consistency of {gt } is equivalent to saying that E [L(gt )] = P (gt (X, Z ) = Y ) → L∗ . In fact, since P (gt (X, Z ) = Y | X = x) ≥ P (g (X ) = Y | X = x) for all x ∈ RD , consistency of {gt } means that for µ-almost all x, P (gt (X, Z ) = Y | X = x) → P (g (X ) = Y | X = x) = 1 − max{η k (x)}

k

Deﬁne the following two sets of indices G = {k | η k (x) = max{η k (x)}} ,

k

B = {k | η k (x) < max{η k (x)}} .

k

Then P (gt (X, Z ) = Y | X = x) =

k

P (gt (X, Z ) = k | X = x) P (Y = k |X = x) P (gt (X, Z ) = k | X = x) +

k ∈G (M ) k ∈B

≤ (1 − max{η k (x)})

k

P (gt (X, Z ) = k | X = x) ,

which means it suﬃces to show that P gt

(X, Z M ) = k | X = x → 0 for all k ∈ B . However, using Z M to

denote M (possibly dependent) copies of Z , for all k ∈ B ,

M

M c=k

I {gt (x, Zj ) = c}

P gt

(M )

(x, Z M ) = k = P

j =1

I {gt (x, Zj ) = k } > max

j =1 M

≤ P

I {gt (x, Zj ) = k } ≥ 1

j =1

By Markov’s inequality, ≤ E

j =1 M

I {gt (x, Zj ) = k }

= M P (gt (x, Z ) = k ) → 0

B.4. Proof of Proposition 3 Proof. The sequence in question is uniformly integrable, so it is suﬃcient to show that E [P (gt (X, Z, I ) = Y | I )] → L∗ implies the result, where the expectation is taken over the random selection of training set. We can write P (gt (X, Z, I ) = Y ) = E [P (gt (X, Z, I ) = Y | I )] =

I

P (gt (X, Z, I ) = Y | I ) ν (I ) +

Ic

P (gt (X, Z, I ) = Y | I ) ν (I )

By assumption ν (I c ) = 0, so we have lim P (gt (X, Z, I ) = Y ) = lim P (gt (X, Z, I ) = Y | I ) ν (I )

I

t→∞

t→∞

1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649

Consistency of Online Random Forests

1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704

Since probabilities are bounded in the interval [0, 1], the dominated convergence theorem allows us to exchange the integral and the limit, = lim P (gt (X, Z, I ) = Y | I ) ν (I )

I t→∞

and by assumption the conditional risk converges to the Bayes risk for all I ∈ I , so = L∗

I

ν (I )

= L∗ which proves the claim. B.5. Proof of Proposition 4 Proof. By deﬁnition, the rule g (x) = arg max{η k (x)}

k

(where ties are broken in favour of smaller k ) achieves the Bayes risk. In the case where all the η k (x) are equal there is nothing to prove, since all choices have the same probability of error. Therefore, suppose there is at least one k such that η k (x) < η g(x) (x) and deﬁne m(x) = η g(x) (x) − max{η k (x) | η k (x) < η g(x) (x)}

k k

m t ( x) = η t

g ( x)

k (x) − max{ηt (x) | η k (x) < η g(x) (x)}

The function m(x) ≥ 0 is the margin function which measures how much better the best choice is than the second best choice, ignoring possible ties for best. The function mt (x) measures the margin of gt (x). If mt (x) > 0 then gt (x) has the same probability of error as the Bayes classiﬁer. The assumption above guarantees that there is some classes, by making t large we can satisfy such that m(x) > . Using C to denote the number of

k P |ηt (X ) − η k (X )| < /2 ≥ 1 − δ/C k since ηt is consistent. Thus C C k |ηt (X ) − η k (X )| < /2 k=1

P

≥1−K +

k=1

k P |ηt (X ) − η k (X )| < /2 ≥ 1 − δ

So with probability at least 1 − δ we have mt (X ) = ηt

g (X ) k − max{ηt (X ) | η k (X ) < η g(X ) (X )} k k − /2) − max{ηt (X ) + /2 | η k (X ) < η g(x) (X )} k

≥ (η

g (X )

= η g(X ) − max{η k (X ) | η k (X ) < η g(X ) (X )} −

k

= m(X ) − >0 Since δ is arbitrary this means that the risk of gt converges in probability to the Bayes risk.

1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759

Consistency of Online Random Forests

1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814

d

A A

A A

A A

Figure 8. This Figure shows the setting of Proposition 8. Conditioned on a partially built tree we select an arbitrary leaf at depth d and an arbitrary candidate split in that leaf. The proposition shows that, assuming no other split for A is selected, we can guarantee that the chosen candidate split will occur in bounded time with arbitrarily high probability.

B.6. Proof of Theorem 1 The proof of Theorem 1 is built in several pieces. Proposition 8. Fix a partitioning sequence. Let t0 be a time at which a split occurs in a tree built using this sequence, and let gt0 denote the tree after this split has been made. If A is one of the newly created cells in gt0 then we can guarantee that the cell A is split before time t > t0 with probability at least 1 − δ by making t suﬃciently large. Proof. Let d denote the depth of A in the tree gt0 and note that µ(A) > 0 with probability 1 since X has a density. This situation is illustrated in Figure 8. By construction, if the following conditions hold: 1. For some candidate split in A, the number of estimation points in both children is at least α(d), 2. The number of estimation points in A is at least β (d), then the algorithm must split A when the next structure point arrives. Thus in order to force a split we need the following sequence of events to occur: 1. A structure point must arrive in A to create a candidate split point. 2. The above two conditions must be satisﬁed. 3. Another structure point must arrive in A to force a split. It is possible for a split to be made before these events occur, but assuming a split is not triggered by some other mechanism we can guarantee that this sequence of events will occur in bounded time with high probability. Suppose a split is not triggered by a diﬀerent mechanism. Deﬁne E0 to be an event that occurs at t0 with probability 1, and let E1 ≤ E2 ≤ E3 be the times at which the above numbered events occur. Each of these events requires the previous one to have occurred and moreover, the sequence has a Markov structure, so for t0 ≤ t1 ≤ t2 ≤ t3 = t we have P (E1 ≤ t ∩ E2 ≤ t ∩ E3 ≤ t | E0 = t0 ) ≥ P (E1 ≤ t1 ∩ E2 ≤ t2 ∩ E3 ≤ t3 | E0 = t0 ) = P (E1 ≤ t1 | E0 = t0 ) P (E2 ≤ t2 | E1 ≤ t1 ) P (E3 ≤ t3 | E2 ≤ t2 ) ≥ P (E1 ≤ t1 | E0 = t0 ) P (E2 ≤ t2 | E1 = t1 ) P (E3 ≤ t3 | E2 = t2 ) . We can rewrite the ﬁrst and last term in more friendly notation as P (E1 ≤ t1 | E0 = t0 ) = P Nts0 ,t1 (A) ≥ 1 P (E3 ≤ t3 | E2 = t2 ) = P Nts2 ,t3 (A) ≥1 , .

1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869

Consistency of Online Random Forests

1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924

E0 t0 t1 − t0

E1 t2 − t1

E2 t3 − t2

E3 t

Figure 9. This Figure diagrams the structure of the argument used in Propositions 8 and 9. The indicated intervals are show regions where the next event must occur with high probability. Each of these intervals is ﬁnite, so their sum is also ﬁnite. We ﬁnd an interval which contains all of the events with high probability by summing the lengths of the intervals for which we have individual bounds.

Lemma 7 allows us to lower bound both of these probabilities by 1 − for any > 0 by making t1 − t0 and t3 − t2 large enough that Nts0 ,t1 ≥ and Nts2 ,t3 ≥ 2 max 1, µ(A)−1 log µ(A) 1 2 max 1, µ(A)−1 log µ(A) 1

respectively. To bound the centre term, recall that µ(A ) > 0 and µ(A ) > 0 with probability 1, and β (d) ≥ α(d) so P (E2 ≤ t2 | E1 = t1 ) ≥ P Nte1 ,t2 (A ) ≥ β (d) ∩ Nte1 ,t2 (A ) ≥ β (d) ≥ P Nte1 ,t2 (A ) ≥ β (d) + P Nte1 ,t2 (A ) ≥ β (d) − 1 , and we can again use Lemma 7 lower bound this by 1 − by making t2 − t1 suﬃciently large that Nte1 ,t2 ≥ 2 max β (d), min{µ(A ), µ(A )}−1 log min{µ(A ), µ(A )} 2

Thus by setting make

= 1 − (1 − δ )1/3 can ensure that the probability of a split before time t is at least 1 − δ if we

t = t0 + (t1 − t0 ) + (t2 − t1 ) + (t3 − t2 ) suﬃciently large. Proposition 9. Fix a partitioning sequence. Each cell in a tree built based on this sequence is split inﬁnitely often in probability. i.e for any x in the support of X , P (At (x) has been split fewer than K times) → 0 as t → ∞ for all K . Proof. For an arbitrary point x in the support of X , let Ek denote the time at which the cell containing x is split for the k th time, or inﬁnity if the cell containing x is split fewer than k times (deﬁne E0 = 0 with probability 1). Now deﬁne the following sequence: t0 = 0 ti = min{t | P (Ei ≤ t | Ei−1 = ti−1 ) ≥ 1 − }

1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979

Consistency of Online Random Forests

1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034

and set Tδ = tk . Proposition 8 guarantees that each of the above ti ’s exists and is ﬁnite. Compute,

k

P (Ek ≤ Tδ ) = P

k

[Ei ≤ Tδ ]

i=1

≥P

k

[Ei ≤ ti ]

i=1

P Ei ≤ ti |

j<i

[Ej ≤ tj ]

=

i=1 k

=

i=1 k

P (Ei ≤ ti | Ei−1 ≤ ti−1 ) P (Ei ≤ ti | Ei−1 = ti−1 )

i=1

≥

≥ (1 − )k where the last line follows from the choice of ti ’s. Thus for any δ > 0 we can choose Tδ to guarantee P (Ek ≤ Tδ ) ≥ 1 − δ by setting = 1 − (1 − δ )1/k and applying the above process. We can make this guarantee for any k which allows us to conclude that P (Ek ≤ t) → 1 as t → ∞ for all k as required. Proposition 10. Fix a partitioning sequence. Let At (X ) denote the cell of gt (built based on the partitioning sequence) containing the point X . Then diam(At (X )) → 0 in probability as t → ∞. Proof. Let Vt (x) be the size of the ﬁrst dimension of At (x). It suﬃces to show that E [Vt (x)] → 0 for all x in the support of X . Let X1 , . . . , Xm ∼ µ|At (x) for some 1 ≤ m ≤ m denote the samples from the structure stream that are used to determine the candidate splits in the cell At (x). Use πd to denote a projection onto the dth coordinate, and without loss of generality, assume that Vt = 1 and π1 Xi ∼ Uniform[0, 1]. Conditioned on the event that the ﬁrst dimension is cut, the largest possible size of the ﬁrst dimension of a child cell is bounded by V ∗ = max(max π1 Xi , 1 − min π1 Xi ) .

i=1 i=1 m m

Recall that we choose the number of candidate dimensions as min(1 + Poisson(λ), D) and select that number of distinct dimensions uniformly at random to be candidates. Deﬁne the following events: E1 = {There is exactly one candidate dimension} E2 = {The ﬁrst dimension is a candidate} Then using V to denote the size of the ﬁrst dimension of the child cell, E [V ] ≤ E [I {(E1 ∩ E2 )c } + I {E1 ∩ E2 } V ∗ ]

c c = P (E1 ) + P (E2 |E1 ) P (E1 ) + P (E2 |E1 ) P (E1 ) E [V ∗ ] 1 1 = (1 − e−λ ) + (1 − )e−λ + e−λ E [V ∗ ] d d e −λ e−λ =1− + E [V ∗ ] D D m e −λ e−λ m =1− + E max(max π1 Xi , 1 − min π1 Xi ) i=1 i=1 D D

=1−

e −λ e−λ 2m + 1 + · D D 2m + 2 e −λ =1− 2D(m + 1)

2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089

Consistency of Online Random Forests

2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144

Iterating this argument we have that after K splits the expected size of the ﬁrst dimension of the cell containing x is upper bounded by e −λ 1− 2D(m + 1)

K

so it suﬃces to have K → ∞ in probability, which we know to be the case from Proposition 9. Proposition 11. Fix a partitioning sequence. In any tree built based on this sequence, N e (At (X )) → ∞ in probability. Proof. It suﬃces to show that N e (At (x)) → ∞ for all x in the support of X . Fix such an x, by Proposition 9 we can make the probability At (x) is split fewer than K times arbitrarily small for any K . Moreover, by construction immediately after the K -th split is made the number of estimation points contributing to the prediction at x is at least α(K ), and this number can only increase. Thus for all K we have that P (N e (At (x)) < α(K )) → 0 as t → ∞ as required. We are now ready to prove our main result. All the work has been done, it is simply a matter of assembling the pieces. Proof (of Theorem 1). Fix a partitioning sequence. Conditioned on this sequence the consistency of each of the class posteriors follows from Theorem 5. The two required conditions where shown to hold in Propositions 10 and 11. Consistency of the multiclass tree classiﬁer then follows by applying Proposition 4. To remove the conditioning on the partitioning sequence, note that Lemma 6 shows that our tree generation mechanism produces a partitioning sequence with probability 1. Apply Proposition 3 to get unconditional consistency of the multiclass tree. Proposition 2 lifts consistency of the trees to consistency of the forest, establishing the desired result. B.7. Extension to a Fixed Size Fringe Proving consistency is preserved with a ﬁxed size fringe requires more precise control over the relationship between the number of estimation points seen in an interval, Nte0 ,t , and the total number of splits which have occurred in the tree, K . The following two lemmas provide the control we need. Lemma 12. Fix a partitioning sequence. If K is the number of splits which have occurred at or before time t then for all M > 0 P (K ≤ M ) → 0 in probability as t → ∞. Proof. Denote the fringe at time t with Ft which has max size |F |, and the set of leafs at time t as Lt with size |Lt |. If |Lt | < |F | then there is no change from the unbounded fringe case, so we assume that |Lt | ≥ |F | so that for all t there are exactly |F | leafs in the fringe. Suppose a leaf A1 ∈ Ft0 for some t0 then for every δ > 0 there is a ﬁnite time t1 such that for all t ≥ t1 P (A1 has not been split before time t) ≤ δ |F |

Now ﬁx a time t0 and δ > 0. For each leaf Ai ∈ Ft0 we can choose ti to satisfy the above bound. Set t = maxi ti then the union bound gives P (K ≤ |F | at time t) ≤ δ

2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199

Consistency of Online Random Forests

2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254

Iterate this argument M/|F | times with δ = / M/|F | and apply the union bound again to get that for suﬃciently large t P (K ≤ M ) ≤ for any > 0.

Lemma 13. Fix a partitioning sequence. If K is the number of splits which have occurred at or before time t then for any t0 > 0, K/Nte0 ,t → 0 as t → ∞.

e e Proof. First note that Nte0 ,t = N0 ,t − N0,t0 −1 so

K K = e e Nte0 ,t N0,t − N0 ,t0 −1

e e and since N0 ,t0 −1 is ﬁxed it is suﬃcient to show that K/N0,t → 0. In the following we write N = N0,t to lighten the notation.

Deﬁne the cost of a tree T as the minimum value of N required to construct a tree with the same shape as T . The cost of the tree is governed by the function α(d) which gives the cost of splitting a leaf at level d. The cost of a tree is found by summing the cost of each split required to build the tree. Note that no tree on K splits is cheaper than a tree of max depth d = log2 (K ) with all levels full (except possibly the last, which may be partially full). This is simple to see, since α(d) is an increasing function of d, meaning it is never more expensive to add a node at a lower level than a higher one. Thus we assume wlog that the tree is full except possibly in the last level. When ﬁlling the dth layer of the tree, each split requires at least 2α(d + 1) points because a split creates two new leafs at level d + 1. This means that for K in the range [2d , 2d+1 − 1] (the range of splits which ﬁll up level d), K can increase at a rate which is at most 1/2α(d + 1) with respect to N . This also tells us that ﬁlling the dth level of the tree requires that N increase by at least 2d α(d) = 2d−1 · 2α(d) (ﬁlling the dth level corresponds to splitting each of the 2d−1 leafs on the d − 1th level at a cost of 2α(d) each). This means that ﬁlling d levels of the tree requires at least

d

Nd =

k=1 d

2k α(k )

points. When N = Nd , K is at most 2 − 1 because that is the number of splits in a full binary tree of depth d. The above argument gives a collection of linear upper bounds on K in terms of N . We know that the maximum growth rate is linear between (Nd , 2d − 1) and (Nd+1 , 2d+1 − 1) so for all d we can ﬁnd that since (2d+1 − 1) − (2d − 1) = (Nd+1 ) − (Nd ) we have that for N and d, K≤ where C (d) is given by C (d) = 2d − 1 − From this we have K 1 1 ≤ + N 2α(d + 1) N 2d − 1 − 1 2

d

2d+1 − 2d

d+1 k=1

2k α (k ) −

d k=1

2k α(k )

=

2d 1 = 2d+1 α(d + 1) 2α(d + 1)

1 N + C (d) 2α(d + 1)

d

1 2

2k

k=1

α (k ) α(d + 1)

2k

k=1

α(k ) α(d + 1)

which holds for all d and N , so if we choose d to make 1/α(d + 1) ≤ δ/2 and then pick N such that C (d)/N ≤ δ/2 we have K/N ≤ δ for arbitrary δ > 0 which proves the claim.

2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309

Consistency of Online Random Forests

2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364

K 23 − 1

1 2α(3) 1 2α(2)

2 −1 C (2) 21 − 1

1 2α(1)

2

0

e N0 ,t

Figure 10. Diagram of the bound in Lemma 13. The horizontal axis is the number of estimation points seen at time t and the vertical axis is the number of splits. The ﬁrst bend is the earliest point at which the root of the tree could be split, which requires 2α(1) points to create 2 new leafs at level 1. Similarly, the second bend is the point at which all leafs at level 1 have been split, each of which requires at least 2α(2) points to create a pair of leafs at level 2.

In order to show that our algorithm remains consistent with a ﬁxed size fringe we must ensure that Proposition 8 does not fail in this setting. Interpreted in the context of a ﬁnite fringe, Proposition 8 says that any cell in the fringe will be split in ﬁnite time. This means that to ensure consistency we need only show that any inactive point will be added to the fringe in ﬁnite time. Remark 14. If s(A) = 0 for any leaf then we know that e(A) = 0, since µ(A) > 0 by construction. If e(A) = 0 then P (g (X ) = Y | X ∈ A) = 0 which means that any subdivision of A has the same asymptotic probability of error as leaving A in tact. Our rule never splits A and thus fails to satisfy the shrinking leaf condition, but our predictions are asymptotically the same as if we had divided A into arbitrarily many pieces so this doesn’t matter. Proposition 15. Every leaf with s(A) > 0 will be added to the fringe in ﬁnite time with high probability. Proof. Pick an arbitrary leaf A. We know from Hoeﬀding’s inequality that P (ˆ p(A) ≤ µ(A) − ) ≤ exp −2|A| and P (ˆ p(A) ≥ µ(A) + ) ≤ exp −2|A|

2 2

≤ exp −2α(d)

2

≤ exp −2α(d)

2

Now pick an arbitrary time t0 and condition on everything before t0 . For an arbitrary node A ⊂ RD , if A is a child of A then we know that if {Ui }Dm i=1 are iid on [0, 1] then E [µ(A )] ≤ µ(A)E max(max(Ui , 1 − Ui ))

i=1 Dm

= µ(A)

2Dm + 1 2Dm + 2

since there are at most D candidate dimensions and each one accumulates at most m candidate splits. So if AK is any leaf created by K splits of A then E µ(AK ) ≤ µ(A) Notice that since we have conditioned on the tree at t0 so, E p ˆ(AK ) = E E p ˆ(AK ) | µ(AK ) = E µ(AK ) 2Dm + 1 2Dm + 2

K

2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419

Consistency of Online Random Forests

2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474

And we can bound p ˆ(AK ) with P p ˆ(AK ) ≥ µ(A) Set (2K +1 |L|)−1 δ = exp −2|AK |

2

2Dm + 1 2Dm + 2

K

+

≤ exp −2|AK |

2

and invert the bound so we have 2Dm + 1 2Dm + 2

K

P p ˆ(AK ) ≥ µ(A)

+

1 log 2|AK |

2K +1 |L| δ

≤

δ 2K +1 |L|

Pick an arbitrary leaf A0 which is in the tree at time t0 . We can use the same approach to ﬁnd a lower bound on s ˆ(A0 ): P s ˆ(A0 ) ≤ s(A0 ) − 1 log 2|A0 | 2K +1 |L| δ ≤ δ 2K +1 |L|

To ensure that s ˆ(A0 ) ≥ p ˆ(AK ) (≥ s ˆ(AK )) fails to hold with probability at most δ 2−K |L|−1 we must choose k and t to make s(A0 ) ≥ µ(A) 2Dm + 1 2Dm + 2

K

+

1 log 2|AK |

2K +1 |L| δ

+

1 log 2|A0 |

2K +1 |L| δ

The ﬁrst term goes to 0 as K → ∞. We know that |AK | ≥ α(K ) so the second term also goes to 0 provided that K/α(K ) → 0, which we require. The third term goes to 0 if K/|A0 | → 0. Recall that |A0 | = Nte0 ,t (A0 ) and for any γ > 0 P Nte0 ,t (A) ≤ Nte0 ,t µ(A) − 1 log 2Nte0 ,t 1 γ ≤γ

From this we see it is suﬃcient to have K/Nte0 ,t → 0 which we established in a lemma. In summary, there are |L| leafs in the tree at time t0 and each of them generates at most 2K diﬀerent AK ’s. Union bounding over all these leafs and over the probability of Nte0 ,t (A0 ) growing sublinearly in Nte0 ,t we have that, conditioned on the event that A0 has not yet been split, A0 is the leaf with the highest value of s ˆ with probability at least 1 − δ − γ in ﬁnite time. Since δ and γ are arbitrary we are done.

2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529

Consistency of Online Random Forests

Abstract

As a testament to their success, the theory of random forests has long been outpaced by their application in practice. In this paper, we take a step towards narrowing this gap by providing a consistency result for online random forests.

present what is to the best of our knowledge the ﬁrst consistency result for online random forests. We show that the theory provides guidance for designing online random forest algorithms. A few simple experiments with our algorithm conﬁrm the requirements for consistency predicted by the theory. The experiments also highlight some theoretical and practical problems that need to be addressed.

1. Introduction

Random forests are a class of ensemble method whose base learners are a collection of randomized tree predictors, which are combined through averaging. The original random forests framework described in Breiman (2001) has been extremely inﬂuential (Svetnik et al., 2003; Prasad et al., 2006; Cutler et al., 2007; Shotton et al., 2011; Criminisi et al., 2011). Despite their extensive use in practical settings, very little is known about the mathematical properties of these algorithms. A recent paper by one of the leading theoretical experts states that Despite growing interest and practical use, there has been little exploration of the statistical properties of random forests, and little is known about the mathematical forces driving the algorithm (Biau, 2012). Theoretical work in this area typically focuses on stylized versions of the random forests algorithms used in practice. For example, Biau et al. (2008) prove the consistency of a variety of ensemble methods built by averaging base classiﬁers. Two of the models they study are direct simpliﬁcations of the forest growing algorithms used in practice; the others are stylized neighbourhood averaging rules, which can be viewed as simpliﬁcations of random forests through the lens of Lin & Jeon (2002). In this paper we make further steps towards narrowing the gap between theory and practice. In particular, we

Preliminary work. Under review by the International Conference on Machine Learning (ICML). Do not distribute.

2. Related Work

Diﬀerent variants of random forests are distinguished by the methods they use for growing the trees. The model described in Breiman (2001) builds each tree on a bootstrapped sample of the training set using the CART methodology (Breiman et al., 1984). The optimization in each leaf that searches for the optimal split point is restricted to a random selection of features, or linear combinations of features. The framework of Criminisi et al. (2011) operates slightly diﬀerently. Instead of choosing only features at random, this framework chooses entire decisions (i.e. both a feature or combination of features and a threshold together) at random and optimizes only over this set. They also oﬀer a variety of diﬀerent objectives which can be optimized to split each leaf, depending on the task at hand (e.g. classiﬁcation vs manifold learning). Unlike the work of Breiman (2001), this framework chooses not to include bagging, preferring instead to train each tree on the entire data set and introduce randomness only in the splitting process. The authors argue that without bagging their model obtains max-margin properties. In addition to the frameworks mentioned above, many practitioners introduce their own variations on the basic random forests algorithm, tailored to their speciﬁc problem domain. A variant from Bosch et al. (2007) is especially similar to the technique we use in this paper: When growing a tree the authors randomly select one third of the training data to determine the structure of the tree and use the remaining two thirds to ﬁt the leaf estimators. However, the authors consider this only as a technique for introducing randomness into the trees, whereas in our model the partitioning

055 056 057 058 059 060 061 062 063 064 065 066 067 068 069 070 071 072 073 074 075 076 077 078 079 080 081 082 083 084 085 086 087 088 089 090 091 092 093 094 095 096 097 098 099 100 101 102 103 104 105 106 107 108 109

Consistency of Online Random Forests

110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164

of data plays a central role in consistency. In addition to these oﬄine methods, several researchers have focused on building online versions of random forests. Online models are attractive because they do not require that the entire training set be accessible at once. These models are appropriate for streaming settings where training data is generated over time and should be incorporated into the model as quickly as possible. Several variants of online decision tree models are present in the MOA system of Bifet et al. (2010). The primary diﬃculty with building online decision trees is their recursive nature. Data encountered once a split has been made cannot be used to correct earlier decisions. A notable approach to this problem is the Hoeﬀding tree (Domingos & Hulten, 2000) algorithm, which works by maintaining several candidate splits in each leaf. The quality of each split is estimated online as data arrive in the leaf, but since the entire training set is not available these quality measures are only estimates. The Hoeﬀding bound is employed in each leaf to control the amount of data which must be collected to ensure that the split chosen on the basis of these estimates is the true best split with high probability. Domingos & Hulten (2000) prove that under reasonable assumptions the online Hoeﬀding tree converges to the oﬄine tree with high probability. The Hoeﬀding tree algorithm is implemented in the system of Bifet et al. (2010). Alternative methods for controlling tree growth in an online setting have also been explored. Saﬀari et al. (2009) use the online bagging technique of Oza & Russel (2001) and control leaf splitting using two parameters, in their online random forest. One parameter speciﬁes the minimum number of data points which must be seen in a leaf before it can be split, and another speciﬁes a minimum quality threshold that the best split in a leaf must reach. This is similar in ﬂavor to the technique used by Hoeﬀding trees, but trades theoretical guarantees for more interpretable parameters. One active avenue of research in online random forests involves tracking non-stationary distributions, also known as concept drift. Many of the online techniques incorporate features designed for this problem (Gama et al., 2005; Abdulsalam, 2008; Saﬀari et al., 2009; Bifet et al., 2009; 2012). However, tracking of nonstationarity is beyond the scope of this paper. The most well known theoretical result for random forests is that of Breiman (2001), which gives an upper bound on the generalization error of the forest in

terms of the correlation and strength of trees. Following Breiman (2001), an interpretation of random forests as an adaptive neighborhood weighting scheme was published in Lin & Jeon (2002). This was followed by the ﬁrst consistency result in this area from Breiman (2004), which proves consistency of a simpliﬁed model of the random forests used in practice. In the context of quantile regression the consistency of a certain model of random forests has been shown by Meinshausen (2006). A model of random forests for survival analysis was shown to be consistent in Ishwaran & Kogalur (2010). Signiﬁcant recent work in this direction comes from Biau et al. (2008) who prove the consistency of a variety of ensemble methods built by averaging base classiﬁers, as is done in random forests. A key feature of the consistency of the tree construction algorithms they present is a proposition that states that if the base classiﬁer is consistent then the forest, which takes a majority vote of these classiﬁers, is itself consistent. The most recent theoretical study, and the one which achieves the closest match between theory and practice, is that of Biau (2012). The most signiﬁcant way in which their model diﬀers from practice is that it requires a second data set which is not used to ﬁt the leaf predictors in order to make decisions about variable importance when growing the trees. One of the innovations of the model we present in this paper is a way to circumvent this limitation in an online setting while maintaining consistency.

3. Random Forests

In this section we brieﬂy review the random forests framework. For a more comprehensive review we refer the reader to Breiman (2001) and Criminisi et al. (2011). Random forests are built by combining the predictions of several trees, each of which is trained in isolation. Unlike in boosting (Schapire & Freund, 2012) where the base classiﬁers are trained and combined using a sophisticated weighting scheme, typically the trees are trained independently and the predictions of the trees are combined through a simple majority vote. There are three main choices to be made when constructing a random tree. These are (1) the method for splitting the leafs, (2) the type of predictor to use in each leaf, and (3) the method for injecting randomness into the trees. Specifying a method for splitting leafs requires selecting the shapes of candidate splits as well as a method

165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219

Consistency of Online Random Forests

220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274

for evaluating the quality of each candidate. Typical choices here are to use axis aligned splits, where data are routed to sub-trees depending on whether or not they exceed a threshold value in a chosen dimension; or linear splits, where a linear combination of features are thresholded to make a decision. The threshold value in either case can be chosen randomly or by optimizing a function of the data in the leafs.

4. Online Random Forests with Stream Partitioning

In this section we describe the workings of our online random forest algorithm. A more precise (pseudocode) description of the training procedure can be found in Appendix A. 4.1. Forest Construction The random forest classiﬁer is constructed by building a collection of random tree classiﬁers in parallel. Each tree is built independently and in isolation from the other trees in the forest. Unlike many other random forest algorithms we do not preform bootstrapping or subsampling at this level; however, the individual trees each have their own optional mechanism for subsampling the data they receive.

Figure 1. Three potential splits for a leaf node and the class histograms for the children each split would create. The rightmost split creates the purest children and will have the greatest information gain.

4.2. Tree Construction Each node of the tree is associated with a rectangular subset of RD , and at each step of the construction the collection of cells associated with the leafs of the tree forms a partition of RD . The root of the tree is RD itself. At each step we receive a data point (Xt , Yt ) from the environment. Each point is assigned to one of two possible streams at random with ﬁxed probability. We denote stream membership with the variable It ∈ {s, e}. How the tree is updated at each time step depends on which stream the corresponding data point is assigned to. We refer to the two streams as the structure stream and the estimation stream; points assigned to these streams are structure and estimation points, respectively. These names reﬂect the diﬀerent uses of the two streams in the construction of the tree: Structure points are allowed to inﬂuence the structure of the tree partition, i.e. the locations of candidate split points and the statistics used to choose between candidates, but they are not permitted to inﬂuence the predictions that are made in each leaf of the tree. Estimation points are not permitted to inﬂuence the shape of the tree partition, but can be used to estimate class membership probabilities in whichever leaf they are assigned to. Only two streams are needed to build a consistent forest, but there is no reason we cannot have more. For instance, we explored the use of a third stream for points that the tree should ignore completely, which gives a form of online sub-sampling in each tree. We found empirically that including this third stream hurts performance of the algorithm, but its presence

In order to split a leaf, a collection of candidate splits are generated and a criterion is evaluated to choose between them. A simple strategy is to choose among the candidates uniformly at random, as in the models analyzed in Biau et al. (2008). A more common approach is to choose the candidate split which optimizes a purity function over the leafs that would be created. Typical choices here are to maximize the information gain, or the Gini gain (Hastie et al., 2013). This situation is illustrated in Figure 1. The most common choice for predictors in each leaf is to use the majority vote over the training points which fall in that leaf. Criminisi et al. (2011) explore the use of several diﬀerent leaf predictors for regression and manifold learning, but these generalizations are beyond the scope of this paper. We consider majority vote classiﬁers in our model. Injecting randomness into the tree construction can happen in many ways. The choice of which dimensions to use as split candidates at each leaf can be randomized, as well as the choice of coeﬃcients for random combinations of features. In either case, thresholds can be chosen either randomly or by optimization over some or all of the data in the leaf. Another common method for introducing randomness is to build each tree using a bootstrapped or subsampled data set. In this way, each tree in the forest is trained on slightly diﬀerent data, which introduces diﬀerences between the trees.

275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329

Consistency of Online Random Forests

330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384

or absence does not aﬀect the theoretical properties. 4.3. Leaf Splitting Mechanism When a leaf is created the number of candidate split dimensions for the new leaf is set to min(1 + Poisson(λ), D), and this many distinct candidate dimensions are selected uniformly at random. We then collect m candidate splits in each candidate dimension (m is a parameter of the algorithm) by projecting the ﬁrst m structure points to arrive in the newly created leaf onto the candidate dimensions. We maintain several structural statistics for each candidate split. Speciﬁcally, for each candidate split we maintain class histograms for each of the new leafs it would create, using data from the estimation stream. We also maintain structural statistics, computed from data in the structure stream, which can be used to choose between the candidate splits. The speciﬁc form of the structural statistics does not aﬀect the consistency of our model, but it is crucial that they depend only on data in the structure stream. Finally, we require two additional conditions which control when a leaf at depth d is split: 1. Before a candidate split can be chosen, the class histograms in each of the leafs it would create must incorporate information from at least α(d) estimation points. 2. If any leaf receives more than β (d) estimation points, and the previous condition is satisﬁed for any candidate split in that leaf, then when the next structure point arrives in this leaf it must be split regardless of the state of the structural statistics. The ﬁrst condition ensures that leafs are not split too often, and the second condition ensures that no branch of the tree ever stops growing completely. In order to ensure consistency we require that α(d) → ∞ monotonically in d. We also require that β (d) ≥ α(d) for convenience. When a structure point arrives in a leaf, if the ﬁrst condition is satisﬁed for some candidate split then the leaf may optionally be split at the corresponding point. The decision of whether to split the leaf or wait to collect more data is made on the basis of the structural statistics collected for the candidate splits in that leaf. 4.4. Structural Statistics In each candidate child we maintain an estimate of the posterior probability of each class, as well as the total

number of points we have seen fall in the candidate child, both counted from the structure stream. In order to decide if a leaf should be split, we compute the information gain for each candidate split which satisﬁes condition 1 from the previous section, I (S ) = H (A) − |A | |A | H (A ) − H (A ) . |A| |A|

Here S is the candidate split, A is the cell belonging to the leaf to be split, and A and A are the two leafs that would be created if A were split at S . The function H (A) is the discrete entropy, computed over the labels of the structure points which fall in the cell A. We select the candidate split with the largest information gain for splitting, provided this split achieves a minimum threshold in information gain, τ . The value of τ is a parameter of our algorithm. 4.5. Prediction At any time the online forest can be used to make predictions for unlabelled data points using the model built from the labelled data it has seen so far. To make a prediction for a query point x at time t, each tree computes, for each class k ,

k ηt (x) =

1 N e (A

t (x)) (Xτ ,Yτ )∈At (x) Iτ =e

I {Yτ = k } ,

where At (x) denotes the leaf of the tree containing x at time t, and N e (At (x)) is the number of estimation points which have been counted in At (x) during its lifetime. Similarly, the sum is over the labels of these points. The tree prediction is then the class which maximizes this value:

k gt (x) = arg max{ηt (x)} . k

The forest predicts the class which receives the most votes from the individual trees. Note that this requires that we maintain class histograms from both the structure and estimation streams separately for each candidate child in the fringe of the tree. The counts from the structure stream are used to select between candidate split points, and the counts from the estimation stream are used to initialize the parameters in the newly created leafs after a split is made. 4.6. Memory Management The typical approach to building trees online, which is employed in Domingos & Hulten (2000) and Saffari et al. (2009), is to maintain a fringe of candidate

385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439

Consistency of Online Random Forests

440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494

children in each leaf of the tree. The algorithm collects statistics in each of these candidate children until some (algorithm dependent) criterion is met, at which point a pair of candidate children is selected to replace their parent. The selected children become leafs in the new tree, acquiring their own candidate children, and the process repeats. Our algorithm also uses this approach. The diﬃculty here is that the trees must be grown breadth ﬁrst, and maintaining the fringe of potential children is very memory intensive when the trees are large. Our algorithm also suﬀers from this deﬁciency, as maintaining the fringe requires O(cmd) statistics in each leaf, where d is the number of candidate split dimensions, m is the number of candidate split points (i.e. md pairs of candidate children per leaf) and c is the number of classes in the problem. The number of leafs grows exponentially fast with tree depth, meaning that for deep trees this memory cost becomes prohibitive. Oﬄine forests do not suﬀer from this problem, because they are able to grow the trees depth ﬁrst. Since they do not need to accumulate statistics for more than one leaf at a time, the cost of computing even several megabytes of statistics per split is negligible. Although the size of the trees still grows exponentially with depth, this memory cost is dwarfed by the savings from not needing to store split statistics for all the leafs. In practice the memory problem is resolved either by growing small trees, as in Saﬀari et al. (2009), or by bounding the number of nodes in the fringe of the tree, as in Domingos & Hulten (2000). Other models of streaming random forests, such as those discussed in Abdulsalam (2008), build trees in sequence instead of in parallel, which reduces the total memory usage. Our algorithm makes use of a bounded fringe and adopts the technique of Domingos & Hulten (2000) to control the policy for adding and removing leafs from the fringe. In each tree we partition the leafs into two sets: we have a set of active leafs, for which we collect split statistics as described in earlier sections, and a set of inactive leafs for which we store only two numbers. We call the set of active leafs the fringe of the tree, and describe a policy for controlling how inactive leafs are added to the fringe. In each inactive leaf At we store the following two quantities • p ˆ(At ) which is an estimate of µ(At ) = P (X ∈ At ),

and • e ˆ(At ) which is an estimate P (gt (X ) = Y | X ∈ At ). of e(A) =

Both of these are estimated based on the estimation points which arrive in At during its lifetime. From these two numbers we form the statistic s ˆ(A) = p ˆ(A)ˆ e(A) (with corresponding true value s(A) = p(A)e(A)) which is an upper bound on the improvement in error rate that can be obtained by splitting A. Membership in the fringe is controlled by s ˆ(A). When a leaf is split it relinquishes its place in the fringe and the inactive leaf with the largest value of s ˆ(A) is chosen to take its place. The newly created leafs from the split are initially inactive and must compete with the other inactive leafs for entry into the fringe. Unlike Domingos & Hulten (2000), who use this technique only as a heuristic for managing memory use, we incorporate the memory management directly into our analysis. The analysis in Appendix B shows that our algorithm, including a limited size fringe, is consistent.

5. Theory

In this section we state our main theoretical results and give an outline of the strategy for establishing consistency of our online random forest algorithm. In the interest of space and clarity we do not include proofs in this section. Unless otherwise noted, the proofs of all claims appear in Appendix B. We denote the tree partition created by our online random forest algorithm from t data points as gt . As t varies we obtain a sequence of classiﬁers, and we are interested in showing that the sequence {gt } is consistent, or more precisely that the probability of error of gt converges in probability to the Bayes risk, i.e. L(gt ) = P (gt (X, Z ) = Y | Dt ) → L∗ , as t → ∞. Here (X, Y ) is a random test point and Z denotes the randomness in the tree construction algorithm. Dt is the training set (of size t) and the probability in the convergence is over the random selection of Dt . The Bayes risk is the probability of error of the Bayes classiﬁer, which is the classiﬁer that makes predictions by choosing the class with the highest posterior probability, g (x) = arg max P (Y = k | X = x) ,

k

(where ties are broken in favour of the smaller index). The Bayes risk L(g ) = L∗ is the minimum achievable

495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549

Consistency of Online Random Forests

550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604

risk of any classiﬁer for the distribution of (X, Y ). In order to ease notation, we drop the explicit dependence on Dt in the remainder of this paper. More information about this setting can be found in Devroye et al. (1996). Our main result is the following theorem: Theorem 1. Suppose the distribution of X has a density with respect to the Lebesgue measure and that this density is bounded from above and below. Then the online random forest classiﬁer described in this paper is consistent. The ﬁrst step in proving Theorem 1 is to show that the consistency of a voting classiﬁer, such as a random forest, follows from the consistency of the base classiﬁers. We prove the following proposition, which is a straightforward generalization of a proposition from Biau et al. (2008), who prove the same result for two class ensembles. Proposition 2. Assume that the sequence {gt } of randomized classiﬁers is consistent for a certain distribu(M ) tion of (X, Y ). Then the voting classiﬁer, gt obtained by taking the majority vote over M (not necessarily independent) copies of gt is also consistent. With Proposition 2 established, the remainder of the eﬀort goes into proving the consistency of our tree construction. The ﬁrst step is to separate the stream splitting randomness from the remaining randomness in the tree construction. We show that if a classiﬁer is conditionally consistent based on the outcome of some random variable, and the sampling process for this random variable generates acceptable values with probability 1, then the resulting classiﬁer is unconditionally consistent. Proposition 3. Suppose {gt } is a sequence of classiﬁers whose probability of error converges conditionally in probability to the Bayes risk L∗ for a speciﬁed distribution on (X, Y ), i.e. P (gt (X, Z, I ) = Y | I ) → L∗ for all I ∈ I and that ν is a distribution on I . If ν (I ) = 1 then the probability of error converges unconditionally in probability, i.e. P (gt (X, Z, I ) = Y ) → L∗ In particular, {gt } is consistent for the speciﬁed distribution. Proposition 3 allows us to condition on the random variables {It }∞ t=1 which partition the data stream into

structure and estimation points in each tree. Provided that the random partitioning process produces acceptable sequences with probability 1, it is suﬃcient to show that the random tree classiﬁer is consistent conditioned on such a sequence. In particular, in the remainder of the argument we assume that {It }∞ t=1 is a ﬁxed, deterministic sequence which assigns inﬁnitely many points to each of the structure and estimation streams. We refer to such a sequence as a partitioning sequence. S I E

Figure 2. The dependency structure of our algorithm. S represents the randomness in the structure of the tree partition, E represents the randomness in the leaf estimators and I represents the randomness in the partitioning of the data stream. E and S are independent conditioned on I .

The reason this is useful is that conditioning on a partitioning sequence breaks the dependence between the structure of the tree partition and the estimators in the leafs. This is a powerful tool because it gives us access to a class of consistency theorems which rely on this type of independence. However, before we are able to apply these theorems we must further reduce our problem to proving the consistency of estimators of the posterior distribution of each class. Proposition 4. Suppose we have regression estik mates, ηt (x), for each class posterior η k (x) = P (Y = k | X = x), and that these estimates are each consistent. The classiﬁer

k gt (x) = arg max{ηt (x)} k

(where ties are broken in favour of the smaller index) is consistent for the corresponding multiclass classiﬁcation problem. Proposition 4 allows us to reduce the consistency of the multiclass classiﬁer to the problem of proving the consistency of several two class posterior estimates. Given a set of classes {1, . . . , c} we can re-assign the labels using the map (X, Y ) → (X, I {Y = k }) for any k ∈ {1, . . . , c} in order to get a two class problem where P (Y = 1 | X = x) in this new problem is equal to η k (x) in the original multiclass problem. Thus to prove consistency of the multiclass classiﬁer it is enough to show that each of these two class posteriors is consistent. To this end we make use of the following theorem from Devroye et al. (1996). Theorem 5. Consider a partitioning classiﬁcation rule which builds a prediction ηt (x) of η (x) = P (Y = 1 | X = x) by averaging the labels in each cell

605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659

Consistency of Online Random Forests

660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714

of the partition. If the labels of the voting points do not inﬂuence the structure of the partition then E [|ηt (x) − η (x)|] → 0 provided that 1. diam(At (X )) → 0 in probability, 2. N e (At (X )) → ∞ in probability.

6. Experiments

In this section we demonstrate some empirical results on simple problems in order to illustrate the properties of our algorithm. We also provide a comparison to an existing online random forest algorithm. Following the review process we plan to release code to reproduce all of the experiments in this section.

0.70

Forest and tree accuracy

Proof. See Theorem 6.1 in Devroye et al. (1996). Here At (X ) refers to the cell of the tree partition containing a random test point X , and diam(A) indicates the diameter of set A. The diameter is deﬁned as the maximum distance between any two points falling in A, diam(A) = sup ||x − y || .

x,y ∈A

0.65 0.60

0.55 0.50 0.45 0.40 0.35 2 10 103

Trees Forest Bayes Data Size

104

The quantity N e (At (X )) is the number of points contributing to the estimation of the posterior at X . This theorem places two requirements on the cells of the partition. The ﬁrst condition ensures that the cells are suﬃciently small that small details of the posterior distribution can be represented. The second condition requires that the cells be large enough that we are able to obtain high quality estimates of the posterior probability in each cell. The leaf splitting mechanism described in Section 4.3 ensures that the second condition of Theorem 5 is satisﬁed. However, showing that our algorithm satisﬁes the ﬁrst condition requires signiﬁcantly more work. The chief diﬃculty lies in showing that every leaf of the tree will be split inﬁnitely often in probability. Once this claim is established a relatively straightforward calculation shows that the expected size of each dimension of a leaf is reduced each time it is split. So far we have described the approach to proving consistency of our algorithm with an unbounded fringe. If the tree is small (i.e. never has more leafs than the maximum fringe size) then the analysis is unchanged. However, since our trees are required to grow to unbounded size this is not possible. To handle this case we derive an upper bound on the time required for an inactive leaf to enter the fringe. Once the leaf it remains there until it is split and the analysis from the unbounded fringe case applies. These details are somewhat technical, so we refer the interested reader to Appendix B for more information, as well as the proofs of the propositions stated in this section.

Figure 3. Prediction accuracy of the forest and the trees it averages on a simple mixture of Gaussians problem. The horizontal line shows the accuracy of the Bayes classiﬁer on this problem. We see that the accuracy of the forest consistently dominates the expected accuracy of the trees. The forest in this example contains 100 trees. Error regions show one standard deviation computed over 10 runs.

6.1. Advantage of a Forest Our ﬁrst experiment demonstrates that although the individual trees are consistent classiﬁers, empirically the performance of the forest is signiﬁcantly better than each of the trees for problems with ﬁnite data. We demonstrate this on a synthetic ﬁve class mixture of Gaussians problem with signiﬁcant class overlap and variation in prior weights. From Figure 3 it is clear that the forest converges much more quickly than the individual trees. Result proﬁles of this kind are common in the boosting and random forests literature; however, in practice one often uses inconsistent base classiﬁers in the ensemble (e.g. boosting with decision stumps or random forests where the trees are grown to full size). This experiment demonstrates that although our base classiﬁers provably converge, empirically there is still a beneﬁt from averaging in ﬁnite time. 6.2. Growing leaves Our next experiment demonstrates the importance of the condition that α(d) → ∞, i.e. having the num-

715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769

Accuracy

Consistency of Online Random Forests

770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824

Gap to Bayes Error

α (d ) = 1 α (d ) = 2 d Excess Error

1.0 0.9

USPS

Accuracy

0.8 0.7 0.6 0.5

Bayes

103

Data Size

104

105

106

0.4

Offline Online Saffari et al. (2009)

102

Data Size

103

Figure 4. Excess error above the Bayes risk for a simple synthetic problem. The solid line shows the excess error for a forest where each tree is built to full depth. The dashed line shows a forest where each tree requires 2d examples in a leaf at level d in order to split. Both forests contain 100 trees.

Figure 5. Comparison between oﬄine random forests and our online algorithm on the USPS data set. The online forest uses 10 passes through the data set. The third line is our implementation of the algorithm from Saﬀari et al. (2009); the performance shown here is identical to what they report. Error regions show one standard deviation computed over 10 runs.

6.3. Comparison to Oﬄine ber of data points in each leaf grow over time. We demonstrate this using a synthetic two class distribution speciﬁcally designed to exhibit problems when α(d) does not grow. In the distribution we construct, P (X = x) is uniform on the unit square in R2 , and the posterior P (Y = 1 | X = x) = 0.5001 for all x. Figure 4 shows the excess error of two forests trained on several data sets of diﬀerent sizes sampled from this distribution. In one of the forests the trees are grown to full depth, while in the other we force the size of the leafs to increase with their depth in the tree. As can be seen in Figure 4, building trees to full depth prevents the forest from making progress towards the Bayes error over a huge range of data set sizes, whereas the forest composed of trees with growing leafs steadily decreases its excess error. Admittedly, this scenario is quite artiﬁcial, and it can be diﬃcult to ﬁnd real problems where the diﬀerence is so pronounced. It is still an open question as to whether a forest can be made consistent by averaging over an inﬁnite number of trees of full depth (although see Breiman (2004) and Biau (2012) for results in this direction). The purpose of this example is to show that in the common scenario where the number of trees is a ﬁxed parameter of the algorithm, having leafs that grow over time is important. In our third experiment, we demonstrate that our online algorithm is able to achieve similar performance to an oﬄine implementation of random forests and also compare to an existing online random forests algorithm on a small non-synthetic problem. In particular, we demonstrate this on the USPS data set from the LibSVM repository (Chang & Lin, 2011). We have chosen the USPS data for this experiment because it allows us to compare our results directly to those of Saﬀari et al. (2009), whose algorithm is very similar to our own. In the interest of comparability we also use a forest of 100 trees and set the minimum information gain threshold (τ in our model) to 0.1. We show results from both online algorithms with 10 passes through the data. Figure 5 shows that we are able to achieve performance very similar to the oﬄine random forest on the full data. The performance we achieve is identical to the performance reported by Saﬀari et al. (2009) on this data set. 6.4. Kinect application For our ﬁnal experiment we evaluate our online random forest algorithm on the challenging computer vision problem of predicting human body part labels from a depth image. Our procedure closely follows the work of Shotton et al. (2011) which is used in the commercially successful Kinect system. Applying the

825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879

Consistency of Online Random Forests

880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934

0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0.0 2 10 103

Kinect

α(d) =10 ·(1.01d )

Saffari et al. (2009) Data Size

104 105 106

Figure 6. Left: Depth, ground truth body parts and predicted body parts. Right: A candidate feature speciﬁed by two oﬀsets.

Figure 7. Comparison of our online algorithm with Saﬀari et al. (2009) on the kinect application; Our algorithm does signiﬁcantly better with less memory.

same approach as Shotton et al. (2011), our online classiﬁer predicts the body part label of a single pixel P in a depth image. To predict all the labels of a depth image, the classiﬁer is applied to every pixel in parrallel. For our dataset, we generate pairs of 640x480 resolution depth and body part images by rendering random poses from the CMU mocap dataset. The 19 body parts and one background class are represented by 20 unique color identiﬁers in the body part image. Figure 6 (left) visualizes the raw depth image, ground truth body part labels and body parts predicted by our classiﬁer for one pose. During training, we sample 50 pixels without replacement for each body part class from each pose; thus, producing 1000 data points for each depth image. During testing we evaluate the prediction accuracy of all non background pixels as this provides a more informative accuracy metric since most of the pixels are background and are relatively easy to predict. For this experiment we use a stream of 1000 poses for training and 500 poses for testing. Each node of each decision tree computes the depth diﬀerence between two pixels described by two oﬀsets from P (the pixel being classiﬁed). At training time, candidate pairs of oﬀsets are sampled from a 2dimensional Gaussian distributions with variance 75.0. The oﬀsets are scaled by the depth of the pixel P to produce depth invariant features. Figure 6 (right) visualizes a candidate feature for the pixel in the green box. The resulting feature value is the depth diﬀerence between the pixel in the red box and the pixel in the white box. In this experiment we construct a forest of 25 trees with 2000 candidate oﬀsets (λ), 10 candidate splits

(m) and a minimum information gain of 0.01 (τ ). For Saﬀari et al. (2009) we set the number of sample points required to split to 10 and for our own algorithm we set α(d) = 10 · (1.01d ) and β (d) = 4 · α(d). With this parameter setting each active leaf stores 20 · 10 · 2000 · 2 = 400, 000 statistics which requires 1.6MB of memory. By limiting the fringe to 1000 active leaves our algorithm requires 1.6GB of memory for leaf statistics. To limit the maximum memory used by Saﬀari et al. (2009) we set the maximum depth to 8 which uses up to 25 · 28 = 6400 active leaves which requires up to 10GB of memory for leaf statistics. Figure 7 shows that our algorithm achieves signiﬁcantly better accuracy while requiring less memory. However, our algorithm does not do as well when seeing a small number of data points. This is likely a result of separating data points into structure and estimation streams and not including all leaves in the active set.

7. Discussion and Future Work

In this paper we described an algorithm for building online random forests and showed that our algorithm is consistent. To the best of our knowledge this is the ﬁrst consistency result for online random forests. The theory guides certain choices made when designing our algorithm, notably that it is necessary for the leafs in each tree to increase in size over time. Our experiments on simple problems conﬁrm that this requirement is important. Growing trees online in the obvious way requires large amounts of memory, since the trees must be grown breadth ﬁrst and each leaf must store are large num-

935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989

Accuracy

Consistency of Online Random Forests

990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044

ber of statistics related to its potential children. We incorporated a memory management technique from Domingos & Hulten (2000) in order to limit the number of leafs in the fringe of the tree. This reﬁnement is important, since it enables our algorithm to grow large trees. The analysis shows that our algorithm is still consistent with this reﬁnement. Finally, our current algorithm is restricted to axis aligned splits. Many implementations of random forests use more elaborate split shapes, such as random linear or quadratic combinations of features. These strategies can be highly eﬀective in practice, especially in sparse or high dimensional settings. Understanding how to maintain consistency in these settings is another potentially interesting direction of inquiry.

1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099

Consistency of Online Random Forests

1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154

References

H. Abdulsalam. Streaming Random Forests. PhD thesis, Queens University, 2008. G. Biau. Analysis of a Random Forests model. JMLR, 13 (April):1063–1095, 2012. G. Biau, L. Devroye, and G. Lugosi. Consistency of random forests and other averaging classiﬁers. JMLR, 9:2015– 2033, 2008. A. Bifet, G. Holmes, and B. Pfahringer. MOA: Massive Online Analysis, a framework for stream classiﬁcation and clustering. In Workshop on Applications of Pattern Analysis, pp. 3–16, 2010. A. Bifet, E. Frank, G. Holmes, and B. Pfahringer. Ensembles of Restricted Hoeﬀding Trees. ACM Transactions on Intelligent Systems and Technology, 3(2):1–20, February 2012. A. Bifet, G. Holmes, and B. Pfahringer. New ensemble methods for evolving data streams. In ACM SIGKDD Intl. Conference on Knowledge Discovery and Data Mining, 2009. A. Bosch, A. Zisserman, and X. Munoz. Image classiﬁcation using random forests and ferns. In International Conference on Computer Vision, pp. 1–8, 2007. L. Breiman. Random forests. Machine Learning, 45(1): 5–32, 2001. L. Breiman. Consistency for a Simple Model of Random Forests. Technical report, University of California at Berkeley, 2004. L. Breiman, J. Friedman, C. Stone, and R. Olshen. Classiﬁcation and Regression Trees. CRC Press LLC, Boca Raton, Florida, 1984. C. Chang and C. Lin. LIBSVM: A library for support vector machines. ACM Transactions on Intelligent Systems and Technology, 2:27:1–27:27, 2011. G. Cormode. Sketch techniques for approximate query processing. Synposes for Approximate Query Processing: Samples, Histograms, Wavelets and Sketches, Foundations and Trends in Databases, 2011. G. Cormode and S. Muthukrishnan. An improved data stream summary: the count-min sketch and its applications. Journal of Algorithms, 55(1):58–75, April 2005. A. Criminisi, J. Shotton, and E. Konukoglu. Decision forests: A uniﬁed framework for classiﬁcation, regression, density estimation, manifold learning and semisupervised learning. Foundations and Trends in Computer Graphics and Vision, 7(2-3):81–227, 2011. D. Cutler, T. Edwards, and K. Beard. Random forests for classiﬁcation in ecology. Ecology, 88(11):2783–92, November 2007. L. Devroye, L. Gy¨ orﬁ, and G. Lugosi. A Probabilistic Theory of Pattern Recognition. Springer-Verlag, New York,

USA, 1996. P. Domingos and G. Hulten. Mining high-speed data streams. In International Conference on Knowledge Discovery and Data Mining, pp. 71–80. ACM, 2000. J. Gama, P. Medas, and P. Rodrigues. Learning decision trees from dynamic data streams. In ACM symposium on Applied computing, SAC ’05, pp. 573–577, New York, NY, USA, 2005. ACM. T. Hastie, R. Tibshirani, and J. Friedman. The Elements of Statistical Learning. Springer, 10 edition, 2013. H. Ishwaran and U. Kogalur. Consistency of random survival forests. Statistics and Probability Letters, 80:1056– 1064, 2010. Y. Lin and Y. Jeon. Random forests and adaptive nearest neighbors. Technical Report 1055, University of Wisconsin, 2002. N. Meinshausen. Quantile regression forests. JMLR, 7: 983–999, 2006. N. Oza and S. Russel. Online Bagging and Boosting. In Artiﬁcial Intelligence and Statistics, volume 3, 2001. A. Prasad, L. Iverson, and A. Liaw. Newer Classiﬁcation and Regression Tree Techniques: Bagging and Random Forests for Ecological Prediction. Ecosystems, 9(2):181– 199, March 2006. ISSN 1432-9840. A. Saﬀari, C. Leistner, J. Santner, M. Godec, and H. Bischof. On-line random forests. In International Conference on Computer Vision Workshops (ICCV Workshops), pp. 1393–1400. IEEE, 2009. R. Schapire and Y. Freund. Boosting: Foundations and Algorithms. MIT Press, Cambridge, Massachusetts, 2012. J. Shotton, A. Fitzgibbon, M. Cook, T. Sharp, M. Finocchio, R. Moore, A. Kipman, and A. Blake. Real-time human pose recognition in parts from single depth images. CVPR, pp. 1297–1304, 2011. V. Svetnik, A. Liaw, C. Tong, J. Culberson, R. Sheridan, and B. Feuston. Random forest: a classiﬁcation and regression tool for compound classiﬁcation and QSAR modeling. Journal of Chemical Information and Computer Sciences, 43(6):1947–58, 2003.

1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209

Consistency of Online Random Forests

1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264

A. Algorithm pseudo-code

Candidate split dimension A dimension along which a split may be made. Poisson(λ), D) of these when it is created. Candidate split point One of the ﬁrst m structure points to arrive in a leaf. Candidate split A combination of a candidate split dimension and a position along that dimension to split. These are formed by projecting each candidate split point into each candidate split dimension. Candidate children Each candidate split in a leaf induces two candidate children for that leaf. These are also referred to as the left and right child of that split. N e (A) is a count of estimation points in the cell A, and Y e (A) is the histogram of labels of these points in A. N s (A) is a count of structure point in the cell A, and Y s (A) is the histogram of labels of these points in A. Algorithm 1 BuildTree Require: Initially the tree has exactly one leaf (TreeRoot) which covers the whole space Require: The dimensionality of the input, D. Parameters λ, m and τ . SelectCandidateSplitDimensions(TreeRoot, min(1 + Poisson(λ), D)) for t = 1 . . . do Receive (Xt , Yt , It ) from the environment At ← leaf containing Xt if It = estimation then UpdateEstimationStatistics(At , (Xt , Yt )) for all S ∈ CandidateSplits(At ) do for all A ∈ CandidateChildren(S ) do if Xt ∈ A then UpdateEstimationStatistics(A, (Xt , Yt )) end if end for end for else if It = structure then if At has fewer than m candidate split points then for all d ∈ CandidateSplitDimensions(At ) do CreateCandidateSplit(At , d, πd Xt ) end for end if for all S ∈ CandidateSplits(At ) do for all A ∈ CandidateChildren(S ) do if Xt ∈ A then UpdateStructuralStatistics(A, (Xt , Yt )) end if end for end for if CanSplit(At ) then if ShouldSplit(At ) then Split(At ) else if MustSplit(At ) then Split(At ) end if end if end if end for Each leaf selects min(1 +

1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319

Consistency of Online Random Forests

1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374

Algorithm 2 Split Require: A leaf A S ← BestSplit(A) A ← LeftChild(A) SelectCandidateSplitDimensions(A , Poisson(λ), D)) A ← RightChild(A) SelectCandidateSplitDimensions(A , Poisson(λ), D)) return A , A Algorithm 3 CanSplit Require: A leaf A d ← Depth(A) for all S ∈ CandidateSplits(A) do if SplitIsValid(A, S ) then return true end if end for return false

min(1

+

Algorithm 5 MustSplit Require: A leaf A d ← Depth(A) return N e (A) ≥ β (d) Algorithm 6 ShouldSplit Require: A leaf A for all S ∈ CandidateSplits(A) do if InformationGain(S ) > τ then if SplitIsValid(A, S ) then return true end if end if end for return false Algorithm 7 BestSplit Require: A leaf A Require: At least one valid candidate split exists for A best split ← none for all S ∈ CandidateSplits(A) do if InformationGain(A, S ) > InformationGain(A, best split) then if SplitIsValid(A, S ) then best split ← S end if end if end for return best split Algorithm 8 InformationGain Require: A leaf A Require: A split S A ← LeftChild(S ) A ← RightChild(S ) s (A ) s return Entropy(Y s (A))− N N s (A) Entropy(Y (A ))−

N s (A ) N s (A)

min(1

+

Algorithm 4 SplitIsValid Require: A leaf A Require: A split S d ← Depth(A) A ← LeftChild(S ) A ← RightChild(S ) return N e (A ) ≥ α(d) and N e (A ) ≥ α(d)

Entropy(Y s (A ))

Algorithm 9 UpdateEstimationStatistics Require: A leaf A Require: A point (X, Y ) N e (A) ← N e (A) + 1 Y e (A) ← Y e (A) + Y Algorithm 10 UpdateStructuralStatistics Require: A leaf A Require: A point (X, Y ) N s ( A) ← N s ( A) + 1 Y s ( A) ← Y s ( A) + Y

1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429

Consistency of Online Random Forests

1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484

B. Proof of Consistency

B.1. A note on notation A will be reserved for subsets of RD , and unless otherwise indicated it can be assumed that A denotes a cell of the tree partition. We will often be interested in the cell of the tree partition containing a particular point, which we denote A(x). Since the partition changes over time, and therefore the shape of A(x) changes as well, we use a subscript to disambiguate: At (x) is the cell of the partition containing x at time t. Cells in the tree partition have a lifetime which begins when they are created as a candidate child to an existing leaf and ends when they are themselves split into two children. When referring to a point Xτ ∈ At (x) it is understood that τ is restricted to the lifetime of At (x). We treat cells of the tree partition and leafs of the tree deﬁning it interchangeably, denoting both with an appropriately decorated A. N generally refers to the number of points of some type in some interval of time. The various decorations the N receives specify which particular type of point or interval of time is being considered. A superscript always denotes type, so N k refers to a count of points of type k . Two special types, e and s, are used to denote k estimation and structure points, respectively. Pairs of subscripts are used to denote time intervals, so Na,b denotes the number of points of type k which appear during the time interval [a, b]. We also use N as a function e whose argument is a subset of RD in order to restrict the counting spatially: Na,b (A) refers to the number of estimation points which fall in the set A during the time interval [a, b]. We make use of one additional variant of N as a function when its argument is a cell in the partition: when we write N k (At (x)), without subscripts on N , the interval of time we count over is understood to be the lifetime of the cell At (x). B.2. Preliminaries Lemma 6. Suppose we partition a stream of data into c parts by assigning each point (Xt , Yt ) to part It ∈ {1, . . . , c} with ﬁxed probability pk , meaning that

b k Na,b = t=a k Then with probability 1, Na,b → ∞ for all k ∈ {1, . . . , c} as b − a → ∞.

I {It = k } .

(1)

Proof. Note that P (It = 1) = p1 and these events are independent for each t. By the second Borel-Cantelli lemma, the probability that the events in this sequence occur inﬁnitely often is 1. The cases for It ∈ {2, . . . , c} are similar. Lemma 7. Let Xt be a sequence of iid random variables with distribution µ, let A be a ﬁxed set such that µ(A) > 0 and let {It } be a ﬁxed partitioning sequence. Then the random variable

k Na,b ( A) = a≤t≤b:It =k k is Binomial with parameters Na,b and µ(A). In particular, k P Na,b (A) ≤

I {Xt ∈ A}

µ(A) k Na,b 2

≤ exp −

µ(A)2 k Na,b 2

k which goes to 0 as b − a → ∞, where Na,b is the deterministic quantity deﬁned as in Equation 1. k Proof. Na,b (A) is a sum of iid indicator random variables so it is Binomial. It has the speciﬁed parameters k k k because it is a sum over Na,b elements and P (Xt ∈ A) = µ(A). Moreover, E Na,b (A) = µ(A)Na,b so by Hoeﬀding’s inequality we have that k k k k k k P Na,b (A) ≤ E Na,b (A) − Na,b = P Na,b (A) ≤ Na,b (µ(A) − ) ≤ exp −2 2 Na,b

.

Setting

=

1 2 µ(A)

gives the desired result.

1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539

Consistency of Online Random Forests

1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594

B.3. Proof of Proposition 2 Proof. Let g (x) denote the Bayes classiﬁer. Consistency of {gt } is equivalent to saying that E [L(gt )] = P (gt (X, Z ) = Y ) → L∗ . In fact, since P (gt (X, Z ) = Y | X = x) ≥ P (g (X ) = Y | X = x) for all x ∈ RD , consistency of {gt } means that for µ-almost all x, P (gt (X, Z ) = Y | X = x) → P (g (X ) = Y | X = x) = 1 − max{η k (x)}

k

Deﬁne the following two sets of indices G = {k | η k (x) = max{η k (x)}} ,

k

B = {k | η k (x) < max{η k (x)}} .

k

Then P (gt (X, Z ) = Y | X = x) =

k

P (gt (X, Z ) = k | X = x) P (Y = k |X = x) P (gt (X, Z ) = k | X = x) +

k ∈G (M ) k ∈B

≤ (1 − max{η k (x)})

k

P (gt (X, Z ) = k | X = x) ,

which means it suﬃces to show that P gt

(X, Z M ) = k | X = x → 0 for all k ∈ B . However, using Z M to

denote M (possibly dependent) copies of Z , for all k ∈ B ,

M

M c=k

I {gt (x, Zj ) = c}

P gt

(M )

(x, Z M ) = k = P

j =1

I {gt (x, Zj ) = k } > max

j =1 M

≤ P

I {gt (x, Zj ) = k } ≥ 1

j =1

By Markov’s inequality, ≤ E

j =1 M

I {gt (x, Zj ) = k }

= M P (gt (x, Z ) = k ) → 0

B.4. Proof of Proposition 3 Proof. The sequence in question is uniformly integrable, so it is suﬃcient to show that E [P (gt (X, Z, I ) = Y | I )] → L∗ implies the result, where the expectation is taken over the random selection of training set. We can write P (gt (X, Z, I ) = Y ) = E [P (gt (X, Z, I ) = Y | I )] =

I

P (gt (X, Z, I ) = Y | I ) ν (I ) +

Ic

P (gt (X, Z, I ) = Y | I ) ν (I )

By assumption ν (I c ) = 0, so we have lim P (gt (X, Z, I ) = Y ) = lim P (gt (X, Z, I ) = Y | I ) ν (I )

I

t→∞

t→∞

1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649

Consistency of Online Random Forests

1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704

Since probabilities are bounded in the interval [0, 1], the dominated convergence theorem allows us to exchange the integral and the limit, = lim P (gt (X, Z, I ) = Y | I ) ν (I )

I t→∞

and by assumption the conditional risk converges to the Bayes risk for all I ∈ I , so = L∗

I

ν (I )

= L∗ which proves the claim. B.5. Proof of Proposition 4 Proof. By deﬁnition, the rule g (x) = arg max{η k (x)}

k

(where ties are broken in favour of smaller k ) achieves the Bayes risk. In the case where all the η k (x) are equal there is nothing to prove, since all choices have the same probability of error. Therefore, suppose there is at least one k such that η k (x) < η g(x) (x) and deﬁne m(x) = η g(x) (x) − max{η k (x) | η k (x) < η g(x) (x)}

k k

m t ( x) = η t

g ( x)

k (x) − max{ηt (x) | η k (x) < η g(x) (x)}

The function m(x) ≥ 0 is the margin function which measures how much better the best choice is than the second best choice, ignoring possible ties for best. The function mt (x) measures the margin of gt (x). If mt (x) > 0 then gt (x) has the same probability of error as the Bayes classiﬁer. The assumption above guarantees that there is some classes, by making t large we can satisfy such that m(x) > . Using C to denote the number of

k P |ηt (X ) − η k (X )| < /2 ≥ 1 − δ/C k since ηt is consistent. Thus C C k |ηt (X ) − η k (X )| < /2 k=1

P

≥1−K +

k=1

k P |ηt (X ) − η k (X )| < /2 ≥ 1 − δ

So with probability at least 1 − δ we have mt (X ) = ηt

g (X ) k − max{ηt (X ) | η k (X ) < η g(X ) (X )} k k − /2) − max{ηt (X ) + /2 | η k (X ) < η g(x) (X )} k

≥ (η

g (X )

= η g(X ) − max{η k (X ) | η k (X ) < η g(X ) (X )} −

k

= m(X ) − >0 Since δ is arbitrary this means that the risk of gt converges in probability to the Bayes risk.

1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759

Consistency of Online Random Forests

1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814

d

A A

A A

A A

Figure 8. This Figure shows the setting of Proposition 8. Conditioned on a partially built tree we select an arbitrary leaf at depth d and an arbitrary candidate split in that leaf. The proposition shows that, assuming no other split for A is selected, we can guarantee that the chosen candidate split will occur in bounded time with arbitrarily high probability.

B.6. Proof of Theorem 1 The proof of Theorem 1 is built in several pieces. Proposition 8. Fix a partitioning sequence. Let t0 be a time at which a split occurs in a tree built using this sequence, and let gt0 denote the tree after this split has been made. If A is one of the newly created cells in gt0 then we can guarantee that the cell A is split before time t > t0 with probability at least 1 − δ by making t suﬃciently large. Proof. Let d denote the depth of A in the tree gt0 and note that µ(A) > 0 with probability 1 since X has a density. This situation is illustrated in Figure 8. By construction, if the following conditions hold: 1. For some candidate split in A, the number of estimation points in both children is at least α(d), 2. The number of estimation points in A is at least β (d), then the algorithm must split A when the next structure point arrives. Thus in order to force a split we need the following sequence of events to occur: 1. A structure point must arrive in A to create a candidate split point. 2. The above two conditions must be satisﬁed. 3. Another structure point must arrive in A to force a split. It is possible for a split to be made before these events occur, but assuming a split is not triggered by some other mechanism we can guarantee that this sequence of events will occur in bounded time with high probability. Suppose a split is not triggered by a diﬀerent mechanism. Deﬁne E0 to be an event that occurs at t0 with probability 1, and let E1 ≤ E2 ≤ E3 be the times at which the above numbered events occur. Each of these events requires the previous one to have occurred and moreover, the sequence has a Markov structure, so for t0 ≤ t1 ≤ t2 ≤ t3 = t we have P (E1 ≤ t ∩ E2 ≤ t ∩ E3 ≤ t | E0 = t0 ) ≥ P (E1 ≤ t1 ∩ E2 ≤ t2 ∩ E3 ≤ t3 | E0 = t0 ) = P (E1 ≤ t1 | E0 = t0 ) P (E2 ≤ t2 | E1 ≤ t1 ) P (E3 ≤ t3 | E2 ≤ t2 ) ≥ P (E1 ≤ t1 | E0 = t0 ) P (E2 ≤ t2 | E1 = t1 ) P (E3 ≤ t3 | E2 = t2 ) . We can rewrite the ﬁrst and last term in more friendly notation as P (E1 ≤ t1 | E0 = t0 ) = P Nts0 ,t1 (A) ≥ 1 P (E3 ≤ t3 | E2 = t2 ) = P Nts2 ,t3 (A) ≥1 , .

1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869

Consistency of Online Random Forests

1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924

E0 t0 t1 − t0

E1 t2 − t1

E2 t3 − t2

E3 t

Figure 9. This Figure diagrams the structure of the argument used in Propositions 8 and 9. The indicated intervals are show regions where the next event must occur with high probability. Each of these intervals is ﬁnite, so their sum is also ﬁnite. We ﬁnd an interval which contains all of the events with high probability by summing the lengths of the intervals for which we have individual bounds.

Lemma 7 allows us to lower bound both of these probabilities by 1 − for any > 0 by making t1 − t0 and t3 − t2 large enough that Nts0 ,t1 ≥ and Nts2 ,t3 ≥ 2 max 1, µ(A)−1 log µ(A) 1 2 max 1, µ(A)−1 log µ(A) 1

respectively. To bound the centre term, recall that µ(A ) > 0 and µ(A ) > 0 with probability 1, and β (d) ≥ α(d) so P (E2 ≤ t2 | E1 = t1 ) ≥ P Nte1 ,t2 (A ) ≥ β (d) ∩ Nte1 ,t2 (A ) ≥ β (d) ≥ P Nte1 ,t2 (A ) ≥ β (d) + P Nte1 ,t2 (A ) ≥ β (d) − 1 , and we can again use Lemma 7 lower bound this by 1 − by making t2 − t1 suﬃciently large that Nte1 ,t2 ≥ 2 max β (d), min{µ(A ), µ(A )}−1 log min{µ(A ), µ(A )} 2

Thus by setting make

= 1 − (1 − δ )1/3 can ensure that the probability of a split before time t is at least 1 − δ if we

t = t0 + (t1 − t0 ) + (t2 − t1 ) + (t3 − t2 ) suﬃciently large. Proposition 9. Fix a partitioning sequence. Each cell in a tree built based on this sequence is split inﬁnitely often in probability. i.e for any x in the support of X , P (At (x) has been split fewer than K times) → 0 as t → ∞ for all K . Proof. For an arbitrary point x in the support of X , let Ek denote the time at which the cell containing x is split for the k th time, or inﬁnity if the cell containing x is split fewer than k times (deﬁne E0 = 0 with probability 1). Now deﬁne the following sequence: t0 = 0 ti = min{t | P (Ei ≤ t | Ei−1 = ti−1 ) ≥ 1 − }

1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979

Consistency of Online Random Forests

1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034

and set Tδ = tk . Proposition 8 guarantees that each of the above ti ’s exists and is ﬁnite. Compute,

k

P (Ek ≤ Tδ ) = P

k

[Ei ≤ Tδ ]

i=1

≥P

k

[Ei ≤ ti ]

i=1

P Ei ≤ ti |

j<i

[Ej ≤ tj ]

=

i=1 k

=

i=1 k

P (Ei ≤ ti | Ei−1 ≤ ti−1 ) P (Ei ≤ ti | Ei−1 = ti−1 )

i=1

≥

≥ (1 − )k where the last line follows from the choice of ti ’s. Thus for any δ > 0 we can choose Tδ to guarantee P (Ek ≤ Tδ ) ≥ 1 − δ by setting = 1 − (1 − δ )1/k and applying the above process. We can make this guarantee for any k which allows us to conclude that P (Ek ≤ t) → 1 as t → ∞ for all k as required. Proposition 10. Fix a partitioning sequence. Let At (X ) denote the cell of gt (built based on the partitioning sequence) containing the point X . Then diam(At (X )) → 0 in probability as t → ∞. Proof. Let Vt (x) be the size of the ﬁrst dimension of At (x). It suﬃces to show that E [Vt (x)] → 0 for all x in the support of X . Let X1 , . . . , Xm ∼ µ|At (x) for some 1 ≤ m ≤ m denote the samples from the structure stream that are used to determine the candidate splits in the cell At (x). Use πd to denote a projection onto the dth coordinate, and without loss of generality, assume that Vt = 1 and π1 Xi ∼ Uniform[0, 1]. Conditioned on the event that the ﬁrst dimension is cut, the largest possible size of the ﬁrst dimension of a child cell is bounded by V ∗ = max(max π1 Xi , 1 − min π1 Xi ) .

i=1 i=1 m m

Recall that we choose the number of candidate dimensions as min(1 + Poisson(λ), D) and select that number of distinct dimensions uniformly at random to be candidates. Deﬁne the following events: E1 = {There is exactly one candidate dimension} E2 = {The ﬁrst dimension is a candidate} Then using V to denote the size of the ﬁrst dimension of the child cell, E [V ] ≤ E [I {(E1 ∩ E2 )c } + I {E1 ∩ E2 } V ∗ ]

c c = P (E1 ) + P (E2 |E1 ) P (E1 ) + P (E2 |E1 ) P (E1 ) E [V ∗ ] 1 1 = (1 − e−λ ) + (1 − )e−λ + e−λ E [V ∗ ] d d e −λ e−λ =1− + E [V ∗ ] D D m e −λ e−λ m =1− + E max(max π1 Xi , 1 − min π1 Xi ) i=1 i=1 D D

=1−

e −λ e−λ 2m + 1 + · D D 2m + 2 e −λ =1− 2D(m + 1)

2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089

Consistency of Online Random Forests

2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144

Iterating this argument we have that after K splits the expected size of the ﬁrst dimension of the cell containing x is upper bounded by e −λ 1− 2D(m + 1)

K

so it suﬃces to have K → ∞ in probability, which we know to be the case from Proposition 9. Proposition 11. Fix a partitioning sequence. In any tree built based on this sequence, N e (At (X )) → ∞ in probability. Proof. It suﬃces to show that N e (At (x)) → ∞ for all x in the support of X . Fix such an x, by Proposition 9 we can make the probability At (x) is split fewer than K times arbitrarily small for any K . Moreover, by construction immediately after the K -th split is made the number of estimation points contributing to the prediction at x is at least α(K ), and this number can only increase. Thus for all K we have that P (N e (At (x)) < α(K )) → 0 as t → ∞ as required. We are now ready to prove our main result. All the work has been done, it is simply a matter of assembling the pieces. Proof (of Theorem 1). Fix a partitioning sequence. Conditioned on this sequence the consistency of each of the class posteriors follows from Theorem 5. The two required conditions where shown to hold in Propositions 10 and 11. Consistency of the multiclass tree classiﬁer then follows by applying Proposition 4. To remove the conditioning on the partitioning sequence, note that Lemma 6 shows that our tree generation mechanism produces a partitioning sequence with probability 1. Apply Proposition 3 to get unconditional consistency of the multiclass tree. Proposition 2 lifts consistency of the trees to consistency of the forest, establishing the desired result. B.7. Extension to a Fixed Size Fringe Proving consistency is preserved with a ﬁxed size fringe requires more precise control over the relationship between the number of estimation points seen in an interval, Nte0 ,t , and the total number of splits which have occurred in the tree, K . The following two lemmas provide the control we need. Lemma 12. Fix a partitioning sequence. If K is the number of splits which have occurred at or before time t then for all M > 0 P (K ≤ M ) → 0 in probability as t → ∞. Proof. Denote the fringe at time t with Ft which has max size |F |, and the set of leafs at time t as Lt with size |Lt |. If |Lt | < |F | then there is no change from the unbounded fringe case, so we assume that |Lt | ≥ |F | so that for all t there are exactly |F | leafs in the fringe. Suppose a leaf A1 ∈ Ft0 for some t0 then for every δ > 0 there is a ﬁnite time t1 such that for all t ≥ t1 P (A1 has not been split before time t) ≤ δ |F |

Now ﬁx a time t0 and δ > 0. For each leaf Ai ∈ Ft0 we can choose ti to satisfy the above bound. Set t = maxi ti then the union bound gives P (K ≤ |F | at time t) ≤ δ

2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199

Consistency of Online Random Forests

2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254

Iterate this argument M/|F | times with δ = / M/|F | and apply the union bound again to get that for suﬃciently large t P (K ≤ M ) ≤ for any > 0.

Lemma 13. Fix a partitioning sequence. If K is the number of splits which have occurred at or before time t then for any t0 > 0, K/Nte0 ,t → 0 as t → ∞.

e e Proof. First note that Nte0 ,t = N0 ,t − N0,t0 −1 so

K K = e e Nte0 ,t N0,t − N0 ,t0 −1

e e and since N0 ,t0 −1 is ﬁxed it is suﬃcient to show that K/N0,t → 0. In the following we write N = N0,t to lighten the notation.

Deﬁne the cost of a tree T as the minimum value of N required to construct a tree with the same shape as T . The cost of the tree is governed by the function α(d) which gives the cost of splitting a leaf at level d. The cost of a tree is found by summing the cost of each split required to build the tree. Note that no tree on K splits is cheaper than a tree of max depth d = log2 (K ) with all levels full (except possibly the last, which may be partially full). This is simple to see, since α(d) is an increasing function of d, meaning it is never more expensive to add a node at a lower level than a higher one. Thus we assume wlog that the tree is full except possibly in the last level. When ﬁlling the dth layer of the tree, each split requires at least 2α(d + 1) points because a split creates two new leafs at level d + 1. This means that for K in the range [2d , 2d+1 − 1] (the range of splits which ﬁll up level d), K can increase at a rate which is at most 1/2α(d + 1) with respect to N . This also tells us that ﬁlling the dth level of the tree requires that N increase by at least 2d α(d) = 2d−1 · 2α(d) (ﬁlling the dth level corresponds to splitting each of the 2d−1 leafs on the d − 1th level at a cost of 2α(d) each). This means that ﬁlling d levels of the tree requires at least

d

Nd =

k=1 d

2k α(k )

points. When N = Nd , K is at most 2 − 1 because that is the number of splits in a full binary tree of depth d. The above argument gives a collection of linear upper bounds on K in terms of N . We know that the maximum growth rate is linear between (Nd , 2d − 1) and (Nd+1 , 2d+1 − 1) so for all d we can ﬁnd that since (2d+1 − 1) − (2d − 1) = (Nd+1 ) − (Nd ) we have that for N and d, K≤ where C (d) is given by C (d) = 2d − 1 − From this we have K 1 1 ≤ + N 2α(d + 1) N 2d − 1 − 1 2

d

2d+1 − 2d

d+1 k=1

2k α (k ) −

d k=1

2k α(k )

=

2d 1 = 2d+1 α(d + 1) 2α(d + 1)

1 N + C (d) 2α(d + 1)

d

1 2

2k

k=1

α (k ) α(d + 1)

2k

k=1

α(k ) α(d + 1)

which holds for all d and N , so if we choose d to make 1/α(d + 1) ≤ δ/2 and then pick N such that C (d)/N ≤ δ/2 we have K/N ≤ δ for arbitrary δ > 0 which proves the claim.

2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309

Consistency of Online Random Forests

2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364

K 23 − 1

1 2α(3) 1 2α(2)

2 −1 C (2) 21 − 1

1 2α(1)

2

0

e N0 ,t

Figure 10. Diagram of the bound in Lemma 13. The horizontal axis is the number of estimation points seen at time t and the vertical axis is the number of splits. The ﬁrst bend is the earliest point at which the root of the tree could be split, which requires 2α(1) points to create 2 new leafs at level 1. Similarly, the second bend is the point at which all leafs at level 1 have been split, each of which requires at least 2α(2) points to create a pair of leafs at level 2.

In order to show that our algorithm remains consistent with a ﬁxed size fringe we must ensure that Proposition 8 does not fail in this setting. Interpreted in the context of a ﬁnite fringe, Proposition 8 says that any cell in the fringe will be split in ﬁnite time. This means that to ensure consistency we need only show that any inactive point will be added to the fringe in ﬁnite time. Remark 14. If s(A) = 0 for any leaf then we know that e(A) = 0, since µ(A) > 0 by construction. If e(A) = 0 then P (g (X ) = Y | X ∈ A) = 0 which means that any subdivision of A has the same asymptotic probability of error as leaving A in tact. Our rule never splits A and thus fails to satisfy the shrinking leaf condition, but our predictions are asymptotically the same as if we had divided A into arbitrarily many pieces so this doesn’t matter. Proposition 15. Every leaf with s(A) > 0 will be added to the fringe in ﬁnite time with high probability. Proof. Pick an arbitrary leaf A. We know from Hoeﬀding’s inequality that P (ˆ p(A) ≤ µ(A) − ) ≤ exp −2|A| and P (ˆ p(A) ≥ µ(A) + ) ≤ exp −2|A|

2 2

≤ exp −2α(d)

2

≤ exp −2α(d)

2

Now pick an arbitrary time t0 and condition on everything before t0 . For an arbitrary node A ⊂ RD , if A is a child of A then we know that if {Ui }Dm i=1 are iid on [0, 1] then E [µ(A )] ≤ µ(A)E max(max(Ui , 1 − Ui ))

i=1 Dm

= µ(A)

2Dm + 1 2Dm + 2

since there are at most D candidate dimensions and each one accumulates at most m candidate splits. So if AK is any leaf created by K splits of A then E µ(AK ) ≤ µ(A) Notice that since we have conditioned on the tree at t0 so, E p ˆ(AK ) = E E p ˆ(AK ) | µ(AK ) = E µ(AK ) 2Dm + 1 2Dm + 2

K

2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419

Consistency of Online Random Forests

2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474

And we can bound p ˆ(AK ) with P p ˆ(AK ) ≥ µ(A) Set (2K +1 |L|)−1 δ = exp −2|AK |

2

2Dm + 1 2Dm + 2

K

+

≤ exp −2|AK |

2

and invert the bound so we have 2Dm + 1 2Dm + 2

K

P p ˆ(AK ) ≥ µ(A)

+

1 log 2|AK |

2K +1 |L| δ

≤

δ 2K +1 |L|

Pick an arbitrary leaf A0 which is in the tree at time t0 . We can use the same approach to ﬁnd a lower bound on s ˆ(A0 ): P s ˆ(A0 ) ≤ s(A0 ) − 1 log 2|A0 | 2K +1 |L| δ ≤ δ 2K +1 |L|

To ensure that s ˆ(A0 ) ≥ p ˆ(AK ) (≥ s ˆ(AK )) fails to hold with probability at most δ 2−K |L|−1 we must choose k and t to make s(A0 ) ≥ µ(A) 2Dm + 1 2Dm + 2

K

+

1 log 2|AK |

2K +1 |L| δ

+

1 log 2|A0 |

2K +1 |L| δ

The ﬁrst term goes to 0 as K → ∞. We know that |AK | ≥ α(K ) so the second term also goes to 0 provided that K/α(K ) → 0, which we require. The third term goes to 0 if K/|A0 | → 0. Recall that |A0 | = Nte0 ,t (A0 ) and for any γ > 0 P Nte0 ,t (A) ≤ Nte0 ,t µ(A) − 1 log 2Nte0 ,t 1 γ ≤γ

From this we see it is suﬃcient to have K/Nte0 ,t → 0 which we established in a lemma. In summary, there are |L| leafs in the tree at time t0 and each of them generates at most 2K diﬀerent AK ’s. Union bounding over all these leafs and over the probability of Nte0 ,t (A0 ) growing sublinearly in Nte0 ,t we have that, conditioned on the event that A0 has not yet been split, A0 is the leaf with the highest value of s ˆ with probability at least 1 − δ − γ in ﬁnite time. Since δ and γ are arbitrary we are done.

2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529