I've been using the ada
R package for a while, and more recently, caret
. According to the documentation, caret
's train()
function should have an option that uses ada. But, caret is puking at me when I use the same syntax that sits within my ada()
call.
Here's a demonstration, using the wine
sample data set.
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
I'm guessing it's that train() wants additional input, but the warning thrown doesn't give me any hints on what's missing. Additionally, I could be missing a dependency, but there's no hint on what should be there....
Look up ?train
and search for ada
you'll see that:
Method Value: ada from package ada with tuning parameters: iter, maxdepth, nu (classification only)
So you must be missing the nu
parameter, and the maxdepth
parameter.