【问题标题】:R caret Error in sensitivity.defaultR caret 灵敏度错误。默认
【发布时间】: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 ...

我需要设置灵敏度吗?或者我错过了什么?

【问题讨论】:

    标签: r r-caret


    【解决方案1】:

    y 是“Factor w/ 3 levels”。除非结果中有两个级别,否则您无法计算敏感性和特异性(请参阅input data must have the same two levels 的注释)

    【讨论】:

      【解决方案2】:

      当我收到相同的消息时,我偶然发现了这一点,我理解为什么会根据解释生成它,但确实可以计算出多类问题的敏感性

      http://www.cs.odu.edu/~mukka/cs495s13/Lecturenotes/Chapter5/recallprecision.pdf

      它还没有在插入符号中实现,它可能永远不会

      【讨论】:

        【解决方案3】:

        它帮助我再次 install.packages("caret")

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2019-12-22
          • 1970-01-01
          • 1970-01-01
          • 2015-08-17
          • 1970-01-01
          • 1970-01-01
          • 2017-09-23
          • 2011-01-30
          相关资源
          最近更新 更多