R/trainRF.R

Defines functions trainRF

trainRF <- function(data,
                    mtry = NULL,
                    ntree = 500,
                    nodesize = 1) {

  result <- SDMmodel(data = data)

  if (is.null(mtry))
    mtry <- floor(sqrt(ncol(data@data)))

  x <- data@data
  p <- data@pa
  model <- randomForest::randomForest(x = x,
                                      y = as.factor(p),
                                      mtry = mtry,
                                      ntree = ntree)

  model_object <- RF(mtry = model$mtry,
                     ntree = model$ntree,
                     nodesize = nodesize,
                     model = model)

  result@model <- model_object

  result
}

Try the SDMtune package in your browser

Any scripts or data that you put into this service are public.

SDMtune documentation built on July 9, 2023, 6:03 p.m.