我正在尝试跑步
control = trainControl(
method = "cv",
number = 5,
classProbs = TRUE,
summaryFunction = twoClassSummary
)
model_fit <-
caret::train(
Survived ~ .,
data = train_cleaned_model_train,
method = "glm",
family = binomial(link = logit),
preProc = c("knnImpute", "nzv"),
metric = "ROC",
trControl = control
)
根据以下结果,输入变量的名称似乎还可以
Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 534 obs. of 9 variables:
$ PassengerId: int 71 744 353 636 436 433 687 329 95 193 ...
$ Survived : Factor w/ 2 levels "0","1": 1 1 1 2 2 2 1 2 1 2 ...
$ Pclass : int 2 3 3 2 1 2 3 3 3 3 ...
$ Sex : chr "male" "male" "male" "female" ...
$ Age : num 32 24 15 28 14 42 14 31 59 19 ...
$ SibSp : int 0 1 1 0 1 1 4 1 0 1 ...
$ Parch : int 0 0 1 0 2 0 1 1 0 0 ...
$ Fare : num 10.5 16.1 7.23 13 120 ...
$ Embarked : chr "S" "S" "C" "S" ...
我还看到了有关同一问题的其他问题。它们大多具有带有变量名的变量,变量名以特殊字符或数字开头。似乎并非如此。
任何人都可以提供见解吗?
答案 0 :(得分:1)
我意识到结果需要编码为字符变量,并且不能为数字1或0。