train.randomForest | R Documentation |
Provides a wrapping function for the randomForest
.
train.randomForest(formula, data, ..., subset, na.action = na.fail)
formula |
a formula describing the model to be fitted (for the print method, an randomForest object). |
data |
an optional data frame containing the variables in the model. By default the variables are taken from the environment which randomForest is called from. |
... |
optional parameters to be passed to the low level function randomForest.default. |
subset |
an index vector indicating which rows should be used. (NOTE: If given, this argument must be named.) |
na.action |
A function to specify the action to be taken if NAs are found. (NOTE: If given, this argument must be named.) |
A object randomForest.prmdt with additional information to the model that allows to homogenize the results.
the parameter information was taken from the original function randomForest
.
The internal function is from package randomForest
.
# Classification data("iris") n <- seq_len(nrow(iris)) .sample <- sample(n, length(n) * 0.75) data.train <- iris[.sample,] data.test <- iris[-.sample,] modelo.rf <- train.randomForest(Species~., data.train) modelo.rf prob <- predict(modelo.rf, data.test, type = "prob") prob prediccion <- predict(modelo.rf, data.test, type = "class") prediccion # Regression len <- nrow(swiss) sampl <- sample(x = 1:len,size = len*0.20,replace = FALSE) ttesting <- swiss[sampl,] ttraining <- swiss[-sampl,] model.rf <- train.randomForest(Infant.Mortality~.,ttraining) prediction <- predict(model.rf, ttesting) prediction
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.