Packages and settings – R and Python
As this chapter reviews some of the techniques in the latter half of the book, we need lot of packages and functions:
- First, set the working directory:
setwd("MyPath/R/Chapter_10")
Load the required R package:
library(boot) library(RSADBE) library(ipred) library(randomForest) library(rpart) library(rattle)
We will only develop the bagging and random forest in Python.
- A lot of functions are required to set up the bagging and random forest method in Python:
Improving the CART
In the Another look at model assessment section of Chapter 8, Regression Models with Regularization, we saw that the technique of train, validate, and test may be further enhanced by using the cross-validation technique. In the case of the linear regression model, we used the CVlm
function from the DAAG
package for the purpose of cross-validation of linear models. The cross-validation technique for the logistic regression models may be carried out by using the CVbinary
...