【发布时间】:2017-09-09 09:58:02
【问题描述】:
我有不平衡的数据集(6% 肯定),我使用过 caret 包中的 xgboost 模型。
这是我的代码:
gbmGrid <- expand.grid(nrounds = 50,
eta = 0.4,
max_depth = 2,
gamma = 0,
colsample_bytree=0.8,
min_child_weight=1,
subsample=1)
ctrl <- trainControl(method = "cv",
number = 10,
search = "grid",
fixedWindow = TRUE,
verboseIter = TRUE,
returnData = TRUE,
returnResamp = "final",
savePredictions = "all",
classProbs = TRUE,
summaryFunction = twoClassSummary,
sampling = "smote",
selectionFunction = "best",
trim = FALSE,
allowParallel = TRUE)
classifier <- train(x = training_set[,-1],y = training_set[,1], method = 'xgbTree',metric = "ROC",trControl = ctrl,tuneGrid = gbmGrid)
问题在于,每次我“运行”火车线路时,它都会给出不同的 roc、sensetivity 和 specificity。
ROC Sens Spec
0.696084 0.8947368 0.2736111
ROC Sens Spec
0.6655806 0.8917293 0.2444444
** expand.grid 设置在最佳调谐模型上。
有人明白为什么模型不稳定吗?
【问题讨论】: