R 运行插入符号模型并停止。它提到了重采样性能度量中缺少的值

R 运行插入符号模型并停止。它提到了重采样性能度量中缺少的值,r,r-caret,R,R Caret,[数据集]作为一名新手,我尝试了泰坦尼克号问题。正准备使用数据集进行训练,这就是我遇到的问题: 试图通过研究来解决这个问题,因此中断了研究。我的问题的可能解决方案是: 1) 一种热编码:基本上是一种将训练数据转换为简单因子/数字的再处理方法 2) 参数输入法: 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_

[数据集]作为一名新手,我尝试了泰坦尼克号问题。正准备使用数据集进行训练,这就是我遇到的问题:


试图通过研究来解决这个问题,因此中断了研究。我的问题的可能解决方案是:

1) 一种热编码:基本上是一种将训练数据转换为简单因子/数字的再处理方法

2) 参数输入法:

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])

x您能用
dput(head(df,n))
提供您的数据样本吗。附加到数据集的链接。@Jabby您能提供对象
all\u model
?你的问题中没有。因此,我无法继续。您加载了哪些库,请同时显示这些库?所有模型您正在使用
caret
软件包中提供的所有分类模型。因此,培训需要时间。你可以看到
library(caret)
library(caretEnsemble)
library(tidyverse)
library(magrittr)
library(doParallel)
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])
#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)])