When running rpart
, I am getting an error message saying :
Something is wrong; all the Accuracy metric values are missing:
The dataset can be found here and has no NAs, can someone help?
> rf.5.cv.1
# Random Forest
# 891 samples
# 6 predictor
# 2 classes: '0', '1'
# No pre-processing
# Resampling: Cross-Validated (10 fold, repeated 10 times)
# Summary of sample sizes: 802, 802, 803, 801, 801, 802, ...
# Resampling results across tuning parameters:
# mtry Accuracy Kappa
# 2 0.8383655 0.6496840
# 4 0.8289433 0.6339793
# 6 0.8219857 0.6196764
# Accuracy was used to select the optimal model using the largest value.
# The final value used for the model was mtry = 2.
library(rpart)
library(caret)
library(snow)
library(doSNOW)
data.combined <- read.csv("data_combined.csv")
rf.label <- as.factor(data.combined[1:891,]$Survived)
cv.10.folds <- createMultiFolds(rf.label,k = 10,times = 10)
ctrl.1 <- trainControl(method = "repeatedcv", number = 10, repeats = 10,
index = cv.10.folds)
rpart.cv <- function(seed, training, labels, ctrl) {
set.seed(seed)
cl <- makeCluster(6, type = "SOCK")
registerDoSNOW(cl)
rpart.cv <- train(x = training,
y = labels,
method = "rpart",
tunelength = 3, trControl = ctrl)
stopCluster(cl)
return(rpart.cv)
}
features <- c("Pclass","Title", "Sex","Fare","Age","Family.Size")
rpart.train.1 <- data.combined[1:891,features]
rpart.1.cv.1 <- rpart.cv(1287, rpart.train.1, rf.label, ctrl.1)
# Something is wrong; all the Accuracy metric values are missing:
# Accuracy Kappa
# Min. : NA Min. : NA
# 1st Qu.: NA 1st Qu.: NA
# Median : NA Median : NA
# Mean :NaN Mean :NaN
# 3rd Qu.: NA 3rd Qu.: NA
# Max. : NA Max. : NA
# NA's :3 NA's :3
# Error in train.default(x = training, y = labels, method = "rpart",
# tunelength = 3, :
# Stopping
# In addition: Warning message:
# In nominalTrainWorkflow(x = x, y = y, wts = weights, info = trainInfo, :
# There were missing values in resampled performance measures.
# Called from: train.default(x = training, y = labels, method = "rpart",
# tunelength = 3,
# trControl = ctrl)
# Browse[1]> Q
# >