R Data Analysis Cookbook, Second Edition - Second Edition
by Kuntal Ganguly, Davor Lozić, Mzabalazo Z. Ngwenya, Andrew Bauman, Shanthi Viswanathan, Viswa Viswanathan
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access