Description Usage Arguments Value Examples
rfMod uses the randomForest function of the package randomForest. rfMod allows to launch a random forest for classification and regression while choosing a column of cross-validation and specifying a grid of hyperparameters.
1 2 3 4 |
x |
|
y |
|
cvcol |
|
ntree |
|
mtry |
|
maxnodes |
|
nodesize |
|
criterion |
|
A list containing :
response variable (y)
predicted values (yp)
the cross-validation column (cvcol)
the optimized parameters (ntree, mtry, maxnodes, nodesize)
the criteria (RMSE, R2, MAPE, AUC...)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | data(mtcars)
#Creation of cross-validation column :
set.seed(1234)
cv <- sample(1:8, nrow(mtcars), replace = TRUE)
#Data
y <- "mpg"
ycolumnindex <- names(mtcars) == "mpg"
x <- mtcars[, !ycolumnindex]
y <- mtcars[, ycolumnindex]
rfMod(x = x, y = y, cvcol= cv,
ntree= c(50, 100), mtry = c(3,4),
nodesize = c(3, 4, 5), criterion = "RMSE")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.