Johan
Johan

Reputation: 21

Confusion Matrix error

I want to build a predictive model using decision tree classification in R. but I got an error msg (Error: could not find function "confusionMatrix"??) when I run This line:

cmatrix <- confusionMatrix(predictions, worktest$YesNo)

what thats mean? please help me.

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")))
> 

Upvotes: 2

Views: 30132

Answers (2)

Abhishek
Abhishek

Reputation: 618

Install these two packages:

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

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

Upvotes: 2

Ankit Katiyar
Ankit Katiyar

Reputation: 3001

Try loading library(caret) lib. You may get some error in my case I see as.

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

It shows actually it fails to load Rcpp package so you need to install it

Solution: install.packages("Rcpp")

Upvotes: 3

Related Questions