首先我要说的是,我已经阅读了很多关于交叉验证的帖子,似乎有很多混乱.我的理解就是这样:
我正在尝试使用rpartR 构建一个决策树并利用该caret包.以下是我正在使用的代码.
# load libraries
library(caret)
library(rpart)
# define training control
train_control<- trainControl(method="cv", number=10)
# train the model
model<- train(resp~., data=mydat, trControl=train_control, method="rpart")
# make predictions
predictions<- predict(model,mydat)
# append predictions
mydat<- cbind(mydat,predictions)
# summarize results
confusionMatrix<- confusionMatrix(mydat$predictions,mydat$resp)
Run Code Online (Sandbox Code Playgroud)
我有一个关于插入火车应用的问题.我已经阅读了插入符号列表部分的简短介绍,其中说明了在重新采样过程中确定了"最佳参数集".
在我的例子中,我是否正确编码了?我是否需要rpart在代码中定义参数或我的代码是否足够?