O'Reilly logo

R Statistical Application Development by Example Beginner's Guide by Prabhanjan Narayanachar Tattar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – random forests for the German credit data

The function randomForest from the package of the same name will be used to build a random forest for the German credit data problem.

  1. Get the randomForest package by using library(randomForest).
  2. Load the German credit data by using data(GC).
  3. Create a random forest with 500 trees:
    GC_RF <- randomForest(good_bad~.,data=GC,keep.forest=TRUE, ntree=500). 

    It is very difficult to visualize a single tree of the random forest. A very ad-hoc approach has been found at http://stats.stackexchange.com/questions/2344/best-way-to-present-a-random-forest-in-a-publication. Now we reproduce the necessary function to get the trees, and as the solution step is not exactly perfect, you may skip this part; steps ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required