错误:使用插入符包时尝试应用非函数

时间:2015-08-15 02:39:37

标签: r machine-learning r-caret

我正在尝试更多地了解caret软件包,并遇到了一个我不确定如何解决的障碍。

#loading up libraries
library(MASS)
library(caret)
library(randomForest)
data(survey)
data<-survey

#create training and test set
split <- createDataPartition(data$W.Hnd, p=.8)[[1]]
train<-data[split,]
test<-data[-split,]


#creating training parameters
control <- trainControl(method = "cv",
                        number = 10, 
                        p =.8, 
                        savePredictions = TRUE, 
                        classProbs = TRUE, 
                        summaryFunction = "twoClassSummary")

#fitting and tuning model
tuningGrid <- data.frame(.mtry = floor(seq(1 , ncol(train) , length = 6)))
rf_tune <- train(W.Hnd ~ . , 
            data=train, 
            method = "rf" ,
            metric = "ROC",
            trControl = control)

不断收到错误:

Error in evalSummaryFunction(y, wts = weights, ctrl = trControl, lev = classLevels,  : 
  attempt to apply non-function

我已经确认我的DV(W.Hnd)是一个因子水平,因此随机森林适合用于分类。我的假设是caret不知道是否适用于randomForest算法?除此之外,我不知道。

0 个答案:

没有答案