You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Do not use parallel processing in the code (unless you are certain that the issue is about parallel processing).
run sessionInfo()
Minimal, reproducible example:
library(caret)
dat = iris
dat$Species2Class = factor(dat$Species == "setosa", levels = c("TRUE", "FALSE"), labels = c("SETOSA", "OTHER"))
# constants used for random seeds
n = 2
r = 5
# set seeds to use for model reproducibility with parallel processing
set.seed(123)
seeds <- vector(mode = "list", length = (n*r)+1)
# for the cross-validation models
for(i in 1:((n*r))) seeds[[i]] <- sample.int(10000,5000)
# for the final model
seeds[[((n*r)+1)]] <- sample.int(1000,1)
fitControl <- trainControl(
seeds = seeds,
method = "repeatedcv",
number = n,
repeats = r,
savePredictions = 'final',
classProbs = T,
preProcOptions = list(pcaComp = 1),
summaryFunction = prSummary)
set.seed(1)
response = "Species2Class"
preds = names(dat)[1:4]
model.fmla = as.formula(paste0(response, " ~ ", paste0(preds, collapse="+")))
# run the model
fit_model <- train(form = model.fmla,
data = dat,
method = "rf",
trControl = fitControl,
preProcess = c("pca"),
metric = "AUC")
# OUTPUT:
# Error in { : task 1 failed - "subscript out of bounds"
# In addition: There were 50 or more warnings (use warnings() to see the first 50)
This happens when attempting to use only the first principal component. With 2 or more it works fine.
If you are filing a bug, make sure these boxes are checked before submitting your issue— thank you!
update.packages(oldPkgs="caret", ask=FALSE)
sessionInfo()
Minimal, reproducible example:
This happens when attempting to use only the first principal component. With 2 or more it works fine.
Session Info:
The text was updated successfully, but these errors were encountered: