O'Reilly logo

R Data Analysis Cookbook - Second Edition by Kuntal Ganguly

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

How it works...

Steps 1 and 2 load the necessary packages and read the data.

Step 3 partitions the data. Refer to the Creating random data partitions recipe in Chapter 2, What's in There? - Exploratory Data Analysis, for more details. We set the random seed to enable you to match your results with those that we have displayed. Technically speaking, we do not really need to partition the data for random forests because it builds many trees and uses only a subset of the data each time. Thus, each case is OOB for about a third of the trees built and can be used for validation. However, the method also allows us to provide a validation dataset separately, and we illustrate that process here.

Step 4 builds the random forest model. We show the ...

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