File: as.matrix.confusionMatrix.Rd

package info (click to toggle)
r-cran-caret 7.0-1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,036 kB
  • sloc: ansic: 210; sh: 10; makefile: 2
file content (57 lines) | stat: -rw-r--r-- 1,406 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/confusionMatrix.R
\name{as.matrix.confusionMatrix}
\alias{as.matrix.confusionMatrix}
\alias{as.table.confusionMatrix}
\title{Confusion matrix as a table}
\usage{
\method{as.matrix}{confusionMatrix}(x, what = "xtabs", ...)
}
\arguments{
\item{x}{an object of class \code{\link{confusionMatrix}}}

\item{what}{data to convert to matrix. Either \code{"xtabs"}, \code{"overall"} or  \code{"classes"}}

\item{\dots}{not currently used}
}
\value{
A matrix or table
}
\description{
Conversion functions for class \code{confusionMatrix}
}
\details{
For \code{as.table}, the cross-tabulations are saved. For \code{as.matrix}, the three object types are saved in matrix format.
}
\examples{
###################
## 2 class example

lvs <- c("normal", "abnormal")
truth <- factor(rep(lvs, times = c(86, 258)),
                levels = rev(lvs))
pred <- factor(
               c(
                 rep(lvs, times = c(54, 32)),
                 rep(lvs, times = c(27, 231))),
               levels = rev(lvs))

xtab <- table(pred, truth)

results <- confusionMatrix(xtab)
as.table(results)
as.matrix(results)
as.matrix(results, what = "overall")
as.matrix(results, what = "classes")

###################
## 3 class example

xtab <- confusionMatrix(iris$Species, sample(iris$Species))
as.matrix(xtab)

}
\author{
Max Kuhn
}
\keyword{utilities}