in caret settings, if you want do 10*10 cross validation, you need to set repeats=10, number=10 and method=repeatedcv, (#2061)

if you set method=cv, actually just one 10-fold cross validation will be run; fixes #2055
This commit is contained in:
moqiguzhu 2017-02-25 06:16:19 -08:00 committed by Yuan (Terry) Tang
parent 7927031ffe
commit 5d093a7f4c

View File

@ -24,7 +24,7 @@ df[,ID:=NULL]
#-------------Basic Training using XGBoost in caret Library----------------- #-------------Basic Training using XGBoost in caret Library-----------------
# Set up control parameters for caret::train # Set up control parameters for caret::train
# Here we use 10-fold cross-validation, repeating twice, and using random search for tuning hyper-parameters. # Here we use 10-fold cross-validation, repeating twice, and using random search for tuning hyper-parameters.
fitControl <- trainControl(method = "cv", number = 10, repeats = 2, search = "random") fitControl <- trainControl(method = "repeatedcv", number = 10, repeats = 2, search = "random")
# train a xgbTree model using caret::train # train a xgbTree model using caret::train
model <- train(factor(Improved)~., data = df, method = "xgbTree", trControl = fitControl) model <- train(factor(Improved)~., data = df, method = "xgbTree", trControl = fitControl)