Tried taking on the problem with research and hence the hiatus. The possible solution to my problem could be:
1) One hot encoding: basically a reprocessing method of converting training data to simple factors/numerics
2)Argument input method:
x<-data_prepro_maf_train[,c(1,3,5,6,7,8)]
y<-data_prepro_maf_train[,12]
model_list1<-caretList(x,y,data=data_prepro_maf_train,trControl = control,metric="Accuracy",methodList = class_model[1])
I changed it to y~X1+X2+X3 method and at least now CaretList is running some models
[Discussion on formula formula-vs-non-formula-interface-in-train1
Below are the changes made:
#Let’s one hot encode the data_prepro_maf_train data
dummy_model1<-dummyVars(title~.,data=data_prepro_maf_train[c(1,2,3,5,6,7,8,10)])
data_train_mat1<-predict(dummy_model1,newdata=data_prepro_maf_train)
data_prepro_maf_train2<-data.frame(data_train_mat1)
#Add back columns “title” and “Embarked”, which have vital factors for the model
data_prepro_maf_train2<-cbind(data_prepro_maf_train$Embarked,data_prepro_maf_train$title,data_prepro_maf_train2)
colnames(data_prepro_maf_train2)[1]<-"Embarked"
colnames(data_prepro_maf_train2)[2]<-"title"
#Adjust consistency of levels in the new train data. If the error below shows up, try running this code again before running model_list2 (not sure why it is not saved):
"Error: One or more factor levels in the outcome has no data: 'Q'"
levels(data_prepro_maf_train2$Embarked)<-droplevels(data_prepro_maf_train2$Embarked)
set.seed(123)
number<-3
repeats<-2
control<-trainControl(method="repeatedcv",number=number,repeats=repeats,classProbs = TRUE,savePredictions = "all",index=createResample(data_prepro_maf_train$Embarked,repeats*number),summaryFunction = multiClassSummary,allowParallel = TRUE)
#Since the class_model has over 100 models...let's select a few that we know for testing the previous error (I stumbled upon the “preProcess=c(“center”,”scale”) which said to help in my situation…not sure how it works and would appreciate if someone could explain it?? :
model_list2<-caretList(Embarked~title+Pclass+Age+Sex.male+Sex.female+SibSp+Parch,data=data_prepro_maf_train1,preProcess = c("center", "scale"),trControl = control,metric="Accuracy",methodList = class_model[c(37,52,55,68,102,145,167,189)])
Not confident if this is the end of my problem....at least the model is running and not stopping without any findings