R/randomForest.model.R

randomForest.model <- function(preProcess = NULL,
                               description = NULL, ...)
{
  library(randomForest)

  function()
  {
    model.name <- "randomForest"
    model_ <- NULL

    train_ <- function(X_train, y)
    {
      model_ <<- randomForest(x = X_train, y, ...)
      invisible()
    }

    predict_ <- function(X_test)
    {
      predictions <- predict(model_, X_test, type="prob")
      predictions <- rename.prediction.columns(predictions, model.name)
      predictions
    }

    list(
      train_ = train_,
      predict_ = predict_,
      name = model.name,
      description = description
    )
  }
}
rladeira/stacking documentation built on May 27, 2019, 9:28 a.m.