zachmayer / caretEnsemble

caret models all the way down :turtle:
Other
226 stars 75 forks source link

using custom caret model with caretEnsemble. How? #169

Closed farbodr closed 1 year ago

farbodr commented 8 years ago

caretEnsemble seems to check for model name in caretList and it doesn't like model names that are not returned by caret. Here is a simple custom model that I'd like to use in caretList.

elm_fun <- getModelInfo("elm")[[1]]
elm_fun$prob <- function (modelFit, newdata, submodels = NULL)  {
  out <- exp(predict(modelFit, newdata))
  t(apply(out, 1, function(x) x/sum(x)))
}
elmFit1 <- train(factor(train_sub$target) ~ ., 
                 data = train_sub,
                  method = elm_fun,
                  trControl = fitControl,
                  metric="ROC",
                  verbose=T,
                  tuneGrid=expand.grid(nhid=seq(4000,5000,by=1000), 
                                       actfun=c('purelin')))

I haven't tried it yet but I'm assuming I can always add elmFit1 to the caretList but was wondering if there is way to do it all in caretList.

FR

zachmayer commented 8 years ago

Yeah, caretEnsemble doesn't like custom models at the moment. We're working on that

lsemployeeoftheyear commented 1 year ago

Was this ever resolved?

zachmayer commented 1 year ago

Yes, https://github.com/zachmayer/caretEnsemble/pull/198 should have resolved this