【发布时间】:2015-06-02 09:23:43
【问题描述】:
我正在应用预测建模(梯度提升机),我的代码在我的笔记本电脑上有错误,但在大学计算机中没有。
我认为错误在第 203 行,train。
错误:
Error in train.default(training_data[, predictorsNames], training_data[, :
final tuning parameters could not be determined
In addition: Warning messages:
1: In nominalTrainWorkflow(x = x, y = y, wts = weights, info = trainInfo, :
There were missing values in resampled performance measures.
2: In train.default(training_data[, predictorsNames], training_data[, :
missing values found in aggregated results
# TRAINING & CROSSVALIDATION SETS
filtered_processed_dataset$IsDelayed<-ifelse(filtered_processed_dataset$IsDelayed==1,'yes','nope')
filtered_processed_dataset$IsDelayed<-as.factor(filtered_processed_dataset$IsDelayed)
outcomeName<-'IsDelayed'
predictorsNames<-names(filtered_processed_dataset)[names(filtered_processed_dataset)!=outcomeName]
inTrain<-caret::createDataPartition(filtered_processed_dataset$IsDelayed,p=.85,list=FALSE)
training_data<-filtered_processed_dataset[inTrain,]
crossvalidation_data<-filtered_processed_dataset[-inTrain,]
# GRADIENT BOOSTING MACHINE
getModelInfo()$gbm$type
rownames(training_data)<-NULL
gbmGrid<-expand.grid(interaction.depth=c(1,5,9), n.trees=100, shrinkage=0.1)
fitControl<-trainControl(
method='cv',
number=3,
returnResamp='none',
verbose=FALSE,
summaryFunction=twoClassSummary,
classProbs=TRUE)
**g<-train(training_data[,predictorsNames], training_data[,outcomeName],
method='gbm',
trControl=fitControl,
metric="ROC",
tuneGrid=gbmGrid)**
crossvalidation_data<-as.data.frame(crossvalidation_data)
rownames(crossvalidation_data)<-NULL
p_gbm<-predict(g, crossvalidation_data[,predictorsNames], type='prob')
auc<-pROC::roc(ifelse(crossvalidation_data[,outcomeName]=="yes",1,0),p_gbm[[2]])
print(auc)
非常感谢。
【问题讨论】:
-
这是绝对不可复制的,我想能帮助你的人不多。你为什么用rstudio标记这个问题?您是否尝试过在 Rstudio 之外运行代码以确认这是 R 问题?