在插入符号confusionMatrix中应用其他参数时出错

用户名

我正在尝试将混淆矩阵应用于我的数据。我的代码是:

library(caret)
library(furrr)

df %>%
  future_map(.,
             ~confusionMatrix(
               as.factor(..1$pred_status),
               as.factor(..1$status),
               model = "everything", positive = "1")
  )

我收到的错误如下:

表中的错误(数据,引用,dnn = dnn,...):所有参数的长度必须相同

但是,当我注释掉该model = "everything", positive = "1"行并运行时。

df %>%
  future_map(.,
             ~confusionMatrix(
               as.factor(..1$pred_status),
               as.factor(..1$status),
               #model = "everything", positive = "1"
               )
  )

我没有得到一个错误。我想设置model = "everything")参数时为什么得到它

数据:

    list(structure(list(status = c(0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 1L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
1L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L), pred_status = c(0, 
0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), row.names = c(NA, 
-100L), class = "data.frame"), structure(list(status = c(0L, 
0L, 0L, 0L, 0L, 1L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 
0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L), pred_status = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 
0, 0, 0, 0, 0)), row.names = c(NA, -100L), class = "data.frame"), 
    structure(list(status = c(0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 
    0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 
    1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
    1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
    0L, 0L), pred_status = c(0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), row.names = c(NA, 
    -100L), class = "data.frame"), structure(list(status = c(1L, 
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
    1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
    0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L), pred_status = c(1, 0, 
    0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 
    1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0)), row.names = c(NA, -100L), class = "data.frame"))
阿克伦

通过检查confusionMatrix,它是mode不是model

library(furrr)
library(caret)
df %>%
  future_map(.,
             ~confusionMatrix(
               as.factor(.x$pred_status),
               as.factor(.x$status),
               mode = "everything", positive = "1")
  )

另外,由于只有一个参数,我们可以使用 .x

另外,如果其中一列只有一个值,则最好指定levelsinfactor

df %>%
  future_map(.,
             ~confusionMatrix(
               factor(.x$pred_status, levels = 0:1),
               factor(.x$status, levels = 0:1),
               mode = "everything", positive = "1")
  )

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

对于名称中带有点和其他符号的目录,与 rsync 同步输出错误“无效参数 (22)”

在其他工作表中运行宏时出错

在python中安装模块或包或其他东西时出错

更新视图时,在基础表中插入其他值

表中的错误(数据,引用,dnn = dnn等):在R中使用脱字符号运行confusionMatrix时,所有参数的长度必须相同

使用GET方法时,URL中的其他参数丢失

除了从其他地方复制外,如何在Chrome中插入表情符号?

将插入符号的confusionMatrix应用于由data.frames组成的列表,从而导致多个混淆矩阵

在插入符号中调整自定义 SVM 模型时出错

尝试在插入符号包中传递自定义指标时出错

显示卢比符号时,它会转换为其他符号

如何在 Kotlin 中其他函数内部的函数中插入参数

通话中的其他参数

如何发送混淆矩阵到插入符号的confusionMatrix?

使用插入符号包训练多个模型时出错

R的插入符号包中的rfe给出错误,因为:任务1失败-“参数1不是向量”

使用Python在Mac上的应用程序上打开时,如何给其他参数?

在python中读取json文件时,数据中出现了一些其他的unicode符号

在Elixir中,为什么在创建地图时不能使用其他符号?

在 GCC 中对 wstringstream 类型的参数使用流插入而不是 MSVC 时出错

在JS代码的其他标签中打开网址时出错

在引用其他程序集的SQL Server 2017中注册CLR程序集时出错

从同一父目录中的其他文件夹导入模块时出错

在其他函数中传递局部变量的值时出错

我可以在 php 错误日志中添加其他信息 - *仅在出错时吗?

PowerShell:读取在其他程序中打开的文件时出错

使用 re.sub() 从 Pandas 数据框中删除所有其他内容时出错

尝试引用VB.net程序其他模块中的子例程时出错

从Asp.net中的其他类调用代码时出错