Debian Codegraph @

man/tidy.roc.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/auc.R
3 \name{tidy.roc}
4 \alias{tidy.roc}
5 \alias{auc_tidiers}
6 \alias{roc_tidiers}
7 \title{Tidy a(n) roc object}
8 \usage{
9 \method{tidy}{roc}(x, ...)
10 }
11 \arguments{
12 \item{x}{An \code{roc} object returned from a call to \code{\link[AUC:roc]{AUC::roc()}}.}
13
14 \item{...}{Additional arguments. Not used. Needed to match generic
15 signature only. \strong{Cautionary note:} Misspelled arguments will be
16 absorbed in \code{...}, where they will be ignored. If the misspelled
17 argument has a default value, the default value will be used.
18 For example, if you pass \code{conf.lvel = 0.9}, all computation will
19 proceed using \code{conf.level = 0.95}. Two exceptions here are:
20 \itemize{
21 \item \code{tidy()} methods will warn when supplied an \code{exponentiate} argument if
22 it will be ignored.
23 \item \code{augment()} methods will warn when supplied a \code{newdata} argument if it
24 will be ignored.
25 }}
26 }
27 \description{
28 Tidy summarizes information about the components of a model.
29 A model component might be a single term in a regression, a single
30 hypothesis, a cluster, or a class. Exactly what tidy considers to be a
31 model component varies across models but is usually self-evident.
32 If a model has several distinct types of components, you will need to
33 specify which components to return.
34 }
35 \examples{
36 \dontshow{if (rlang::is_installed(c("AUC", "ggplot2"))) withAutoprint(\{ # examplesIf}
37
38 # load libraries for models and data
39 library(AUC)
40
41 # load data
42 data(churn)
43
44 # fit model
45 r <- roc(churn$predictions, churn$labels)
46
47 # summarize with tidiers + visualization
48 td <- tidy(r)
49 td
50
51 library(ggplot2)
52
53 ggplot(td, aes(fpr, tpr)) +
54 geom_line()
55
56 # compare the ROC curves for two prediction algorithms
57 library(dplyr)
58 library(tidyr)
59
60 rocs <- churn |>
61 pivot_longer(contains("predictions"),
62 names_to = "algorithm",
63 values_to = "value"
64 ) |>
65 nest(data = -algorithm) |>
66 mutate(tidy_roc = purrr::map(data, \(x) tidy(roc(x$value, x$labels)))) |>
67 unnest(tidy_roc)
68
69 ggplot(rocs, aes(fpr, tpr, color = algorithm)) +
70 geom_line()
71 \dontshow{\}) # examplesIf}
72 }
73 \seealso{
74 \code{\link[=tidy]{tidy()}}, \code{\link[AUC:roc]{AUC::roc()}}
75 }
76 \value{
77 A \code{\link[tibble:tibble]{tibble::tibble()}} with columns:
78 \item{cutoff}{The cutoff used for classification. Observations with predicted probabilities above this value were assigned class 1, and observations with predicted probabilities below this value were assigned class 0.}
79 \item{fpr}{False positive rate.}
80 \item{tpr}{The true positive rate at the given cutoff.}
81
82 }