混淆矩阵错误

时间:2015-04-24 17:40:09

标签: r

我想在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")))
> 

2 个答案:

答案 0 :(得分:2)

尝试加载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")

答案 1 :(得分:1)

安装这两个包:

install.packages('e1071', dependencies=TRUE)

install.packages('caret', dependencies=TRUE)