gpt4 book ai didi

r - 混淆矩阵错误

转载 作者:行者123 更新时间:2023-12-02 04:21:50 25 4
gpt4 key购买 nike

我想使用 R 中的决策树分类构建预测模型。但当我运行此行时,我收到错误消息(错误:找不到函数“confusionMatrix”??):

cmatrix <- confusionMatrix(predictions, worktest$YesNo)

那是什么意思?请帮助我。

the dput() output:
> dput(worktest$ICUtransfer)
Error in worktest$ICUtransfer : $ operator is invalid for atomic vectors
> dput(ICUtransfer)
Error in dput(ICUtransfer) : object 'ICUtransfer' not found
> dput(worktest)
c(2L, 15L, 19L, 20L, 21L, 34L, 36L, 37L, 39L, 41L)
> dput(fitted)
structure(c(0.689655172413793, 0.689655172413793, 0.689655172413793,
0.454545454545455, 0.689655172413793, 0.454545454545455, 0.689655172413793,
0.454545454545455, 0.689655172413793, 0.689655172413793, 0.310344827586207,
0.310344827586207, 0.310344827586207, 0.545454545454546, 0.310344827586207,
0.545454545454546, 0.310344827586207, 0.545454545454546, 0.310344827586207,
0.310344827586207), .Dim = c(10L, 2L), .Dimnames = list(c("2",
"15", "19", "20", "21", "34", "36", "37", "39", "41"), c("no",
"yes")))
>

最佳答案

尝试加载library(caret) lib。在我看来,您可能会遇到一些错误。

Loading required package: lattice
Loading required package: ggplot2
Error: package or namespace load failed for ‘ggplot2’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
there is no package called ‘Rcpp’
Error: package ‘ggplot2’ could not be loaded

它实际上显示无法加载Rcpp包,因此您需要安装它

解决方案:install.packages("Rcpp")

关于r - 混淆矩阵错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29854053/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com