【发布时间】:2020-09-23 21:15:44
【问题描述】:
> cv.ctrl <- trainControl(method = "repeatedcv", repeats = 3,
+ summaryFunction = twoClassSummary,
+ classProbs = TRUE)
>
> set.seed(35)
> glm.tune.1 <- train(y ~ bool_3,
+ data = train.batch,
+ method = "glm",
+ metric = "ROC",
+ trControl = cv.ctrl)
Error in sensitivity.default(data[, "pred"], data[, "obs"], lev[1]) :
input data must have the same two levels
In addition: Warning message:
In train.default(x, y, weights = w, ...) :
At least one of the class levels are not valid R variables names; This may cause errors if class probabilities are generated because the variables names will be converted to: X.1, X0, X1
这是数据结构的摘录:
> str(train.batch)
'data.frame': 128046 obs. of 42 variables:
$ bool_3 : int 0 0 0 0 0 0 0 1 0 0 ...
$ bool_brand_cat : int 0 0 0 0 0 0 0 1 0 0 ...
$ bool_cat_comp : int 0 0 0 0 0 0 0 1 0 0 ...
...
$ y : Factor w/ 3 levels "-1","0","1": 2 3 2 2 2 3 3 3 3 2 ...
我需要设置灵敏度吗?或者我错过了什么?
【问题讨论】: