我使用ada
R 包已经有一段时间了,最近,caret
. 根据文档,caret
的train()
函数应该有一个使用 ada. 但是,当我使用与我的ada()
通话中相同的语法时,插入符号正在向我吐口水。
这是一个使用wine
示例数据集的演示。
library(doSNOW)
registerDoSNOW(makeCluster(2, type = "SOCK"))
library(caret)
library(ada)
wine = read.csv("http://www.nd.edu/~mclark19/learn/data/goodwine.csv")
set.seed(1234) #so that the indices will be the same when re-run
trainIndices = createDataPartition(wine$good, p = 0.8, list = F)
wanted = !colnames(wine) %in% c("free.sulfur.dioxide", "density", "quality",
"color", "white")
wine_train = wine[trainIndices, wanted]
wine_test = wine[-trainIndices, wanted]
cv_opts = trainControl(method="cv", number=10)
###now, the example that works using ada()
results_ada <- ada(good ~ ., data=wine_train, control=rpart.control
(maxdepth=30, cp=0.010000, minsplit=20, xval=10), iter=500)
##this works, and gives me a confusion matrix.
results_ada
ada(good ~ ., data = wine_train, control = rpart.control(maxdepth = 30,
cp = 0.01, minsplit = 20, xval = 10), iter = 500)
Loss: exponential Method: discrete Iteration: 500
Final Confusion Matrix for Data:
Final Prediction
etc. etc. etc. etc.
##Now, the calls that don't work.
results_ada = train(good~., data=wine_train, method="ada",
control=rpart.control(maxdepth=30, cp=0.010000, minsplit=20,
xval=10), iter=500)
Error in train.default(x, y, weights = w, ...) :
final tuning parameters could not be determined
In addition: Warning messages:
1: In nominalTrainWorkflow(dat = trainData, info = trainInfo, method = method, :
There were missing values in resampled performance measures.
2: In train.default(x, y, weights = w, ...) :
missing values found in aggregated results
###this doesn't work, either
results_ada = train(good~., data=wine_train, method="ada", trControl=cv_opts,
maxdepth=10, nu=0.1, iter=50)
Error in train.default(x, y, weights = w, ...) :
final tuning parameters could not be determined
In addition: Warning messages:
1: In nominalTrainWorkflow(dat = trainData, info = trainInfo, method = method, :
There were missing values in resampled performance measures.
2: In train.default(x, y, weights = w, ...) :
missing values found in aggregated results
我猜这是 train() 需要额外的输入,但抛出的警告并没有给我任何关于缺少什么的提示。此外,我可能缺少一个依赖项,但没有提示应该有什么......