вес в расширенном каретном случайном лесу - PullRequest
0 голосов
/ 28 мая 2020
require(mlbench)
require(e1071)
require (caret)
customRF <- list(type = "Classification", library = "randomForest", loop = NULL)
customRF$parameters <- data.frame(parameter = c("mtry", "ntree","nodesize","maxnodes"
                                                ), 
                                  class = rep("numeric", 4), 
                                  label = c("mtry", "ntree","nodesize","maxnodes"))
customRF$grid <- function(x, y, len = NULL, search = "grid") {}
customRF$fit <- function(x, y, wts, param, lev, last, weights, classProbs, ...) {
  randomForest(x, y, mtry = param$mtry, ntree=param$ntree,nodesize=param$nodesize,maxnodes=param$maxnodes,...)
}
customRF$predict <- function(modelFit, newdata, preProc = NULL, submodels = NULL)
   predict(modelFit, newdata)
customRF$prob <- function(modelFit, newdata, preProc = NULL, submodels = NULL)
   predict(modelFit, newdata, type = "prob")
customRF$sort <- function(x) x[order(x[,1]),]
customRF$levels <- function(x) x$classes 

С расширением каретки для модели случайного леса я ищу, как мы можем добавить список весов в поисковую сетку. например weights = list (c (1,1), c (1,3), c (1,5)) # c (1,3) 1 для R и 3 для класса M

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...