Book Image

Hands-On Ensemble Learning with R

By : Prabhanjan Narayanachar Tattar
Book Image

Hands-On Ensemble Learning with R

By: Prabhanjan Narayanachar Tattar

Overview of this book

Ensemble techniques are used for combining two or more similar or dissimilar machine learning algorithms to create a stronger model. Such a model delivers superior prediction power and can give your datasets a boost in accuracy. Hands-On Ensemble Learning with R begins with the important statistical resampling methods. You will then walk through the central trilogy of ensemble techniques – bagging, random forest, and boosting – then you'll learn how they can be used to provide greater accuracy on large datasets using popular R packages. You will learn how to combine model predictions using different machine learning algorithms to build ensemble models. In addition to this, you will explore how to improve the performance of your ensemble models. By the end of this book, you will have learned how machine learning algorithms can be combined to reduce common problems and build simple efficient ensemble models with the help of real-world examples.
Table of Contents (17 chapters)
Hands-On Ensemble Learning with R
Contributors
Preface
12
What's Next?
Index

Clustering with Random Forest


Random forests can be set up without the target variable. Using this feature, we will calculate the proximity matrix and use the OOB proximity values. Since the proximity matrix gives us a measure of closeness between the observations, it can be converted into clusters using hierarchical clustering methods.

We begin with the setup of y = NULL in the randomForest function. The options of proximity=TRUE and oob.prox=TRUE are specified to ensure that we obtain the required proximity matrix:

>data(multishapes)
>par(mfrow=c(1,2))
>plot(multishapes[1:2],col=multishapes[,3], 
+      main="Six Multishapes Data Display")
> MS_RF <- randomForest(x=multishapes[1:2],y=NULL,ntree=1000,
+ proximity=TRUE, oob.prox=TRUE,mtry = 1)

Next, we use the hclust function with the option of ward.D2 to carry out the hierarchical cluster analysis on the proximity matrix of dissimilarities. The cutree function divides the hclust object into k = 6 number of clusters. Finally...