prediction - How to predict on a new dataset using caretEnsemble package in R? -
i using caretensemble
package in r combining multiple models trained in caret. have got list of final trained models (say model_list
) using caretlist
function same package follows.
model_list <- caretlist( x = input_predictors, y = input_labels, metric = 'accuracy', tunelist = list( randomforestmodel = caretmodelspec(method='rf', tunelength=1, preprocess=c('boxcox', 'center', 'scale')), ldamodel = caretmodelspec(method='lda', tunelength=1, preprocess=c('boxcox', 'center', 'scale')), logisticregressionmodel = caretmodelspec(method='glm', tunelength=1, preprocess=c('boxcox', 'center', 'scale')) ), trcontrol = mytraincontrol )
the train control object provided follows :
mytraincontrol = traincontrol(method = "cv", number = 10, index=createresample(training_input_data$retinopathy, 10), savepredictions = true, classprobs = true, verboseiter = true, summaryfunction = twoclasssummary)
now training on list of models :
ens <- caretensemble(model_list)
applying summary
on ens
tells me selected models (out of model_list
), weightage allocated selected models, out-of-sample auc
values each of selected models, , in-sample auc
values ens
.
now want compute performance of ens
on other test-data (to idea out-of-sample performance). how achieve it?
i trying out :
enspredictions <- predict(ens, newdata = test_data)
but it's giving me error :
error in `[.data.frame`(out, , obslevels, drop = false) : undefined columns selected
Comments
Post a Comment