Data science, statistics or machine learning in broken English

Random Forest is still one of the strongest supervised learning methods although these days many people love to use Deep Learning or Convolutional NN. Of course because it's simple architecture and a lot of implementation in various environments or languages, e.g. Python, R.

The point I wanna emphasize here is that Random Forest is also a strong method for not only classification but also estimation of variable importance, derived from its origin, decision / regression tree.

A brief trial on a short version of MNIST datasets

Below is a result on the short hold-out version of MNIST data. In this example I only tuned the number of variables of Random Forest using tuneRF() function, but the result was great.

This took much shorter time but its performance great and better than SVM or NN. Accuracy 0.953 on this hold-out MNIST dataset is almost the same as Deep Learning implemented in H2O. You can easily understand why many people love to use Random Forest.

Algorithm summary

(b) Grow a random-forest tree to the bootstrapped data, by recursively repeating the following steps for each terminal node of the tree, until the minimum node size is reached.

i. Select variables at random from the variables.

ii. Pick the best variable/split-point among the .

iii. Split the node into two daughter nodes.

2. Output the ensemble of trees .

To make a prediction at a new point :

Regression:

Classification: Let be the class prediction of the th random-forest tree. Then .

In short, Random Forest is one of bagging methods. Unlike the other bagging methods, its weak classifier is a "de-correlated" decision / regression tree, in order to decrease correlation between subspaces and to avoid overfitting.

I think a schematic figure above well explains how Random Forest works. At any rate, the algorithm generates a lot of weak decision / regression trees and finally their outputs are converged with a certain prefixed rule. Its consequent output would be less overfitted and well generalized, as assumed.

How it works on XOR patterns and linearly separable patterns

OK, let's see what kind of decision boundaries Random Forest draws. In case of XOR patterns, run as below.

Yes, just empirically (from my own experience) it has been known that Random Forest sometimes overfits more than expected. In the case of 2D XOR patterns the number of variables ("mtry" here) is just 2 so tuning on independent variables almost never works, but in many cases it would work very efficiently.

In R, you can easily tune it with tuneRF() function in order to decide an optimal value of "mtry" and you can use it in randomForest() function with "mtry" argument. In the example with a hold-out MNIST dataset above, "mtry" was 56 out of 784.

On the other hand, let's see how RF works on linearly separable datasets.

LOL neither decision boundaries go along with the assumed true boundaries. I think this characteristic of Random Forest may be derived from that of Decision Tree. It means that even Random Forest has difficulty in classification on linearly separable patterns.

Conclusions

Important lessons learned here are as follows:

Random Forest performs very well in general, comparable with even Deep Learning

Tuning on "mtry" parameter is important

RF seems to easily get overfitted

Similar to Decision Tree, RF is bad at classifying linearly separable patterns

Although there are some disadvantages in RF, many people really love to apply it to real-world data... for example user classification in CRM systems or customer targeting in demand-side platform (DSP) of Internet ads. Its algorithm is much simple and easy to implement, so many engineers implement it not only with packages or libraries but also from scratch.

...OK, in the next post will be the final one on supervised classifier - I'll write about Xgboost (eXtreme Gradient Boosting) that is currently the most popular classifier in Kaggle or other ML competitions.