| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/caret.R |
| 3 |
\name{tidy.confusionMatrix} |
| 4 |
\alias{tidy.confusionMatrix} |
| 5 |
\alias{caret_tidiers} |
| 6 |
\alias{confusionMatrix_tidiers} |
| 7 |
\title{Tidy a(n) confusionMatrix object} |
| 8 |
\usage{ |
| 9 |
\method{tidy}{confusionMatrix}(x, by_class = TRUE, ...) |
| 10 |
} |
| 11 |
\arguments{ |
| 12 |
\item{x}{An object of class \code{confusionMatrix} created by a call to |
| 13 |
\code{\link[caret:confusionMatrix]{caret::confusionMatrix()}}.} |
| 14 |
|
| 15 |
\item{by_class}{Logical indicating whether or not to show performance |
| 16 |
measures broken down by class. Defaults to \code{TRUE}. When \code{by_class = FALSE} |
| 17 |
only returns a tibble with accuracy, kappa, and McNemar statistics.} |
| 18 |
|
| 19 |
\item{...}{Additional arguments. Not used. Needed to match generic |
| 20 |
signature only. \strong{Cautionary note:} Misspelled arguments will be |
| 21 |
absorbed in \code{...}, where they will be ignored. If the misspelled |
| 22 |
argument has a default value, the default value will be used. |
| 23 |
For example, if you pass \code{conf.lvel = 0.9}, all computation will |
| 24 |
proceed using \code{conf.level = 0.95}. Two exceptions here are: |
| 25 |
\itemize{ |
| 26 |
\item \code{tidy()} methods will warn when supplied an \code{exponentiate} argument if |
| 27 |
it will be ignored. |
| 28 |
\item \code{augment()} methods will warn when supplied a \code{newdata} argument if it |
| 29 |
will be ignored. |
| 30 |
}} |
| 31 |
} |
| 32 |
\description{ |
| 33 |
Tidy summarizes information about the components of a model. |
| 34 |
A model component might be a single term in a regression, a single |
| 35 |
hypothesis, a cluster, or a class. Exactly what tidy considers to be a |
| 36 |
model component varies across models but is usually self-evident. |
| 37 |
If a model has several distinct types of components, you will need to |
| 38 |
specify which components to return. |
| 39 |
} |
| 40 |
\examples{ |
| 41 |
\dontshow{if (rlang::is_installed("caret")) withAutoprint(\{ # examplesIf} |
| 42 |
|
| 43 |
# load libraries for models and data |
| 44 |
library(caret) |
| 45 |
|
| 46 |
set.seed(27) |
| 47 |
|
| 48 |
# generate data |
| 49 |
two_class_sample1 <- as.factor(sample(letters[1:2], 100, TRUE)) |
| 50 |
two_class_sample2 <- as.factor(sample(letters[1:2], 100, TRUE)) |
| 51 |
|
| 52 |
two_class_cm <- confusionMatrix( |
| 53 |
two_class_sample1, |
| 54 |
two_class_sample2 |
| 55 |
) |
| 56 |
|
| 57 |
# summarize model fit with tidiers |
| 58 |
tidy(two_class_cm) |
| 59 |
tidy(two_class_cm, by_class = FALSE) |
| 60 |
|
| 61 |
# multiclass example |
| 62 |
six_class_sample1 <- as.factor(sample(letters[1:6], 100, TRUE)) |
| 63 |
six_class_sample2 <- as.factor(sample(letters[1:6], 100, TRUE)) |
| 64 |
|
| 65 |
six_class_cm <- confusionMatrix( |
| 66 |
six_class_sample1, |
| 67 |
six_class_sample2 |
| 68 |
) |
| 69 |
|
| 70 |
# summarize model fit with tidiers |
| 71 |
tidy(six_class_cm) |
| 72 |
tidy(six_class_cm, by_class = FALSE) |
| 73 |
\dontshow{\}) # examplesIf} |
| 74 |
} |
| 75 |
\seealso{ |
| 76 |
\code{\link[=tidy]{tidy()}}, \code{\link[caret:confusionMatrix]{caret::confusionMatrix()}} |
| 77 |
} |
| 78 |
\value{ |
| 79 |
A \code{\link[tibble:tibble]{tibble::tibble()}} with columns: |
| 80 |
\item{class}{The class under consideration.} |
| 81 |
\item{conf.high}{Upper bound on the confidence interval for the estimate.} |
| 82 |
\item{conf.low}{Lower bound on the confidence interval for the estimate.} |
| 83 |
\item{estimate}{The estimated value of the regression term.} |
| 84 |
\item{term}{The name of the regression term.} |
| 85 |
\item{p.value}{P-value for accuracy and kappa statistics.} |
| 86 |
|
| 87 |
} |