我正在尝试更多地了解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
算法?除此之外,我不知道。