train.randomForest: train.randomForest

View source: R/train.R

train.randomForestR Documentation

train.randomForest

Description

Provides a wrapping function for the randomForest.

Usage

train.randomForest(formula, data, ..., subset, na.action = na.fail)

Arguments

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.)

Value

A object randomForest.prmdt with additional information to the model that allows to homogenize the results.

Note

the parameter information was taken from the original function randomForest.

See Also

The internal function is from package randomForest.

Examples


# 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


PROMiDAT/trainR documentation built on Nov. 13, 2023, 3:20 a.m.